Skip to content

Commit

Permalink
rpmmd: add module_hotifxes flag to RepoConfig
Browse files Browse the repository at this point in the history
Adds module_hotfixes flag to all repo types so it can be used during osbuild.
This enables users to disable modularity filtering on specific repositories.
  • Loading branch information
ezr-ondrej committed Nov 28, 2023
1 parent a39314a commit 7ad2d6a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 35 deletions.
46 changes: 24 additions & 22 deletions pkg/blueprint/repository_customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ import (
)

type RepositoryCustomization struct {
Id string `json:"id" toml:"id"`
BaseURLs []string `json:"baseurls,omitempty" toml:"baseurls,omitempty"`
GPGKeys []string `json:"gpgkeys,omitempty" toml:"gpgkeys,omitempty"`
Metalink string `json:"metalink,omitempty" toml:"metalink,omitempty"`
Mirrorlist string `json:"mirrorlist,omitempty" toml:"mirrorlist,omitempty"`
Name string `json:"name,omitempty" toml:"name,omitempty"`
Priority *int `json:"priority,omitempty" toml:"priority,omitempty"`
Enabled *bool `json:"enabled,omitempty" toml:"enabled,omitempty"`
GPGCheck *bool `json:"gpgcheck,omitempty" toml:"gpgcheck,omitempty"`
RepoGPGCheck *bool `json:"repo_gpgcheck,omitempty" toml:"repo_gpgcheck,omitempty"`
SSLVerify *bool `json:"sslverify,omitempty" toml:"sslverify,omitempty"`
Filename string `json:"filename,omitempty" toml:"filename,omitempty"`
Id string `json:"id" toml:"id"`
BaseURLs []string `json:"baseurls,omitempty" toml:"baseurls,omitempty"`
GPGKeys []string `json:"gpgkeys,omitempty" toml:"gpgkeys,omitempty"`
Metalink string `json:"metalink,omitempty" toml:"metalink,omitempty"`
Mirrorlist string `json:"mirrorlist,omitempty" toml:"mirrorlist,omitempty"`
Name string `json:"name,omitempty" toml:"name,omitempty"`
Priority *int `json:"priority,omitempty" toml:"priority,omitempty"`
Enabled *bool `json:"enabled,omitempty" toml:"enabled,omitempty"`
GPGCheck *bool `json:"gpgcheck,omitempty" toml:"gpgcheck,omitempty"`
RepoGPGCheck *bool `json:"repo_gpgcheck,omitempty" toml:"repo_gpgcheck,omitempty"`
SSLVerify *bool `json:"sslverify,omitempty" toml:"sslverify,omitempty"`
ModuleHotfixes *bool `json:"module_hotfixes,omitempty" toml:"module_hotfixes,omitempty"`
Filename string `json:"filename,omitempty" toml:"filename,omitempty"`
}

