Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update module github.com/argoproj/argo-cd/v2 to v2.12.0 #141

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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