internal/rpmmd: change ignoressl to pointer
Change the `IgnoreSSL` field in `rpmmd.RepoConfig` to a pointer. This will be later used to configure the `SSLVerify` field in the yum repo stage.
This commit is contained in:
parent
173de3eba4
commit
ce299dfa0e
13 changed files with 89 additions and 82 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/fsnode"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
|
@ -21,7 +22,7 @@ type RepositoryCustomization struct {
|
|||
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"`
|
||||
SSLVerify *bool `json:"sslverify,omitempty" toml:"sslverify,omitempty"`
|
||||
Filename string `json:"filename,omitempty" toml:"filename,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +127,10 @@ func (repo RepositoryCustomization) customRepoToRepoConfig() rpmmd.RepoConfig {
|
|||
CheckRepoGPG: repo.RepoGPGCheck,
|
||||
Priority: repo.Priority,
|
||||
Enabled: repo.Enabled,
|
||||
IgnoreSSL: !repo.SSLVerify,
|
||||
}
|
||||
|
||||
if repo.SSLVerify != nil {
|
||||
repoConfig.IgnoreSSL = common.ToPtr(!*repo.SSLVerify)
|
||||
}
|
||||
|
||||
return repoConfig
|
||||
|
|
|
|||
|
|
@ -175,14 +175,12 @@ func TestCustomRepoToRepoConfigAndGPGKeys(t *testing.T) {
|
|||
Name: "Test no gpg keys, no filenames",
|
||||
Repos: []RepositoryCustomization{
|
||||
{
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
SSLVerify: true,
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
},
|
||||
{
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
SSLVerify: true,
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
},
|
||||
},
|
||||
WantRepoConfig: map[string][]rpmmd.RepoConfig{
|
||||
|
|
@ -207,16 +205,14 @@ func TestCustomRepoToRepoConfigAndGPGKeys(t *testing.T) {
|
|||
Name: "Test no gpg keys, filenames",
|
||||
Repos: []RepositoryCustomization{
|
||||
{
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
SSLVerify: true,
|
||||
Filename: "test-1.repo",
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
Filename: "test-1.repo",
|
||||
},
|
||||
{
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
SSLVerify: true,
|
||||
Filename: "test-2.repo",
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
Filename: "test-2.repo",
|
||||
},
|
||||
},
|
||||
WantRepoConfig: map[string][]rpmmd.RepoConfig{
|
||||
|
|
@ -241,18 +237,16 @@ func TestCustomRepoToRepoConfigAndGPGKeys(t *testing.T) {
|
|||
Name: "Test remote gpgkeys",
|
||||
Repos: []RepositoryCustomization{
|
||||
{
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
GPGKeys: []string{"http://example-1.com/gpgkey"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
SSLVerify: true,
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
GPGKeys: []string{"http://example-1.com/gpgkey"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
},
|
||||
{
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
GPGKeys: []string{"http://example-2.com/gpgkey"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
SSLVerify: true,
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
GPGKeys: []string{"http://example-2.com/gpgkey"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
},
|
||||
},
|
||||
WantRepoConfig: map[string][]rpmmd.RepoConfig{
|
||||
|
|
@ -279,18 +273,16 @@ func TestCustomRepoToRepoConfigAndGPGKeys(t *testing.T) {
|
|||
Name: "Test inline gpgkeys",
|
||||
Repos: []RepositoryCustomization{
|
||||
{
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
GPGKeys: []string{"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-1-----END PGP PUBLIC KEY BLOCK-----\n"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
SSLVerify: true,
|
||||
Id: "example-1",
|
||||
BaseURLs: []string{"http://example-1.com"},
|
||||
GPGKeys: []string{"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-1-----END PGP PUBLIC KEY BLOCK-----\n"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
},
|
||||
{
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
GPGKeys: []string{"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-2-----END PGP PUBLIC KEY BLOCK-----\n"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
SSLVerify: true,
|
||||
Id: "example-2",
|
||||
BaseURLs: []string{"http://example-2.com"},
|
||||
GPGKeys: []string{"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-2-----END PGP PUBLIC KEY BLOCK-----\n"},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
},
|
||||
},
|
||||
WantRepoConfig: map[string][]rpmmd.RepoConfig{
|
||||
|
|
@ -326,8 +318,7 @@ func TestCustomRepoToRepoConfigAndGPGKeys(t *testing.T) {
|
|||
"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-1-----END PGP PUBLIC KEY BLOCK-----\n",
|
||||
"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-2-----END PGP PUBLIC KEY BLOCK-----\n",
|
||||
},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
SSLVerify: true,
|
||||
GPGCheck: common.ToPtr(true),
|
||||
},
|
||||
{
|
||||
Id: "example-2",
|
||||
|
|
@ -336,8 +327,7 @@ func TestCustomRepoToRepoConfigAndGPGKeys(t *testing.T) {
|
|||
"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-1-----END PGP PUBLIC KEY BLOCK-----\n",
|
||||
"-----BEGIN PGP PUBLIC KEY BLOCK-----fake-gpg-key-2-----END PGP PUBLIC KEY BLOCK-----\n",
|
||||
},
|
||||
GPGCheck: common.ToPtr(true),
|
||||
SSLVerify: true,
|
||||
GPGCheck: common.ToPtr(true),
|
||||
},
|
||||
},
|
||||
WantRepoConfig: map[string][]rpmmd.RepoConfig{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue