Skip to content

Commit

Permalink
fix: ensure passwords in helm templates are quoted (#96)
Browse files Browse the repository at this point in the history
## Description
This is to address issues like the one below when converting yaml to
json:
```
failed to install validator: failed to install validator helm chart: error executing helm upgrade: Release "validator" does not exist. Installing it now.
Error: failed to parse /var/folders/h_/0543c2rd71z0gvw2xbqxcjsr0000gn/T/3171513764: error converting YAML to JSON: yaml: line 69: did not find expected comment or line break
```

The other changes made in the components package to the
`ConfigureXXXPlugin` functions ensure they each setup their structs
correctly to avoid nil pointer dereferences
  • Loading branch information
ahmad-ibra authored Jul 24, 2024
1 parent 2a01e95 commit f36383b
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/spectrocloud-labs/prompts-tui v0.0.0-20240715203051-ec46421ba5c0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/validator-labs/validator v0.0.48
github.com/validator-labs/validator v0.0.49
github.com/validator-labs/validator-plugin-aws v0.1.1
github.com/validator-labs/validator-plugin-azure v0.0.13
github.com/validator-labs/validator-plugin-network v0.0.19
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/transparency-dev/merkle v0.0.2 h1:Q9nBoQcZcgPamMkGn7ghV8XiTZ/kRxn1yCG81+twTK4=
github.com/transparency-dev/merkle v0.0.2/go.mod h1:pqSy+OXefQ1EDUVmAJ8MUhHB9TXGuzVAT58PqBoHz1A=
github.com/validator-labs/validator v0.0.48 h1:Vngvw9Y0B3B5ea8LqHgxBKw8dOS8ZK8z2zyzMq2rs/8=
github.com/validator-labs/validator v0.0.48/go.mod h1:YxUKAXuSR6fIAi7WCQV/Wbrzf9szf8aCTeYWEA+JyIY=
github.com/validator-labs/validator v0.0.49 h1:gqtiVFBdLHNJysGx7MDx09uYJ7aLZ5x0bHgFmN9bVhM=
github.com/validator-labs/validator v0.0.49/go.mod h1:YxUKAXuSR6fIAi7WCQV/Wbrzf9szf8aCTeYWEA+JyIY=
github.com/validator-labs/validator-plugin-aws v0.1.1 h1:GPWSk1hSRBV+NgOBKKn0q6f2iH3+ZikHYuSD6S41Ybk=
github.com/validator-labs/validator-plugin-aws v0.1.1/go.mod h1:GGFVx01t77XomgrPZFmF5Dkre+iqmtBOBjThuWgB/jI=
github.com/validator-labs/validator-plugin-azure v0.0.13 h1:0aWcNuOs9XHQg6TFyW+TM69A3FxUOzG/E5uQF1fn+Og=
Expand Down
3 changes: 2 additions & 1 deletion pkg/components/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func ConfigureNetworkPlugin(vc *ValidatorConfig, config NetworkConfig) {
},
},
ReleaseSecret: &Secret{
Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginNetwork),
Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginNetwork),
BasicAuth: &BasicAuth{},
},
Validator: &network_api.NetworkValidatorSpec{
IPRangeRules: config.IPRangeRules,
Expand Down
3 changes: 2 additions & 1 deletion pkg/components/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func ConfigureOciPlugin(vc *ValidatorConfig, config OciConfig) {
},
},
ReleaseSecret: &Secret{
Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginOci),
Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginOci),
BasicAuth: &BasicAuth{},
},
Validator: &oci_api.OciValidatorSpec{
OciRegistryRules: generateOciRegistryRules(config.HostRefs),
Expand Down
2 changes: 2 additions & 0 deletions pkg/components/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,12 @@ func ConfigureBaseValidator(vc *ValidatorConfig, kubeconfig string) {
}
vc.KindConfig.UseKindCluster = true
vc.Kubeconfig = kubeconfig
// TODO: update this to use the correct image registry (custom private registry / hauler / default)
vc.ImageRegistry = cfg.ValidatorImagePath()
vc.ProxyConfig = &ProxyConfig{
Env: &Env{
PodCIDR: &cfg.DefaultPodCIDR,
ProxyCACert: &CACert{},
ServiceIPRange: &cfg.DefaultServiceIPRange,
},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/components/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func ConfigureVspherePlugin(vc *ValidatorConfig, config VsphereConfig) {
},
},
ReleaseSecret: &Secret{
Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginVsphere),
Name: fmt.Sprintf("validator-helm-release-%s", cfg.ValidatorPluginVsphere),
BasicAuth: &BasicAuth{},
},
Account: &vsphere.CloudAccount{
Insecure: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

// ValidatorChartVersions is a map of validator component names to their respective versions
var ValidatorChartVersions = map[string]string{
Validator: "v0.0.48",
Validator: "v0.0.49",
ValidatorPluginAws: "v0.1.1",
ValidatorPluginAzure: "v0.0.13",
ValidatorPluginNetwork: "v0.0.19",
Expand Down
12 changes: 6 additions & 6 deletions pkg/utils/embed/resources/validator/validator-base-values.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ pluginSecrets:
{{- if .VspherePlugin.Validator.Auth.SecretName }}
vSphere:
secretName: {{ .VspherePlugin.Validator.Auth.SecretName }}
username: {{ .VspherePlugin.Account.Username }}
password: {{ .VspherePlugin.Account.Password }}
vcenterServer: {{ .VspherePlugin.Account.VcenterServer }}
insecureSkipVerify: {{ .VspherePlugin.Account.Insecure }}
username: {{ .VspherePlugin.Account.Username | quote }}
password: {{ .VspherePlugin.Account.Password | quote }}
vcenterServer: {{ .VspherePlugin.Account.VcenterServer | quote }}
insecureSkipVerify: {{ .VspherePlugin.Account.Insecure | quote }}
{{- else }}
vSphere: {}
{{- end }}
Expand All @@ -142,8 +142,8 @@ pluginSecrets:
- secretName: {{ .Name }}
env:
{{- if .BasicAuth }}
username: {{ .BasicAuth.Username }}
password: {{ .BasicAuth.Password }}
username: {{ .BasicAuth.Username | quote }}
password: {{ .BasicAuth.Password | quote }}
{{- end }}
{{- range $k, $v := .Data }}
{{ $k }}: {{ $v }}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/_validator/testcases/data/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ helmRelease:
chart:
name: validator
repository: https://validator-labs.github.io/validator
version: v0.0.48
version: v0.0.49
insecureSkipVerify: true
values: ""
helmReleaseSecret:
Expand Down

0 comments on commit f36383b

Please sign in to comment.