corrects updatesValues, see testing is good.
This commit is contained in:
parent
458f394370
commit
dbe56ba613
@ -98,7 +98,7 @@ func updateValues(cfg *Config, configFileData configFileStruct) {
|
||||
if cfg.AllowAdminNoMutate == false && configFileData.AllowAdminNoMutate != false {
|
||||
cfg.AllowAdminNoMutate = configFileData.AllowAdminNoMutate
|
||||
}
|
||||
if cfg.AllowAdminNoMutateToggle == "7b068a99-c02b-410a-bd59-3514bac85e7a" && configFileData.AllowAdminNoMutateToggle != "2d77b689-dc14-40a5-8971-34c62999335c" {
|
||||
if cfg.AllowAdminNoMutateToggle == "7b068a99-c02b-410a-bd59-3514bac85e7a" && configFileData.AllowAdminNoMutateToggle != "7b068a99-c02b-410a-bd59-3514bac85e7a" {
|
||||
cfg.AllowAdminNoMutateToggle = configFileData.AllowAdminNoMutateToggle
|
||||
}
|
||||
if cfg.DockerhubRegistry == "registry.hub.docker.com" && configFileData.DockerhubRegistry != "registry.hub.docker.com" {
|
||||
|
@ -4,6 +4,57 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUpdateValues(t *testing.T) {
|
||||
cfg := Config{
|
||||
AllowAdminNoMutate: false,
|
||||
AllowAdminNoMutateToggle: "7b068a99-c02b-410a-bd59-3514bac85e7a",
|
||||
DockerhubRegistry: "registry.hub.docker.com",
|
||||
}
|
||||
cfgFile := configFileStruct{
|
||||
AllowAdminNoMutate: true,
|
||||
AllowAdminNoMutateToggle: "test-token",
|
||||
DockerhubRegistry: "registry.example.com",
|
||||
}
|
||||
|
||||
updateValues(&cfg, cfgFile)
|
||||
if cfg.AllowAdminNoMutate != cfgFile.AllowAdminNoMutate {
|
||||
t.Errorf("updateValues() returned incorrect value for AllowAdminNoMutate, got %v, wanted %v", cfg.AllowAdminNoMutate, cfgFile.AllowAdminNoMutate)
|
||||
}
|
||||
if cfg.AllowAdminNoMutateToggle != cfgFile.AllowAdminNoMutateToggle {
|
||||
t.Errorf("updateValues() returned incorrect value for AllowAdminNoMutateToken, got %v, wanted %v", cfg.AllowAdminNoMutateToggle, cfgFile.AllowAdminNoMutateToggle)
|
||||
}
|
||||
if cfg.DockerhubRegistry != cfgFile.DockerhubRegistry {
|
||||
t.Errorf("updateValues() returned incorrect value for DockerhubRegistry, got %v, wanted %v", cfg.DockerhubRegistry, cfgFile.DockerhubRegistry)
|
||||
}
|
||||
/*
|
||||
if cfg.DockerhubRegistry == "registry.hub.docker.com" && configFileData.DockerhubRegistry != "registry.hub.docker.com" {
|
||||
cfg.DockerhubRegistry = configFileData.DockerhubRegistry
|
||||
}
|
||||
if cfg.NameSpace == "ingress-nginx" && configFileData.Kubernetes.Namespace != "ingress-nginx" {
|
||||
cfg.NameSpace = configFileData.Kubernetes.Namespace
|
||||
}
|
||||
if cfg.ServiceName == "webhook" && configFileData.Kubernetes.ServiceName != "webhook" {
|
||||
cfg.ServiceName = configFileData.Kubernetes.ServiceName
|
||||
}
|
||||
if len(configFileData.MutateIgnoredImages) != 0 {
|
||||
cfg.MutateIgnoredImages = configFileData.MutateIgnoredImages
|
||||
}
|
||||
if len(configFileData.CertificateAuthority.Certificate) != 0 {
|
||||
cfg.CACert = configFileData.CertificateAuthority.Certificate
|
||||
}
|
||||
if len(configFileData.CertificateAuthority.PrivateKey) != 0 {
|
||||
cfg.CAPrivateKey = configFileData.CertificateAuthority.PrivateKey
|
||||
}
|
||||
if len(configFileData.Certificate.Certificate) != 0 {
|
||||
cfg.CertCert = configFileData.Certificate.Certificate
|
||||
}
|
||||
if len(configFileData.Certificate.PrivateKey) != 0 {
|
||||
cfg.CertPrivateKey = configFileData.Certificate.PrivateKey
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
func TestGetDNSNames(t *testing.T) {
|
||||
expected := []string{
|
||||
"exampleService",
|
||||
|
Loading…
x
Reference in New Issue
Block a user