Skip to content

Commit 73d8a2c

Browse files
authored
Merge pull request #251 from gianlucam76/fix
Fix lint
2 parents fd8dc74 + cadc3b1 commit 73d8a2c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

controllers/handlers_kustomize.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
504504
Name: kustomizationRef.Name,
505505
}
506506

507-
localReports, err = deployUnstructured(ctx, true, localConfig, c, objectsToDeployLocally,
507+
localReports, err = deployUnstructured(ctx, localConfig, c, objectsToDeployLocally,
508508
ref, configv1alpha1.FeatureKustomize, clusterSummary, logger)
509509
if err != nil {
510510
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to management cluster %v", err))
@@ -516,7 +516,12 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
516516
return nil, nil, err
517517
}
518518

519-
remoteReports, err = deployUnstructured(ctx, false, remoteRestConfig, remoteClient, objectsToDeployRemotely,
519+
err = validateUnstructred(ctx, true, objectsToDeployRemotely, clusterSummary, logger)
520+
if err != nil {
521+
return nil, nil, err
522+
}
523+
524+
remoteReports, err = deployUnstructured(ctx, remoteRestConfig, remoteClient, objectsToDeployRemotely,
520525
ref, configv1alpha1.FeatureKustomize, clusterSummary, logger)
521526
if err != nil {
522527
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to remote cluster %v", err))

controllers/handlers_utils.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,18 @@ func deployContent(ctx context.Context, deployingToMgmtCluster bool, destConfig
185185
Name: referencedObject.GetName(),
186186
}
187187

188-
err = validateUnstructred(ctx, deployingToMgmtCluster, destConfig, destClient, referencedUnstructured, ref,
189-
configv1alpha1.FeatureResources, clusterSummary, logger)
188+
err = validateUnstructred(ctx, deployingToMgmtCluster, referencedUnstructured, clusterSummary, logger)
190189
if err != nil {
191190
return nil, err
192191
}
193192

194-
return deployUnstructured(ctx, deployingToMgmtCluster, destConfig, destClient, referencedUnstructured, ref,
193+
return deployUnstructured(ctx, destConfig, destClient, referencedUnstructured, ref,
195194
configv1alpha1.FeatureResources, clusterSummary, logger)
196195
}
197196

198-
func validateUnstructred(ctx context.Context, deployingToMgmtCluster bool, destConfig *rest.Config,
199-
destClient client.Client, referencedUnstructured []*unstructured.Unstructured, referencedObject *corev1.ObjectReference,
200-
featureID configv1alpha1.FeatureID, clusterSummary *configv1alpha1.ClusterSummary, logger logr.Logger,
201-
) error {
197+
func validateUnstructred(ctx context.Context, deployingToMgmtCluster bool,
198+
referencedUnstructured []*unstructured.Unstructured, clusterSummary *configv1alpha1.ClusterSummary,
199+
logger logr.Logger) error {
202200

203201
for i := range referencedUnstructured {
204202
policy := referencedUnstructured[i]
@@ -228,7 +226,7 @@ func validateUnstructred(ctx context.Context, deployingToMgmtCluster bool, destC
228226
// Returns an error if one occurred. Otherwise it returns a slice containing the name of
229227
// the policies deployed in the form of kind.group:namespace:name for namespaced policies
230228
// and kind.group::name for cluster wide policies.
231-
func deployUnstructured(ctx context.Context, deployingToMgmtCluster bool, destConfig *rest.Config,
229+
func deployUnstructured(ctx context.Context, destConfig *rest.Config,
232230
destClient client.Client, referencedUnstructured []*unstructured.Unstructured, referencedObject *corev1.ObjectReference,
233231
featureID configv1alpha1.FeatureID, clusterSummary *configv1alpha1.ClusterSummary, logger logr.Logger,
234232
) (reports []configv1alpha1.ResourceReport, err error) {

0 commit comments

Comments
 (0)