const repoFilenameRegex = "^[\\w.-]{1,250}\\.repo$"
Expand Down Expand Up @@ -117,16 +118,17 @@ func (repo RepositoryCustomization) customRepoToRepoConfig() rpmmd.RepoConfig {
copy(keys, repo.GPGKeys)

repoConfig := rpmmd.RepoConfig{
Id: repo.Id,
BaseURLs: urls,
GPGKeys: keys,
Name: repo.Name,
Metalink: repo.Metalink,
MirrorList: repo.Mirrorlist,
CheckGPG: repo.GPGCheck,
CheckRepoGPG: repo.RepoGPGCheck,
Priority: repo.Priority,
Enabled: repo.Enabled,
Id: repo.Id,
BaseURLs: urls,
GPGKeys: keys,
Name: repo.Name,
Metalink: repo.Metalink,
MirrorList: repo.Mirrorlist,
CheckGPG: repo.GPGCheck,
CheckRepoGPG: repo.RepoGPGCheck,
Priority: repo.Priority,
ModuleHotfixes: repo.ModuleHotfixes,
Enabled: repo.Enabled,
}

if repo.SSLVerify != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/dnfjson/dnfjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ func (s *Solver) reposFromRPMMD(rpmRepos []rpmmd.RepoConfig) ([]repoConfig, erro
MetadataExpire: rr.MetadataExpire,
repoHash: rr.Hash(),
}

if rr.CheckGPG != nil {
dr.CheckGPG = *rr.CheckGPG
}
Expand All @@ -294,6 +293,10 @@ func (s *Solver) reposFromRPMMD(rpmRepos []rpmmd.RepoConfig) ([]repoConfig, erro
dr.SSLClientKey = secrets.SSLClientKey
dr.SSLClientCert = secrets.SSLClientCert
}

if rr.ModuleHotfixes != nil {
dr.ModuleHotfixes = *rr.ModuleHotfixes
}
dnfRepos[idx] = dr
}
return dnfRepos, nil
Expand All @@ -315,6 +318,7 @@ type repoConfig struct {
SSLClientKey string `json:"sslclientkey,omitempty"`
SSLClientCert string `json:"sslclientcert,omitempty"`
MetadataExpire string `json:"metadata_expire,omitempty"`
ModuleHotfixes bool `json:"module_hotfixes"`
// set the repo hass from `rpmmd.RepoConfig.Hash()` function
// rather than re-calculating it
repoHash string
Expand Down
23 changes: 12 additions & 11 deletions pkg/osbuild/yum_repos_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,18 @@ func repoConfigToYumRepository(repo rpmmd.RepoConfig) YumRepository {
}

yumRepo := YumRepository{
Id: repo.Id,
Name: repo.Name,
Mirrorlist: repo.MirrorList,
Metalink: repo.Metalink,
BaseURLs: urls,
GPGKey: keys,
GPGCheck: repo.CheckGPG,
RepoGPGCheck: repo.CheckRepoGPG,
Enabled: repo.Enabled,
Priority: repo.Priority,
SSLVerify: sslVerify,
Id: repo.Id,
Name: repo.Name,
Mirrorlist: repo.MirrorList,
Metalink: repo.Metalink,
BaseURLs: urls,
GPGKey: keys,
GPGCheck: repo.CheckGPG,
RepoGPGCheck: repo.CheckRepoGPG,
Enabled: repo.Enabled,
Priority: repo.Priority,
SSLVerify: sslVerify,
ModuleHotfixes: repo.ModuleHotfixes,
}

return yumRepo
Expand Down
13 changes: 12 additions & 1 deletion pkg/rpmmd/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type repository struct {
CheckGPG bool `json:"check_gpg,omitempty"`
IgnoreSSL bool `json:"ignore_ssl,omitempty"`
RHSM bool `json:"rhsm,omitempty"`
ModuleHotfixes bool `json:"module_hotfixes,omitempty"`
MetadataExpire string `json:"metadata_expire,omitempty"`
ImageTypeTags []string `json:"image_type_tags,omitempty"`
}
Expand All @@ -42,6 +43,7 @@ type RepoConfig struct {
Priority *int `json:"priority,omitempty"`
IgnoreSSL *bool `json:"ignore_ssl,omitempty"`
MetadataExpire string `json:"metadata_expire,omitempty"`
ModuleHotfixes *bool `json:"module_hotfixes,omitempty"`
RHSM bool `json:"rhsm,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
ImageTypeTags []string `json:"image_type_tags,omitempty"`
Expand All @@ -56,6 +58,9 @@ func (r *RepoConfig) Hash() string {
return fmt.Sprintf("%T", b)
}
bpts := func(b *bool) string {
if b == nil {
return ""
}
return fmt.Sprintf("%T", b)
}
ats := func(s []string) string {
Expand All @@ -69,7 +74,8 @@ func (r *RepoConfig) Hash() string {
bpts(r.CheckRepoGPG)+
bpts(r.IgnoreSSL)+
r.MetadataExpire+
bts(r.RHSM))))
bts(r.RHSM)+
bpts(r.ModuleHotfixes))))
}

type DistrosRepoConfigs map[string]map[string][]RepoConfig
Expand Down Expand Up @@ -255,6 +261,10 @@ func loadRepositoriesFromFile(filename string) (map[string][]RepoConfig, error)
if repo.GPGKey != "" {
keys = []string{repo.GPGKey}
}
var modHotfixes *bool
if repo.ModuleHotfixes {
modHotfixes = &repo.ModuleHotfixes
}
config := RepoConfig{
Name: repo.Name,
BaseURLs: urls,
Expand All @@ -264,6 +274,7 @@ func loadRepositoriesFromFile(filename string) (map[string][]RepoConfig, error)
CheckGPG: &repo.CheckGPG,
RHSM: repo.RHSM,
MetadataExpire: repo.MetadataExpire,
ModuleHotfixes: modHotfixes,
ImageTypeTags: repo.ImageTypeTags,
}

Expand Down

0 comments on commit 7ad2d6a

Please sign in to comment.