Skip to content

Commit

Permalink
Merge pull request #141 from puzzle/renovate/github.com-argoproj-argo…
Browse files Browse the repository at this point in the history
…-cd-v2-2.x

Update module github.com/argoproj/argo-cd/v2 to v2.12.0
  • Loading branch information
ioboi authored Aug 13, 2024
2 parents 3a94ea4 + df14e54 commit e7012fa
Show file tree
Hide file tree
Showing 4 changed files with 350 additions and 398 deletions.
24 changes: 21 additions & 3 deletions argocd/appSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/ghodss/yaml"
log "github.com/sirupsen/logrus"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

func RenderApplicationSets(inputDir, outDir string) error {
Expand Down Expand Up @@ -71,7 +73,12 @@ func RenderApplicationSet(appSetFile, outDir string) error {
supportedGens := make(map[string]generators.Generator)
supportedGens["List"] = listGen

apps, _, err := generateApplications(*appSet, supportedGens)
// "List" generator does not use "client" at the moment.
// See: https://github.com/argoproj/argo-cd/blob/ec30a48bce7a60046836e481cd2160e28c59231d/applicationset/generators/list.go#L31
// TODO: Create unit test to check if list generator still works without real client.
fakeClient := fake.NewClientBuilder().Build()

apps, _, err := generateApplications(*appSet, supportedGens, fakeClient)
if err != nil {
return fmt.Errorf("could not generate applications: %w", err)
}
Expand Down Expand Up @@ -110,7 +117,11 @@ func writeApplications(apps []v1alpha1.Application, ouputDir string) error {
return nil
}

func generateApplications(applicationSetInfo v1alpha1.ApplicationSet, supportedGenerators map[string]generators.Generator) ([]v1alpha1.Application, v1alpha1.ApplicationSetReasonType, error) {
func generateApplications(
applicationSetInfo v1alpha1.ApplicationSet,
supportedGenerators map[string]generators.Generator,
client client.Client,
) ([]v1alpha1.Application, v1alpha1.ApplicationSetReasonType, error) {
var res []v1alpha1.Application

var firstError error
Expand All @@ -119,7 +130,14 @@ func generateApplications(applicationSetInfo v1alpha1.ApplicationSet, supportedG
renderer := utils.Render{}

for _, requestedGenerator := range applicationSetInfo.Spec.Generators {
t, err := generators.Transform(requestedGenerator, supportedGenerators, applicationSetInfo.Spec.Template, &applicationSetInfo, map[string]interface{}{})
t, err := generators.Transform(
requestedGenerator,
supportedGenerators,
applicationSetInfo.Spec.Template,
&applicationSetInfo, map[string]interface{}{},
client,
)

if err != nil {

log.Errorf("error generating application from params")
Expand Down
8 changes: 5 additions & 3 deletions argocd/repoClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ func renderFile(file, repoServerUrl, outputDir string, client apiclient.RepoServ
}
}

refSources, err := argo.GetRefSources(context.Background(), app.Spec, repoDB)
// As long as rollback is false, revisions can be empty.
// See: https://github.com/argoproj/argo-cd/blob/ec30a48bce7a60046836e481cd2160e28c59231d/util/argo/argo.go#L472
refSources, err := argo.GetRefSources(context.Background(), app.Spec.Sources, app.Spec.Project, repoDB.GetRepository, []string{}, false)
if err != nil {
return err
}

appSrc := app.Spec.GetSourcePtr()
appSrc := app.Spec.GetSource()

req := &apiclient.ManifestRequest{
ApplicationSource: appSrc,
ApplicationSource: &appSrc,
AppName: "goff-test",
NoCache: true,
RefSources: refSources,
Expand Down
Loading

0 comments on commit e7012fa

Please sign in to comment.