From 0de7642d4c34a90d7539e0eae2c6cf2c8e5ab9ae Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" <1josegomezr@gmail.com> Date: Tue, 12 Nov 2024 21:56:56 +0100 Subject: [PATCH 1/7] Support arbitrary registration URL Add support for `operatingSystem.packages.sccRegistrationUrl` to allow for registration against an RMT/SMT/SUMA. --- pkg/image/definition.go | 1 + pkg/rpm/resolver/resolver.go | 2 ++ pkg/rpm/resolver/templates/rpm-resolution.sh.tpl | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/image/definition.go b/pkg/image/definition.go index feb8f05a..e3f4a8cd 100644 --- a/pkg/image/definition.go +++ b/pkg/image/definition.go @@ -128,6 +128,7 @@ type Packages struct { PKGList []string `yaml:"packageList"` AdditionalRepos []AddRepo `yaml:"additionalRepos"` RegCode string `yaml:"sccRegistrationCode"` + RegUrl string `yaml:"sccRegistrationUrl"` } type AddRepo struct { diff --git a/pkg/rpm/resolver/resolver.go b/pkg/rpm/resolver/resolver.go index edcbcf07..22a6c061 100644 --- a/pkg/rpm/resolver/resolver.go +++ b/pkg/rpm/resolver/resolver.go @@ -182,6 +182,7 @@ func (r *Resolver) prepareLocalRPMs(localRPMConfig *image.LocalRPMConfig) error func (r *Resolver) writeRPMResolutionScript(localRPMConfig *image.LocalRPMConfig, packages *image.Packages) error { values := struct { RegCode string + RegUrl string AddRepo []image.AddRepo CacheDir string PKGList string @@ -192,6 +193,7 @@ func (r *Resolver) writeRPMResolutionScript(localRPMConfig *image.LocalRPMConfig EnableExtras bool }{ RegCode: packages.RegCode, + RegUrl: packages.RegUrl, AddRepo: packages.AdditionalRepos, CacheDir: r.generateResolverImgRPMRepoPath(), NoGPGCheck: packages.NoGPGCheck, diff --git a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl index 5fdd8766..acbfceda 100644 --- a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl +++ b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl @@ -13,7 +13,7 @@ set -euo pipefail # EnableExtras - registers the SL-Micro-Extras repo for use in resolution {{ if ne .RegCode "" }} -suseconnect -r {{ .RegCode }} +suseconnect -r {{ .RegCode }} {{- with .RegUrl }} --url "{{ . }}" {{- end }} {{ if $.EnableExtras -}} suseconnect -p SL-Micro-Extras/6.0/{{ .Arch }} {{ end -}} From cef09fee65b01ecfbc777d63199e0e0e5c9c2595 Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 22 Nov 2024 21:38:18 +0100 Subject: [PATCH 2/7] Validate registration url parameter Use net/url.Parse function to ensure a valid url is present --- pkg/image/validation/os.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/image/validation/os.go b/pkg/image/validation/os.go index 7cc3590d..e62aaf44 100644 --- a/pkg/image/validation/os.go +++ b/pkg/image/validation/os.go @@ -2,6 +2,7 @@ package validation import ( "fmt" + "net/url" "slices" "strings" @@ -226,6 +227,16 @@ func validatePackages(os *image.OperatingSystem) []FailedValidation { } } + if os.Packages.RegUrl != "" { + _, err := url.Parse(os.Packages.RegUrl) + if err != nil { + msg := fmt.Sprintf("The 'sccRegistrationUrl' is not a valid url: %s", err) + failures = append(failures, FailedValidation{ + UserMessage: msg, + }) + } + } + return failures } From f7828af0da0533d40b150f772de70bc73b9ff32f Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 22 Nov 2024 21:40:38 +0100 Subject: [PATCH 3/7] Example of a registration url in the sample YAML --- pkg/image/testdata/full-valid-example.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/image/testdata/full-valid-example.yaml b/pkg/image/testdata/full-valid-example.yaml index 7ab6d38e..6c296b74 100644 --- a/pkg/image/testdata/full-valid-example.yaml +++ b/pkg/image/testdata/full-valid-example.yaml @@ -76,6 +76,7 @@ operatingSystem: - url: https://developer.download.nvidia.com/compute/cuda/repos/sles15/x86_64/ unsigned: true sccRegistrationCode: INTERNAL-USE-ONLY-foo-bar + sccRegistrationUrl: https://registration-server.like-rmt-smt.here/ embeddedArtifactRegistry: images: - name: hello-world:latest From 4a36df7780d5679bb7b00eb58ddbdbde821b3d8f Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 22 Nov 2024 21:42:15 +0100 Subject: [PATCH 4/7] Test registration URL goes from YAML to go struct --- pkg/image/definition_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/image/definition_test.go b/pkg/image/definition_test.go index b7e021fb..6906332d 100644 --- a/pkg/image/definition_test.go +++ b/pkg/image/definition_test.go @@ -117,6 +117,7 @@ func TestParse(t *testing.T) { } assert.Equal(t, expectedAddRepos, pkgConfig.AdditionalRepos) assert.Equal(t, "INTERNAL-USE-ONLY-foo-bar", pkgConfig.RegCode) + assert.Equal(t, "https://registration-server.like-rmt-suma.here/", pkgConfig.RegUrl) // Operating System -> IsoConfiguration installDevice := definition.OperatingSystem.IsoConfiguration.InstallDevice From 98c0d0d9932ade0fc0e61086c3b76debece9a5b2 Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 22 Nov 2024 21:54:10 +0100 Subject: [PATCH 5/7] Document usage of Registration URL --- docs/building-images.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/building-images.md b/docs/building-images.md index 969ccd25..6db5653e 100644 --- a/docs/building-images.md +++ b/docs/building-images.md @@ -114,6 +114,7 @@ operatingSystem: - url: https://example2.com unsigned: true sccRegistrationCode: scc-reg-code + sccRegistrationUrl: https://registration-server.like-rmt-suma.here/ ``` ### Type-specific Configuration @@ -200,6 +201,10 @@ see the [Installing packages](./installing-packages.md) guide. * `unsigned` - This must be set to `true` if the repository is unsigned. * `sccRegistrationCode` - Specifies the SUSE Customer Center registration code in plain text, which is used to connect to SUSE's internal RPM repositories. + * `sccRegistrationUrl` - Specifies a registration server like RMT or SUMA, which is used to connect download SUSE's internal RPM repositories. Defaults to `https://scc.suse.com`. + +> **_NOTE:_** When using `sccRegistrationUrl` over `https` it's important that the `eib` recognizes the CA of the `registrationUrl`. +> This is common on RMT setups. See the [RMT docs on configuring clients](https://documentation.suse.com/sles/15-SP6/html/SLES-all/cha-rmt-client.html). ## Kubernetes From 5bf8166d43cfe6bfb60113a4bdc6e8274c78a58e Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 22 Nov 2024 21:57:25 +0100 Subject: [PATCH 6/7] Add line in release notes --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b5b1ece7..c8816a7d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -9,6 +9,7 @@ ### Image Definition Changes * Added the `enableExtras` flag to enable the SUSE Linux Extras repository during RPM resolution. +* Added support for custom registration server (like RMT/SUMA) via `sccRegistrationUrl`. ### Image Configuration Directory Changes From a07c825c1dc38fad6d5057d3fe760b47039e5c59 Mon Sep 17 00:00:00 2001 From: "Jose D. Gomez R" Date: Fri, 22 Nov 2024 22:04:54 +0100 Subject: [PATCH 7/7] Add RegUrl reference in template fields doc block in rpm-resolution.sh.tpl --- pkg/rpm/resolver/templates/rpm-resolution.sh.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl index acbfceda..26b07eb3 100644 --- a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl +++ b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl @@ -3,6 +3,7 @@ set -euo pipefail # Template Fields # RegCode - scc.suse.com registration code +# RegUrl - registration server url # AddRepo - additional third-party repositories that will be used in the resolution process # CacheDir - zypper cache directory where all rpm dependencies will be downloaded to # PKGList - list of packages for which to do the dependency resolution