Skip to content

Commit

Permalink
feat: WIP: add maas plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arturshadnik committed Aug 12, 2024
1 parent 065cbc2 commit 042f0c6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/validator-labs/validator v0.1.3-0.20240809205255-c05a36eebd3c
github.com/validator-labs/validator-plugin-aws v0.1.4-0.20240809205833-8085473f77df
github.com/validator-labs/validator-plugin-azure v0.0.16-0.20240809210033-fab1ab878d10
github.com/validator-labs/validator-plugin-maas v0.0.8-0.20240807214621-951e09472a70
github.com/validator-labs/validator-plugin-maas v0.0.8-0.20240809210245-5894f5118612
github.com/validator-labs/validator-plugin-network v0.0.23-0.20240809205936-18ffc3b792c4
github.com/validator-labs/validator-plugin-oci v0.1.1-0.20240809205756-c1942b7a7104
github.com/validator-labs/validator-plugin-vsphere v0.0.30-0.20240809210242-a318dfc2be38
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ github.com/validator-labs/validator-plugin-aws v0.1.4-0.20240809205833-8085473f7
github.com/validator-labs/validator-plugin-aws v0.1.4-0.20240809205833-8085473f77df/go.mod h1:NAPw04DYgOQUKN7GmGy65gETac19lDAjCAPtE4nLe5Q=
github.com/validator-labs/validator-plugin-azure v0.0.16-0.20240809210033-fab1ab878d10 h1:BFlJUBviwxKnrgYnemEqW643Ohj32XvDr6VNbQYzmOI=
github.com/validator-labs/validator-plugin-azure v0.0.16-0.20240809210033-fab1ab878d10/go.mod h1:Lg4K6Uc7BkNi3KIr0gEPYDcwfjmFNI0uYHm4tbVyswo=
github.com/validator-labs/validator-plugin-maas v0.0.8-0.20240807214621-951e09472a70 h1:mw98qwizN2s2y9q/L4yLK8osmFc52bVHmLkDoymFKtY=
github.com/validator-labs/validator-plugin-maas v0.0.8-0.20240807214621-951e09472a70/go.mod h1:JyQk0ehRB+zNnhyYRpzk5ZekZZReFOfeJ7L6z0kln64=
github.com/validator-labs/validator-plugin-maas v0.0.8-0.20240809210245-5894f5118612 h1:dM8Ot/EX0/tNvGfOtK8OMPwpYfXltxWJeN7yO49SzwY=
github.com/validator-labs/validator-plugin-maas v0.0.8-0.20240809210245-5894f5118612/go.mod h1:sla9fLOH2YRzKYfzqCf4ljA7LtiPT+DxuI8R/X0GZh8=
github.com/validator-labs/validator-plugin-network v0.0.23-0.20240809205936-18ffc3b792c4 h1:iHmrJU1FBgfBzMuQ1tcYZiy2nZ5Qwmvu6GZ787b5odo=
github.com/validator-labs/validator-plugin-network v0.0.23-0.20240809205936-18ffc3b792c4/go.mod h1:zA+EcB7wV2qj67SiFpzpTq1Bv08BIqJWU/+XrbeBRZM=
github.com/validator-labs/validator-plugin-oci v0.1.1-0.20240809205756-c1942b7a7104 h1:5A/j5XFU720xFvmuqunGM4Rz1NB1KIWVodQqhleP4Jk=
Expand Down
7 changes: 4 additions & 3 deletions hack/validator.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,8 @@ maasPlugin:
- name: Image Rule
images:
- name: example
architecture: amd64/ga-20.04
resourceAvailabilityRules:
architecture: amd64/ga-20.04
resourceAvailabilityRules:
- name: AZ1
az: az1
resources:
Expand All @@ -861,4 +861,5 @@ maasPlugin:
host: "http://example.com/MAAS"
auth:
secretName: maas-creds
tokenKey: MAAS_API_KEY
tokenKey: MAAS_API_KEY
maasApiToken: "ZmFrZTptYWFzYXBpOnRva2Vu"
6 changes: 3 additions & 3 deletions pkg/config/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package config

// ValidatorChartVersions is a map of validator component names to their respective versions
var ValidatorChartVersions = map[string]string{
Validator: "v0.1.2",
Validator: "v0.1.3",
ValidatorPluginAws: "v0.1.3",
ValidatorPluginAzure: "v0.0.15",
ValidatorPluginMaas: "v0.0.7",
ValidatorPluginMaas: "v0.0.7",
ValidatorPluginNetwork: "v0.0.22",
ValidatorPluginOci: "v0.1.0",
ValidatorPluginOci: "v0.2.0",
ValidatorPluginVsphere: "v0.0.29",
}
3 changes: 3 additions & 0 deletions pkg/services/validator/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func configureIamRoleRules(c *components.AWSPluginConfig, ruleNames *[]string) e
return nil
}

