Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support arbitrary registration URL #610

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions docs/building-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
Comment on lines +204 to +207
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must confess I'm not super inspired on this writing part, I'm very open to suggestions 😅


## Kubernetes

Expand Down
1 change: 1 addition & 0 deletions pkg/image/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/image/definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/image/testdata/full-valid-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions pkg/image/validation/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package validation

import (
"fmt"
"net/url"
"slices"
"strings"

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/rpm/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpm/resolver/templates/rpm-resolution.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down