Skip to content

Commit

Permalink
Merge pull request #61 from arangodb/tls-none
Browse files Browse the repository at this point in the history
Fixed validation of tls.caSecretName=None
  • Loading branch information
ewoutp authored Mar 22, 2018
2 parents cd44faa + 18197de commit 19dd015
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/apis/deployment/v1alpha/tls_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ func (s TLSSpec) GetAltNames() (dnsNames, ipAddresses, emailAddresses []string,

// Validate the given spec
func (s TLSSpec) Validate() error {
if err := k8sutil.ValidateOptionalResourceName(s.CASecretName); err != nil {
return maskAny(err)
}
if _, _, _, err := s.GetAltNames(); err != nil {
return maskAny(err)
if s.IsSecure() {
if err := k8sutil.ValidateOptionalResourceName(s.CASecretName); err != nil {
return maskAny(err)
}
if _, _, _, err := s.GetAltNames(); err != nil {
return maskAny(err)
}
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/deployment/v1alpha/tls_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestTLSSpecValidate(t *testing.T) {
// Valid
assert.Nil(t, TLSSpec{CASecretName: ""}.Validate())
assert.Nil(t, TLSSpec{CASecretName: "foo"}.Validate())
assert.Nil(t, TLSSpec{CASecretName: "None"}.Validate())
assert.Nil(t, TLSSpec{AltNames: []string{}}.Validate())
assert.Nil(t, TLSSpec{AltNames: []string{"foo"}}.Validate())
assert.Nil(t, TLSSpec{AltNames: []string{"[email protected]", "127.0.0.1"}}.Validate())
Expand Down

0 comments on commit 19dd015

Please sign in to comment.