// nolint:dupl
func readIamRoleRule(c *components.AWSPluginConfig, r *vpawsapi.IamRoleRule, idx int, ruleNames *[]string) error {
if r == nil {
r = &vpawsapi.IamRoleRule{
Expand Down Expand Up @@ -225,6 +226,7 @@ func configureIamUserRules(c *components.AWSPluginConfig, ruleNames *[]string) e
return nil
}

// nolint:dupl
func readIamUserRule(c *components.AWSPluginConfig, r *vpawsapi.IamUserRule, idx int, ruleNames *[]string) error {
if r == nil {
r = &vpawsapi.IamUserRule{
Expand Down Expand Up @@ -313,6 +315,7 @@ func configureIamGroupRules(c *components.AWSPluginConfig, ruleNames *[]string)
return nil
}

// nolint:dupl
func readIamGroupRule(c *components.AWSPluginConfig, r *vpawsapi.IamGroupRule, idx int, ruleNames *[]string) error {
if r == nil {
r = &vpawsapi.IamGroupRule{
Expand Down
1 change: 0 additions & 1 deletion pkg/services/validator/maas.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func readMaasPlugin(vc *components.ValidatorConfig, tc *cfg.TaskConfig, k8sClien
if err := readMaasCredentials(c, tc, k8sClient); err != nil {
return fmt.Errorf("failed to read MAAS credentials: %w", err)
}

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/utils/embed/resources/validator/validator-base-values.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,13 @@ pluginSecrets:
{{- else }}
vSphere: {}
{{- end }}

{{- if .MAASPlugin.Validator.Auth.SecretName }}
maas:
secretName: {{ .MAASPlugin.Validator.Auth.SecretName }}
tokenKey: {{ .MAASPlugin.Validator.Auth.TokenKey }}
maasApiToken: {{ .MAASPlugin.MaasAPIToken }}
{{- else }}
maas: {}
{{- end }}

46 changes: 24 additions & 22 deletions tests/integration/_validator/testcases/test_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ func (t *ValidatorTest) Execute(ctx *test.TestContext) (tr *test.TestResult) {
if result := t.testInstallSilent(); result.IsFailed() {
return result
}
if result := t.testInstallSilentWait(); result.IsFailed() {
return result
}
if result := t.testCheckDirect(); result.IsFailed() {
return result
}
if result := t.testDescribe(); result.IsFailed() {
return result
}
if result := t.testUndeploy(); result.IsFailed() {
return result
}
if result := t.testInstallUpdatePasswords(); result.IsFailed() {
return result
}
// if result := t.testInstallSilentWait(); result.IsFailed() {
// return result
// }
// if result := t.testCheckDirect(); result.IsFailed() {
// return result
// }
// if result := t.testDescribe(); result.IsFailed() {
// return result
// }
// if result := t.testUndeploy(); result.IsFailed() {
// return result
// }
// if result := t.testInstallUpdatePasswords(); result.IsFailed() {
// return result
// }
return test.Success()
}

Expand Down Expand Up @@ -492,14 +492,16 @@ func (t *ValidatorTest) vspherePluginValues(ctx *test.TestContext, vals []string

func (t *ValidatorTest) maasPluginInstallValues(ctx *test.TestContext, vals []string) []string {
maasVals := []string{
"y", // install MAAS plugin
"maas-creds", // MAAS credentials secret name
"MAAS_API_KEY", // MAAS API token key
"fake:maas:token", // MAAS API token
"y", // install MAAS plugin
"maas-creds", // MAAS credentials secret name
"MAAS_API_KEY", // MAAS API token key
"fake:maasapi:token", // MAAS API token
}

if string_utils.IsDevVersion(ctx.Get("version")) {
maasVals = slices.Insert(maasVals, 1, cfg.ValidatorChartVersions[cfg.ValidatorPluginMaas])
maasVals = slices.Insert(maasVals, 1,
cfg.ValidatorChartVersions[cfg.ValidatorPluginMaas],
)
}

vals = append(vals, maasVals...)
Expand Down Expand Up @@ -528,7 +530,7 @@ func (t *ValidatorTest) maasPluginValues(ctx *test.TestContext, vals []string, s
"n", // Add another image
"n", // Add another image rule
"y", // Enable internal DNS validation
"maas.io", //MAAS Domain
"maas.io", // MAAS Domain
"subdomain.maas.io", // FQDN
"10.10.10.10", // IP
"A", // Record type
Expand Down Expand Up @@ -663,7 +665,7 @@ func (t *ValidatorTest) testInstallUpdatePasswords() (tr *test.TestResult) {
// MAAS validator
"maas-creds", // MAAS credentials secret name
"MAAS_API_KEY", // MAAS API token key
"fake:maas:token123", // MAAS API token
"fake:maasapi:token", // MAAS API token

// OCI validator
"y", // Add basic auth credentials
Expand Down

0 comments on commit 042f0c6

Please sign in to comment.