Skip to content

Commit

Permalink
Merge pull request #251 from gianlucam76/fix
Browse files Browse the repository at this point in the history
Fix lint
  • Loading branch information
gianlucam76 authored Jun 14, 2023
2 parents fd8dc74 + cadc3b1 commit 73d8a2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 7 additions & 2 deletions controllers/handlers_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
Name: kustomizationRef.Name,
}

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

remoteReports, err = deployUnstructured(ctx, false, remoteRestConfig, remoteClient, objectsToDeployRemotely,
err = validateUnstructred(ctx, true, objectsToDeployRemotely, clusterSummary, logger)
if err != nil {
return nil, nil, err
}

remoteReports, err = deployUnstructured(ctx, remoteRestConfig, remoteClient, objectsToDeployRemotely,
ref, configv1alpha1.FeatureKustomize, clusterSummary, logger)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to remote cluster %v", err))
Expand Down
14 changes: 6 additions & 8 deletions controllers/handlers_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,18 @@ func deployContent(ctx context.Context, deployingToMgmtCluster bool, destConfig
Name: referencedObject.GetName(),
}

err = validateUnstructred(ctx, deployingToMgmtCluster, destConfig, destClient, referencedUnstructured, ref,
configv1alpha1.FeatureResources, clusterSummary, logger)
err = validateUnstructred(ctx, deployingToMgmtCluster, referencedUnstructured, clusterSummary, logger)
if err != nil {
return nil, err
}

return deployUnstructured(ctx, deployingToMgmtCluster, destConfig, destClient, referencedUnstructured, ref,
return deployUnstructured(ctx, destConfig, destClient, referencedUnstructured, ref,
configv1alpha1.FeatureResources, clusterSummary, logger)
}

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

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

0 comments on commit 73d8a2c

Please sign in to comment.