Skip to content

Commit

Permalink
Merge pull request #22 from cycloidio/lo-v0.0.18
Browse files Browse the repository at this point in the history
provider: fix panic occuring when the resource owner is missing
  • Loading branch information
kerak19 authored Aug 5, 2024
2 parents d2e7a48 + baaf31e commit 5bedb46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.tfstate*
main.tf
variables.tf
*.env
5 changes: 4 additions & 1 deletion provider/catalog_repository_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,14 @@ func (r *catalogRepositoryResource) Delete(ctx context.Context, req resource.Del
func catalogRepositoryCYModelToData(org string, cr *models.ServiceCatalogSource, data *catalogRepositoryResourceModel) diag.Diagnostics {
var diags diag.Diagnostics

if cr.Owner != nil {
data.Owner = types.StringPointerValue(cr.Owner.Username)
}

data.Name = types.StringPointerValue(cr.Name)
data.Url = types.StringPointerValue(cr.URL)
data.Branch = types.StringValue(cr.Branch)
data.Canonical = types.StringPointerValue(cr.Canonical)
data.Owner = types.StringPointerValue(cr.Owner.Username)
data.OrganizationCanonical = types.StringValue(org)
data.CredentialCanonical = types.StringValue(cr.CredentialCanonical)

Expand Down
7 changes: 5 additions & 2 deletions provider/credential_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,18 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
)
return
}

}

// credentialCYModelToData converts the 'cred' into the 'credentialResourceModel'
func credentialCYModelToData(ctx context.Context, org string, cred *models.Credential, data *credentialResourceModel) diag.Diagnostics {
var diags diag.Diagnostics

if cred.Owner != nil {
data.Owner = types.StringPointerValue(cred.Owner.Username)
}

data.Name = types.StringPointerValue(cred.Name)
data.Description = types.StringValue(cred.Description)
data.Owner = types.StringPointerValue(cred.Owner.Username)
data.Canonical = types.StringPointerValue(cred.Canonical)
data.OrganizationCanonical = types.StringValue(org)
data.Body.AccessKey = types.StringValue(cred.Raw.AccessKey)
Expand Down

0 comments on commit 5bedb46

Please sign in to comment.