Skip to content

Commit ed7cc45

Browse files
author
Joshua Reed
committed
Webhooks seem working.
1 parent ae638e7 commit ed7cc45

23 files changed

+587
-508
lines changed

api/v1beta1/cloudstackcluster_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
const (
27-
ClusterFinalizer = "cloudstackcluster.infrastructure.cluster.x-k8s.io"
28-
defaultIdentityRefKind = "Secret"
27+
ClusterFinalizer = "cloudstackcluster.infrastructure.cluster.x-k8s.io"
28+
// defaultIdentityRefKind = "Secret"
2929
CloudStackClusterLabelName = "cloudstackcluster.infrastructure.cluster.x-k8s.io/name"
3030
NetworkTypeIsolated = "Isolated"
3131
NetworkTypeShared = "Shared"

api/v1beta1/cloudstackcluster_webhook.go

Lines changed: 0 additions & 133 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1_test
18+
19+
import (
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta1"
24+
"time"
25+
)
26+
27+
var _ = Describe("CloudStackMachine types", func() {
28+
var cloudStackMachine infrav1.CloudStackMachine
29+
30+
BeforeEach(func() { // Reset test vars to initial state.
31+
cloudStackMachine = infrav1.CloudStackMachine{}
32+
})
33+
34+
Context("When calculating time since state change", func() {
35+
It("Return the correct value when the last state update time is known", func() {
36+
delta := time.Duration(10 * time.Minute)
37+
lastUpdated := time.Now().Add(-delta)
38+
cloudStackMachine.Status.InstanceStateLastUpdated = metav1.NewTime(lastUpdated)
39+
Ω(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(BeNumerically("~", delta, time.Second))
40+
})
41+
42+
It("Return a negative value when the last state update time is unknown", func() {
43+
Ω(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(BeNumerically("<", 0))
44+
})
45+
})
46+
})
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1_test
18+
19+
import (
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta1"
24+
"time"
25+
)
26+
27+
var _ = Describe("CloudStackMachine types", func() {
28+
var cloudStackMachine infrav1.CloudStackMachine
29+
30+
BeforeEach(func() { // Reset test vars to initial state.
31+
cloudStackMachine = infrav1.CloudStackMachine{}
32+
})
33+
34+
Context("When calculating time since state change", func() {
35+
It("Return the correct value when the last state update time is known", func() {
36+
delta := time.Duration(10 * time.Minute)
37+
lastUpdated := time.Now().Add(-delta)
38+
cloudStackMachine.Status.InstanceStateLastUpdated = metav1.NewTime(lastUpdated)
39+
Ω(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(BeNumerically("~", delta, time.Second))
40+
})
41+
42+
It("Return a negative value when the last state update time is unknown", func() {
43+
Ω(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(BeNumerically("<", 0))
44+
})
45+
})
46+
})

api/v1beta1/cloudstackmachine_webhook.go

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)