Skip to content

Commit

Permalink
revert to old version using json tring
Browse files Browse the repository at this point in the history
  • Loading branch information
Oded-B committed Jul 2, 2024
1 parent 9db40f0 commit 779df8f
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions internal/pkg/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/argoproj/gitops-engine/pkg/sync/hook"
"github.com/google/go-cmp/cmp"
log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

Expand Down Expand Up @@ -272,30 +271,30 @@ func SetArgoCDAppRevision(ctx context.Context, componentPath string, revision st
return nil
}

patchObject := argoappv1.Application{
ObjectMeta: metav1.ObjectMeta{
Namespace: foundApp.Namespace,
},
Spec: argoappv1.ApplicationSpec{
Source: &argoappv1.ApplicationSource{
TargetRevision: revision,
},
},
}
patchJson, err := json.Marshal(patchObject)
if err != nil {
return fmt.Errorf("Error marshalling patch object: %v\n%v", err, patchObject)
}
patch := string(patchJson)

// patchObject := argoappv1.Application{
// ObjectMeta: metav1.ObjectMeta{
// Namespace: foundApp.Namespace,
// },
// Spec: argoappv1.ApplicationSpec{
// Source: &argoappv1.ApplicationSource{
// TargetRevision: revision,
// },
// },
// }
// patchJson, err := json.Marshal(patchObject)
// if err != nil {
// return fmt.Errorf("Error marshalling patch object: %v\n%v", err, patchObject)
// }
// patch := string(patchJson)
patch := fmt.Sprintf(`{"spec": {"source": {"targetRevision": "%s"}}}`, revision)
log.Debugf("Patching app %s/%s with: %s", foundApp.Namespace, foundApp.Name, patch)

patchType := "merge"
patchedApp, err := appClient.Patch(ctx, &application.ApplicationPatchRequest{
Name: &foundApp.Name,
AppNamespace: &foundApp.Namespace,
PatchType: &patchType,
Patch: &patch,
Name: &foundApp.Name,
// AppNamespace: &foundApp.Namespace,
PatchType: &patchType,
Patch: &patch,
})
if err != nil {
return fmt.Errorf("Error patching app %s revision to %s failed: %v\n, patch: %v\npatched app: %v\n", foundApp.Name, revision, err, patch, patchedApp)
Expand Down

0 comments on commit 779df8f

Please sign in to comment.