internal/rpmmd: add missing fields to RepoConfig
Further align the RepoConfig object to the dnf spec and add missing fields.
This commit is contained in:
parent
d44703cdc8
commit
3b6fddb14a
4 changed files with 41 additions and 15 deletions
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||||
"github.com/osbuild/osbuild-composer/internal/common"
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/container"
|
"github.com/osbuild/osbuild-composer/internal/container"
|
||||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||||
|
|
@ -39,11 +38,14 @@ func (mv *multiValue) Set(v string) error {
|
||||||
|
|
||||||
type repository struct {
|
type repository struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Id string `json:"id,omitempty"`
|
||||||
BaseURL string `json:"baseurl,omitempty"`
|
BaseURL string `json:"baseurl,omitempty"`
|
||||||
Metalink string `json:"metalink,omitempty"`
|
Metalink string `json:"metalink,omitempty"`
|
||||||
MirrorList string `json:"mirrorlist,omitempty"`
|
MirrorList string `json:"mirrorlist,omitempty"`
|
||||||
GPGKey string `json:"gpgkey,omitempty"`
|
GPGKey string `json:"gpgkey,omitempty"`
|
||||||
CheckGPG bool `json:"check_gpg,omitempty"`
|
CheckGPG bool `json:"check_gpg,omitempty"`
|
||||||
|
CheckRepoGPG bool `json:"check_repo_gpg,omitempty"`
|
||||||
|
IgnoreSSL bool `json:"ignore_ssl,omitempty"`
|
||||||
RHSM bool `json:"rhsm,omitempty"`
|
RHSM bool `json:"rhsm,omitempty"`
|
||||||
MetadataExpire string `json:"metadata_expire,omitempty"`
|
MetadataExpire string `json:"metadata_expire,omitempty"`
|
||||||
ImageTypeTags []string `json:"image_type_tags,omitempty"`
|
ImageTypeTags []string `json:"image_type_tags,omitempty"`
|
||||||
|
|
@ -199,14 +201,15 @@ func convertRepo(r repository) rpmmd.RepoConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpmmd.RepoConfig{
|
return rpmmd.RepoConfig{
|
||||||
|
Id: r.Id,
|
||||||
Name: r.Name,
|
Name: r.Name,
|
||||||
BaseURLs: urls,
|
BaseURLs: urls,
|
||||||
Metalink: r.Metalink,
|
Metalink: r.Metalink,
|
||||||
MirrorList: r.MirrorList,
|
MirrorList: r.MirrorList,
|
||||||
GPGKeys: keys,
|
GPGKeys: keys,
|
||||||
CheckGPG: &r.CheckGPG,
|
CheckGPG: &r.CheckGPG,
|
||||||
CheckRepoGPG: common.ToPtr(false),
|
CheckRepoGPG: &r.CheckRepoGPG,
|
||||||
IgnoreSSL: false,
|
IgnoreSSL: r.IgnoreSSL,
|
||||||
MetadataExpire: r.MetadataExpire,
|
MetadataExpire: r.MetadataExpire,
|
||||||
RHSM: r.RHSM,
|
RHSM: r.RHSM,
|
||||||
ImageTypeTags: r.ImageTypeTags,
|
ImageTypeTags: r.ImageTypeTags,
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type repository struct {
|
type repository struct {
|
||||||
Name string `json:"name,omitempty"`
|
Id string `json:"id,omitempty"`
|
||||||
BaseURL string `json:"baseurl,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Metalink string `json:"metalink,omitempty"`
|
BaseURL string `json:"baseurl,omitempty"`
|
||||||
MirrorList string `json:"mirrorlist,omitempty"`
|
Metalink string `json:"metalink,omitempty"`
|
||||||
GPGKey string `json:"gpgkey,omitempty"`
|
MirrorList string `json:"mirrorlist,omitempty"`
|
||||||
CheckGPG bool `json:"check_gpg,omitempty"`
|
GPGKey string `json:"gpgkey,omitempty"`
|
||||||
PackageSets []string `json:"package_sets,omitempty"`
|
CheckGPG bool `json:"check_gpg,omitempty"`
|
||||||
RHSM bool `json:"rhsm,omitempty"`
|
CheckRepoGPG bool `json:"repo_check_gpg,omitempty"`
|
||||||
|
IgnoreSSL bool `json:"ignore_ssl,omitempty"`
|
||||||
|
PackageSets []string `json:"package_sets,omitempty"`
|
||||||
|
RHSM bool `json:"rhsm,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ostreeOptions struct {
|
type ostreeOptions struct {
|
||||||
|
|
@ -141,6 +144,10 @@ func main() {
|
||||||
if repoName == "" {
|
if repoName == "" {
|
||||||
repoName = fmt.Sprintf("repo-%d", i)
|
repoName = fmt.Sprintf("repo-%d", i)
|
||||||
}
|
}
|
||||||
|
repoId := repo.Id
|
||||||
|
if repoId == "" {
|
||||||
|
repoId = fmt.Sprintf("repo-%d", i)
|
||||||
|
}
|
||||||
var urls []string
|
var urls []string
|
||||||
if repo.BaseURL != "" {
|
if repo.BaseURL != "" {
|
||||||
urls = []string{repo.BaseURL}
|
urls = []string{repo.BaseURL}
|
||||||
|
|
@ -149,7 +156,9 @@ func main() {
|
||||||
if repo.GPGKey != "" {
|
if repo.GPGKey != "" {
|
||||||
keys = []string{repo.GPGKey}
|
keys = []string{repo.GPGKey}
|
||||||
}
|
}
|
||||||
|
|
||||||
repos[i] = rpmmd.RepoConfig{
|
repos[i] = rpmmd.RepoConfig{
|
||||||
|
Id: repoId,
|
||||||
Name: repoName,
|
Name: repoName,
|
||||||
BaseURLs: urls,
|
BaseURLs: urls,
|
||||||
Metalink: repo.Metalink,
|
Metalink: repo.Metalink,
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ type repository struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RepoConfig struct {
|
type RepoConfig struct {
|
||||||
|
// the repo id is not always required and is ignored in some cases.
|
||||||
|
// For example, it is not required in dnf-json, but it is a required
|
||||||
|
// field for creating a repo file in `/etc/yum.repos.d/`
|
||||||
|
Id string `json:"id,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
BaseURLs []string `json:"baseurls,omitempty"`
|
BaseURLs []string `json:"baseurls,omitempty"`
|
||||||
Metalink string `json:"metalink,omitempty"`
|
Metalink string `json:"metalink,omitempty"`
|
||||||
|
|
@ -35,9 +39,11 @@ type RepoConfig struct {
|
||||||
GPGKeys []string `json:"gpgkeys,omitempty"`
|
GPGKeys []string `json:"gpgkeys,omitempty"`
|
||||||
CheckGPG *bool `json:"check_gpg,omitempty"`
|
CheckGPG *bool `json:"check_gpg,omitempty"`
|
||||||
CheckRepoGPG *bool `json:"check_repo_gpg,omitempty"`
|
CheckRepoGPG *bool `json:"check_repo_gpg,omitempty"`
|
||||||
|
Priority *int `json:"priority,omitempty"`
|
||||||
IgnoreSSL bool `json:"ignore_ssl,omitempty"`
|
IgnoreSSL bool `json:"ignore_ssl,omitempty"`
|
||||||
MetadataExpire string `json:"metadata_expire,omitempty"`
|
MetadataExpire string `json:"metadata_expire,omitempty"`
|
||||||
RHSM bool `json:"rhsm,omitempty"`
|
RHSM bool `json:"rhsm,omitempty"`
|
||||||
|
Enabled *bool `json:"enabled,omitempty"`
|
||||||
ImageTypeTags []string `json:"image_type_tags,omitempty"`
|
ImageTypeTags []string `json:"image_type_tags,omitempty"`
|
||||||
PackageSets []string `json:"package_sets,omitempty"`
|
PackageSets []string `json:"package_sets,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,9 @@ func TestOldWorkerRepositoryCompatUnmarshal(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
repoJSON: []byte(`{"name":"all","baseurls":["http://example.com/all"],"metalink":"http://example.com/metalink","mirrorlist":"http://example.com/mirrorlist","gpgkeys":["key1","key2"],"check_gpg":true,"check_repo_gpg":true,"ignore_ssl":true,"metadata_expire":"test","rhsm":true,"image_type_tags":["one","two"],"package_sets":["1","2"],"baseurl":"http://example.com/all"}`),
|
repoJSON: []byte(`{"id":"all","name":"all","baseurls":["http://example.com/all"],"metalink":"http://example.com/metalink","mirrorlist":"http://example.com/mirrorlist","gpgkeys":["key1","key2"],"check_gpg":true,"check_repo_gpg":true,"ignore_ssl":true,"priority":10,"metadata_expire":"test","rhsm":true,"enabled":true,"image_type_tags":["one","two"],"package_sets":["1","2"],"baseurl":"http://example.com/all"}`),
|
||||||
repo: rpmmd.RepoConfig{
|
repo: rpmmd.RepoConfig{
|
||||||
|
Id: "all",
|
||||||
Name: "all",
|
Name: "all",
|
||||||
BaseURLs: []string{"http://example.com/all"},
|
BaseURLs: []string{"http://example.com/all"},
|
||||||
Metalink: "http://example.com/metalink",
|
Metalink: "http://example.com/metalink",
|
||||||
|
|
@ -222,8 +223,10 @@ func TestOldWorkerRepositoryCompatUnmarshal(t *testing.T) {
|
||||||
CheckGPG: common.ToPtr(true),
|
CheckGPG: common.ToPtr(true),
|
||||||
CheckRepoGPG: common.ToPtr(true),
|
CheckRepoGPG: common.ToPtr(true),
|
||||||
IgnoreSSL: true,
|
IgnoreSSL: true,
|
||||||
|
Priority: common.ToPtr(10),
|
||||||
MetadataExpire: "test",
|
MetadataExpire: "test",
|
||||||
RHSM: true,
|
RHSM: true,
|
||||||
|
Enabled: common.ToPtr(true),
|
||||||
ImageTypeTags: []string{"one", "two"},
|
ImageTypeTags: []string{"one", "two"},
|
||||||
PackageSets: []string{"1", "2"},
|
PackageSets: []string{"1", "2"},
|
||||||
},
|
},
|
||||||
|
|
@ -246,22 +249,25 @@ func TestOldWorkerRepositoryCompatMarshal(t *testing.T) {
|
||||||
repo rpmmd.RepoConfig
|
repo rpmmd.RepoConfig
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
repoJSON: []byte(`{"name":"fedora","baseurls":["http://example.com/fedora"],"baseurl":"http://example.com/fedora"}`),
|
repoJSON: []byte(`{"id":"fedora","name":"fedora","baseurls":["http://example.com/fedora"],"baseurl":"http://example.com/fedora"}`),
|
||||||
repo: rpmmd.RepoConfig{
|
repo: rpmmd.RepoConfig{
|
||||||
|
Id: "fedora",
|
||||||
Name: "fedora",
|
Name: "fedora",
|
||||||
BaseURLs: []string{"http://example.com/fedora"},
|
BaseURLs: []string{"http://example.com/fedora"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
repoJSON: []byte(`{"name":"multiple","baseurls":["http://example.com/one","http://example.com/two"],"baseurl":"http://example.com/one,http://example.com/two"}`),
|
repoJSON: []byte(`{"id":"multiple","name":"multiple","baseurls":["http://example.com/one","http://example.com/two"],"baseurl":"http://example.com/one,http://example.com/two"}`),
|
||||||
repo: rpmmd.RepoConfig{
|
repo: rpmmd.RepoConfig{
|
||||||
|
Id: "multiple",
|
||||||
Name: "multiple",
|
Name: "multiple",
|
||||||
BaseURLs: []string{"http://example.com/one", "http://example.com/two"},
|
BaseURLs: []string{"http://example.com/one", "http://example.com/two"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
repoJSON: []byte(`{"name":"all","baseurls":["http://example.com/all"],"metalink":"http://example.com/metalink","mirrorlist":"http://example.com/mirrorlist","gpgkeys":["key1","key2"],"check_gpg":true,"check_repo_gpg":true,"ignore_ssl":true,"metadata_expire":"test","rhsm":true,"image_type_tags":["one","two"],"package_sets":["1","2"],"baseurl":"http://example.com/all"}`),
|
repoJSON: []byte(`{"id":"all","name":"all","baseurls":["http://example.com/all"],"metalink":"http://example.com/metalink","mirrorlist":"http://example.com/mirrorlist","gpgkeys":["key1","key2"],"check_gpg":true,"check_repo_gpg":true,"priority":10,"ignore_ssl":true,"metadata_expire":"test","rhsm":true,"enabled":true,"image_type_tags":["one","two"],"package_sets":["1","2"],"baseurl":"http://example.com/all"}`),
|
||||||
repo: rpmmd.RepoConfig{
|
repo: rpmmd.RepoConfig{
|
||||||
|
Id: "all",
|
||||||
Name: "all",
|
Name: "all",
|
||||||
BaseURLs: []string{"http://example.com/all"},
|
BaseURLs: []string{"http://example.com/all"},
|
||||||
Metalink: "http://example.com/metalink",
|
Metalink: "http://example.com/metalink",
|
||||||
|
|
@ -269,9 +275,11 @@ func TestOldWorkerRepositoryCompatMarshal(t *testing.T) {
|
||||||
GPGKeys: []string{"key1", "key2"},
|
GPGKeys: []string{"key1", "key2"},
|
||||||
CheckGPG: common.ToPtr(true),
|
CheckGPG: common.ToPtr(true),
|
||||||
CheckRepoGPG: common.ToPtr(true),
|
CheckRepoGPG: common.ToPtr(true),
|
||||||
|
Priority: common.ToPtr(10),
|
||||||
IgnoreSSL: true,
|
IgnoreSSL: true,
|
||||||
MetadataExpire: "test",
|
MetadataExpire: "test",
|
||||||
RHSM: true,
|
RHSM: true,
|
||||||
|
Enabled: common.ToPtr(true),
|
||||||
ImageTypeTags: []string{"one", "two"},
|
ImageTypeTags: []string{"one", "two"},
|
||||||
PackageSets: []string{"1", "2"},
|
PackageSets: []string{"1", "2"},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue