Skip to content

Commit

Permalink
cloudapi: Add module_hotfixes flag
Browse files Browse the repository at this point in the history
Allow passing module_hotfixes flag through the cloudapi.
This will enable depsolving on repositories that might be affected by modularity filtering.

Refs HMS-3202
  • Loading branch information
ezr-ondrej committed Dec 1, 2023
1 parent 6cfa263 commit 7bbe655
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 160 deletions.
25 changes: 13 additions & 12 deletions internal/blueprint/repository_customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,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
4 changes: 4 additions & 0 deletions internal/cloudapi/v2/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ func (request *ComposeRequest) GetBlueprintWithCustomizations() (blueprint.Bluep
repoCustomization.Priority = repo.Priority
}

if repo.ModuleHotfixes != nil && *repo.ModuleHotfixes {
repoCustomization.ModuleHotfixes = repo.ModuleHotfixes
}

repoCustomizations = append(repoCustomizations, repoCustomization)
}
bp.Customizations.Repositories = repoCustomizations
Expand Down
36 changes: 20 additions & 16 deletions internal/cloudapi/v2/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ func TestGetBlueprintWithCustomizations(t *testing.T) {
Openscap: &OpenSCAP{ProfileId: "B 263-59"},
CustomRepositories: &[]CustomRepository{
CustomRepository{
Id: "custom repo",
Metalink: common.ToPtr("http://example.org/metalink"),
CheckGpg: common.ToPtr(true),
Enabled: common.ToPtr(true),
Id: "custom repo",
Metalink: common.ToPtr("http://example.org/metalink"),
CheckGpg: common.ToPtr(true),
Enabled: common.ToPtr(true),
ModuleHotfixes: common.ToPtr(true),
},
},
Firewall: &FirewallCustomization{
Expand Down Expand Up @@ -192,10 +193,11 @@ func TestGetBlueprintWithCustomizations(t *testing.T) {
},
Repositories: []blueprint.RepositoryCustomization{
blueprint.RepositoryCustomization{
Id: "custom repo",
Metalink: "http://example.org/metalink",
Enabled: common.ToPtr(true),
GPGCheck: common.ToPtr(true),
Id: "custom repo",
Metalink: "http://example.org/metalink",
Enabled: common.ToPtr(true),
GPGCheck: common.ToPtr(true),
ModuleHotfixes: common.ToPtr(true),
},
},
Firewall: &blueprint.FirewallCustomization{
Expand Down Expand Up @@ -257,20 +259,22 @@ func TestGetPayloadRepositories(t *testing.T) {
cr = ComposeRequest{Customizations: &Customizations{
PayloadRepositories: &[]Repository{
Repository{
Baseurl: common.ToPtr("http://example.org/pub/linux/repo"),
CheckGpg: common.ToPtr(true),
PackageSets: &[]string{"build", "archive"},
Rhsm: common.ToPtr(false),
Baseurl: common.ToPtr("http://example.org/pub/linux/repo"),
CheckGpg: common.ToPtr(true),
PackageSets: &[]string{"build", "archive"},
Rhsm: common.ToPtr(false),
ModuleHotfixes: common.ToPtr(true),
},
},
}}

expected := []Repository{
Repository{
Baseurl: common.ToPtr("http://example.org/pub/linux/repo"),
CheckGpg: common.ToPtr(true),
PackageSets: &[]string{"build", "archive"},
Rhsm: common.ToPtr(false),
Baseurl: common.ToPtr("http://example.org/pub/linux/repo"),
CheckGpg: common.ToPtr(true),
PackageSets: &[]string{"build", "archive"},
Rhsm: common.ToPtr(false),
ModuleHotfixes: common.ToPtr(true),
},
}
repos = cr.GetPayloadRepositories()
Expand Down
3 changes: 3 additions & 0 deletions internal/cloudapi/v2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,9 @@ func genRepoConfig(repo Repository) (*rpmmd.RepoConfig, error) {
if repo.CheckRepoGpg != nil {
repoConfig.CheckRepoGPG = repo.CheckRepoGpg
}
if repo.ModuleHotfixes != nil && *repo.ModuleHotfixes {
repoConfig.ModuleHotfixes = repo.ModuleHotfixes
}

if repoConfig.CheckGPG != nil && *repoConfig.CheckGPG && len(repoConfig.GPGKeys) == 0 {
return nil, HTTPError(ErrorNoGPGKey)
Expand Down
Loading

0 comments on commit 7bbe655

Please sign in to comment.