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

fix: [CDS-105417]: harness_platform_gitops_applications resource is n… #1142

Merged
merged 1 commit into from
Jan 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,9 @@ func datasourceGitopsApplicationRead(ctx context.Context, d *schema.ResourceData
d.MarkNewResource()
return nil
}
setApplication(d, &resp)
err = setApplication(d, &resp)
if err != nil {
return diag.FromErr(err)
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,11 @@ func resourceGitopsApplicationCreate(ctx context.Context, d *schema.ResourceData
d.MarkNewResource()
return nil
}
setApplication(d, &resp)
err = setApplication(d, &resp)
if err != nil {
return diag.FromErr(err)
}

return nil
}

Expand Down Expand Up @@ -1176,7 +1180,11 @@ func resourceGitopsApplicationRead(ctx context.Context, d *schema.ResourceData,
d.MarkNewResource()
return nil
}
setApplication(d, &resp)
err = setApplication(d, &resp)
if err != nil {
return diag.FromErr(err)
}

return nil
}

Expand Down Expand Up @@ -1279,7 +1287,11 @@ func resourceGitopsApplicationUpdate(ctx context.Context, d *schema.ResourceData
d.MarkNewResource()
return nil
}
setApplication(d, &resp)
err = setApplication(d, &resp)
if err != nil {
return diag.FromErr(err)
}

return nil
}

Expand Down Expand Up @@ -1324,7 +1336,7 @@ func resourceGitopsApplicationDelete(ctx context.Context, d *schema.ResourceData
return nil
}

func setApplication(d *schema.ResourceData, app *nextgen.Servicev1Application) {
func setApplication(d *schema.ResourceData, app *nextgen.Servicev1Application) error {
d.SetId(app.Name)
d.Set("org_id", app.OrgIdentifier)
d.Set("project_id", app.ProjectIdentifier)
Expand Down Expand Up @@ -1441,9 +1453,13 @@ func setApplication(d *schema.ResourceData, app *nextgen.Servicev1Application) {
application["spec"] = specList
}
applicationList = append(applicationList, application)
d.Set("application", applicationList)
}

err := d.Set("application", applicationList)
if err != nil {
return fmt.Errorf("error setting application: %v", err)
}
}
return nil
}

func buildCreateApplicationRequest(d *schema.ResourceData) nextgen.ApplicationsApplicationCreateRequest {
Expand Down Expand Up @@ -1644,7 +1660,6 @@ func getSourceForState(appSpec *nextgen.ApplicationsApplicationSpec) map[string]
source["path"] = appSpec.Source.Path
source["target_revision"] = appSpec.Source.TargetRevision
source["chart"] = appSpec.Source.Chart
source["ref"] = appSpec.Source.Ref
if appSpec.Source.Helm != nil {
var helmList = []interface{}{}
var helm = map[string]interface{}{}
Expand Down