Skip to content

Commit b6d53b7

Browse files
added unit testing code
1 parent 4154973 commit b6d53b7

File tree

2 files changed

+617
-63
lines changed

2 files changed

+617
-63
lines changed

pkg/handlers/generic/lifecycle/k8sregistrationagent/handler.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const (
3737

3838
type ControllerConfig struct {
3939
*options.GlobalOptions
40-
4140
helmAddonConfig *addons.HelmAddonConfig
4241
}
4342

@@ -124,7 +123,6 @@ func (n *DefaultK8sRegistrtionAgent) apply(
124123
)
125124

126125
varMap := variables.ClusterVariablesToVariablesMap(cluster.Spec.Topology.Variables)
127-
// log.Info("debug 1: %v", varMap)
128126
k8sAgentVar, err := variables.Get[apivariables.NutanixK8sRegistrationAgent](
129127
varMap,
130128
n.variableName,
@@ -150,7 +148,7 @@ func (n *DefaultK8sRegistrtionAgent) apply(
150148
return
151149
}
152150

153-
// Ensure credentials are provided
151+
// Ensure pc credentials are provided
154152
if k8sAgentVar.Credentials == nil {
155153
resp.SetStatus(runtimehooksv1.ResponseStatusFailure)
156154
resp.SetMessage("name of the Secret containing PC credentials must be set")
@@ -201,11 +199,9 @@ func (n *DefaultK8sRegistrtionAgent) apply(
201199
}
202200
}
203201

204-
log.Info("debug 2: %v", k8sAgentVar.Strategy)
205202
var strategy addons.Applier
206203
switch k8sAgentVar.Strategy {
207204
case v1alpha1.AddonStrategyHelmAddon:
208-
log.Info("debug 3: inside helm strategy")
209205
helmChart, err := n.helmChartInfoGetter.For(ctx, log, config.K8sRegistrationAgent)
210206
if err != nil {
211207
log.Error(
@@ -220,15 +216,6 @@ func (n *DefaultK8sRegistrtionAgent) apply(
220216
)
221217
return
222218
}
223-
log.Info(
224-
"debug: helmChart info",
225-
"name",
226-
helmChart.Name,
227-
"repo",
228-
helmChart.Repository,
229-
"version",
230-
helmChart.Version,
231-
)
232219
clusterConfigVar, err := variables.Get[apivariables.ClusterConfigSpec](
233220
varMap,
234221
v1alpha1.ClusterConfigVariableName,
@@ -272,14 +259,12 @@ func (n *DefaultK8sRegistrtionAgent) apply(
272259
}
273260

274261
if err := strategy.Apply(ctx, cluster, n.config.DefaultsNamespace(), log); err != nil {
275-
log.Info("debug 5: inside apply error")
276262
log.Error(err, "Helm strategy Apply failed")
277263
err = fmt.Errorf("failed to apply K8s Registration Agent addon: %w", err)
278264
resp.SetStatus(runtimehooksv1.ResponseStatusFailure)
279265
resp.SetMessage(err.Error())
280266
return
281267
}
282-
log.Info("debug 7: successfully applied")
283268
resp.SetStatus(runtimehooksv1.ResponseStatusSuccess)
284269
}
285270

0 commit comments

Comments
 (0)