-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow webhook changes to the bastion enabled flag
Signed-off-by: Tobias Giese <tobias.giese@daimler.com>
- Loading branch information
1 parent
244d31b
commit aea3643
Showing
8 changed files
with
520 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha4 | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestOpenStackCluster_ValidateUpdate(t *testing.T) { | ||
g := NewWithT(t) | ||
|
||
tests := []struct { | ||
name string | ||
oldTemplate *OpenStackCluster | ||
newTemplate *OpenStackCluster | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "OpenStackCluster.Spec.Bastion with immutable spec", | ||
oldTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Instance: OpenStackMachineSpec{ | ||
CloudName: "foobar", | ||
}, | ||
Enabled: false, | ||
}, | ||
}, | ||
}, | ||
newTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Instance: OpenStackMachineSpec{ | ||
CloudName: "foobarbaz", | ||
}, | ||
Enabled: true, | ||
}, | ||
}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "OpenStackCluster.Spec.Bastion with mutable spec", | ||
oldTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Enabled: false, | ||
}, | ||
}, | ||
}, | ||
newTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Enabled: true, | ||
}, | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "OpenStackCluster.Spec.IdentityRef with immutable spec", | ||
oldTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
IdentityRef: &OpenStackIdentityReference{ | ||
Kind: "Secret", | ||
}, | ||
CloudName: "foobar", | ||
}, | ||
}, | ||
newTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
IdentityRef: &OpenStackIdentityReference{ | ||
Kind: "foobar", | ||
}, | ||
}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "OpenStackCluster.Spec.IdentityRef with mutable spec", | ||
oldTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
IdentityRef: &OpenStackIdentityReference{ | ||
Kind: "Secret", | ||
}, | ||
CloudName: "foobar", | ||
}, | ||
}, | ||
newTemplate: &OpenStackCluster{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
IdentityRef: &OpenStackIdentityReference{ | ||
Kind: "Secret", | ||
}, | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
err := tt.newTemplate.ValidateUpdate(tt.oldTemplate) | ||
if tt.wantErr { | ||
g.Expect(err).To(HaveOccurred()) | ||
} else { | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha4 | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestOpenStackClusterTemplate_ValidateUpdate(t *testing.T) { | ||
g := NewWithT(t) | ||
|
||
tests := []struct { | ||
name string | ||
oldTemplate *OpenStackClusterTemplate | ||
newTemplate *OpenStackClusterTemplate | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "OpenStackClusterTemplate with immutable spec", | ||
oldTemplate: &OpenStackClusterTemplate{ | ||
Spec: OpenStackClusterTemplateSpec{ | ||
Template: OpenStackClusterTemplateResource{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Instance: OpenStackMachineSpec{ | ||
CloudName: "foobar", | ||
}, | ||
Enabled: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
newTemplate: &OpenStackClusterTemplate{ | ||
Spec: OpenStackClusterTemplateSpec{ | ||
Template: OpenStackClusterTemplateResource{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Instance: OpenStackMachineSpec{ | ||
CloudName: "foobarbaz", | ||
}, | ||
Enabled: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "OpenStackClusterTemplate with mutable spec", | ||
oldTemplate: &OpenStackClusterTemplate{ | ||
Spec: OpenStackClusterTemplateSpec{ | ||
Template: OpenStackClusterTemplateResource{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Enabled: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
newTemplate: &OpenStackClusterTemplate{ | ||
Spec: OpenStackClusterTemplateSpec{ | ||
Template: OpenStackClusterTemplateResource{ | ||
Spec: OpenStackClusterSpec{ | ||
CloudName: "foobar", | ||
Bastion: &Bastion{ | ||
Enabled: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
err := tt.newTemplate.ValidateUpdate(tt.oldTemplate) | ||
if tt.wantErr { | ||
g.Expect(err).To(HaveOccurred()) | ||
} else { | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.