99 "github.com/stretchr/testify/assert"
1010 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
12+
13+ carenv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
1214)
1315
1416func TestNew (t * testing.T ) {
@@ -37,14 +39,14 @@ func TestNew(t *testing.T) {
3739 {
3840 name : "ignores empty skip annotation value" ,
3941 annotations : map [string ]string {
40- AnnotationKey : "" ,
42+ carenv1 . PreflightChecksSkipAnnotationKey : "" ,
4143 },
4244 expectCheckNames : map [string ]struct {}{},
4345 },
4446 {
4547 name : "ignores empty check names" ,
4648 annotations : map [string ]string {
47- AnnotationKey : "InfraVMImage,,InfraCredentials," ,
49+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,,InfraCredentials," ,
4850 },
4951 expectCheckNames : map [string ]struct {}{
5052 "infravmimage" : {},
@@ -54,14 +56,14 @@ func TestNew(t *testing.T) {
5456 {
5557 name : "ignores value of only commas" ,
5658 annotations : map [string ]string {
57- AnnotationKey : ",,," ,
59+ carenv1 . PreflightChecksSkipAnnotationKey : ",,," ,
5860 },
5961 expectCheckNames : map [string ]struct {}{},
6062 },
6163 {
6264 name : "accepts single check name" ,
6365 annotations : map [string ]string {
64- AnnotationKey : "InfraVMImage" ,
66+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage" ,
6567 },
6668 expectCheckNames : map [string ]struct {}{
6769 "infravmimage" : {},
@@ -70,7 +72,7 @@ func TestNew(t *testing.T) {
7072 {
7173 name : "accepts multiple check names" ,
7274 annotations : map [string ]string {
73- AnnotationKey : "InfraVMImage,InfraCredentials" ,
75+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,InfraCredentials" ,
7476 },
7577 expectCheckNames : map [string ]struct {}{
7678 "infravmimage" : {},
@@ -80,7 +82,7 @@ func TestNew(t *testing.T) {
8082 {
8183 name : "trims spaces from check names" ,
8284 annotations : map [string ]string {
83- AnnotationKey : " InfraVMImage , InfraCredentials " ,
85+ carenv1 . PreflightChecksSkipAnnotationKey : " InfraVMImage , InfraCredentials " ,
8486 },
8587 expectCheckNames : map [string ]struct {}{
8688 "infravmimage" : {},
@@ -125,47 +127,47 @@ func TestEvaluator_For(t *testing.T) {
125127 {
126128 name : "empty annotation value" ,
127129 annotations : map [string ]string {
128- AnnotationKey : "" ,
130+ carenv1 . PreflightChecksSkipAnnotationKey : "" ,
129131 },
130132 checkName : "InfraVMImage" ,
131133 expectMatch : false ,
132134 },
133135 {
134136 name : "skip InfraVMImage check" ,
135137 annotations : map [string ]string {
136- AnnotationKey : "InfraVMImage,InfraCredentials" ,
138+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,InfraCredentials" ,
137139 },
138140 checkName : "InfraVMImage" ,
139141 expectMatch : true ,
140142 },
141143 {
142144 name : "skip credentials, but not image" ,
143145 annotations : map [string ]string {
144- AnnotationKey : "InfraCredentials" ,
146+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraCredentials" ,
145147 },
146148 checkName : "InfraVMImage" ,
147149 expectMatch : false ,
148150 },
149151 {
150152 name : "skip with spaces and case mixing" ,
151153 annotations : map [string ]string {
152- AnnotationKey : " infraVMImage , InfraCredentials " ,
154+ carenv1 . PreflightChecksSkipAnnotationKey : " infraVMImage , InfraCredentials " ,
153155 },
154156 checkName : "InfraVMImage" ,
155157 expectMatch : true ,
156158 },
157159 {
158160 name : "extra commas do not affect matching" ,
159161 annotations : map [string ]string {
160- AnnotationKey : "InfraVMImage,,InfraCredentials," ,
162+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,,InfraCredentials," ,
161163 },
162164 checkName : "InfraVMImage" ,
163165 expectMatch : true ,
164166 },
165167 {
166168 name : "skip all checks" ,
167169 annotations : map [string ]string {
168- AnnotationKey : "all" ,
170+ carenv1 . PreflightChecksSkipAnnotationKey : "all" ,
169171 },
170172 checkName : "InfraVMImage" ,
171173 expectMatch : true ,
@@ -206,34 +208,34 @@ func TestEvaluator_ForAll(t *testing.T) {
206208 {
207209 name : "empty annotation value" ,
208210 annotations : map [string ]string {
209- AnnotationKey : "" ,
211+ carenv1 . PreflightChecksSkipAnnotationKey : "" ,
210212 },
211213 },
212214 {
213215 name : "skip all checks with spaces and case mixing" ,
214216 annotations : map [string ]string {
215- AnnotationKey : " aLL " ,
217+ carenv1 . PreflightChecksSkipAnnotationKey : " aLL " ,
216218 },
217219 expectMatch : true ,
218220 },
219221 {
220222 name : "skip all checks with extra commas" ,
221223 annotations : map [string ]string {
222- AnnotationKey : ",all,," ,
224+ carenv1 . PreflightChecksSkipAnnotationKey : ",all,," ,
223225 },
224226 expectMatch : true ,
225227 },
226228 {
227229 name : "skip all checks" ,
228230 annotations : map [string ]string {
229- AnnotationKey : "all" ,
231+ carenv1 . PreflightChecksSkipAnnotationKey : "all" ,
230232 },
231233 expectMatch : true ,
232234 },
233235 {
234236 name : "skip some checks, but not all" ,
235237 annotations : map [string ]string {
236- AnnotationKey : "OneCheck,AnotherCheck" ,
238+ carenv1 . PreflightChecksSkipAnnotationKey : "OneCheck,AnotherCheck" ,
237239 },
238240 expectMatch : false ,
239241 },
0 commit comments