@@ -44,6 +44,9 @@ type QuickStartSpecInput struct {
44
44
// If not set, a random one will be generated.
45
45
ClusterName * string
46
46
47
+ // ClassNamespace is an optional class namespace reference, configuring cross-namespace cluster class reference
48
+ ClassNamespace * string
49
+
47
50
// InfrastructureProvider allows to specify the infrastructure provider to be used when looking for
48
51
// cluster templates.
49
52
// If not set, clusterctl will look at the infrastructure provider installed in the management cluster;
@@ -81,11 +84,12 @@ type QuickStartSpecInput struct {
81
84
// NOTE: This test works with Clusters with and without ClusterClass.
82
85
func QuickStartSpec (ctx context.Context , inputGetter func () QuickStartSpecInput ) {
83
86
var (
84
- specName = "quick-start"
85
- input QuickStartSpecInput
86
- namespace * corev1.Namespace
87
- cancelWatches context.CancelFunc
88
- clusterResources * clusterctl.ApplyClusterTemplateAndWaitResult
87
+ specName = "quick-start"
88
+ input QuickStartSpecInput
89
+ namespace * corev1.Namespace
90
+ clusterClassNamespace * corev1.Namespace
91
+ cancelWatches context.CancelFunc
92
+ clusterResources * clusterctl.ApplyClusterTemplateAndWaitResult
89
93
)
90
94
91
95
BeforeEach (func () {
@@ -100,6 +104,12 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
100
104
101
105
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
102
106
namespace , cancelWatches = framework .SetupSpecNamespace (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , input .PostNamespaceCreated )
107
+
108
+ if input .ClassNamespace != nil {
109
+ clusterClassNamespace = framework .CreateNamespace (ctx , framework.CreateNamespaceInput {Creator : input .BootstrapClusterProxy .GetClient (), Name : * input .ClassNamespace }, "40s" , "10s" )
110
+ Expect (clusterClassNamespace ).ToNot (BeNil (), "Failed to create namespace %q" , * input .ClassNamespace )
111
+ }
112
+
103
113
clusterResources = new (clusterctl.ApplyClusterTemplateAndWaitResult )
104
114
})
105
115
@@ -130,11 +140,19 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
130
140
if input .ClusterName != nil {
131
141
clusterName = * input .ClusterName
132
142
}
143
+
144
+ variables := map [string ]string {}
145
+ if input .ClassNamespace != nil {
146
+ variables ["CLUSTER_CLASS_NAMESPACE" ] = * input .ClassNamespace
147
+ }
148
+
149
+ By ("Creating a cluster referencing a clusterClass from another namespace" )
133
150
clusterctl .ApplyClusterTemplateAndWait (ctx , clusterctl.ApplyClusterTemplateAndWaitInput {
134
151
ClusterProxy : input .BootstrapClusterProxy ,
135
152
ConfigCluster : clusterctl.ConfigClusterInput {
136
153
LogFolder : filepath .Join (input .ArtifactFolder , "clusters" , input .BootstrapClusterProxy .GetName ()),
137
154
ClusterctlConfigPath : input .ClusterctlConfigPath ,
155
+ ClusterctlVariables : variables ,
138
156
KubeconfigPath : input .BootstrapClusterProxy .GetKubeconfigPath (),
139
157
InfrastructureProvider : infrastructureProvider ,
140
158
Flavor : flavor ,
@@ -154,11 +172,18 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
154
172
}
155
173
},
156
174
}, clusterResources )
175
+
157
176
By ("PASSED!" )
158
177
})
159
178
160
179
AfterEach (func () {
161
180
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
162
181
framework .DumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace , cancelWatches , clusterResources .Cluster , input .E2EConfig .GetIntervals , input .SkipCleanup )
182
+ if input .ClassNamespace != nil {
183
+ framework .DeleteNamespace (ctx , framework.DeleteNamespaceInput {
184
+ Deleter : input .BootstrapClusterProxy .GetClient (),
185
+ Name : clusterClassNamespace .Name ,
186
+ })
187
+ }
163
188
})
164
189
}
0 commit comments