Skip to content

Commit b8ebe90

Browse files
authored
Fix codefresh_account refresh for on-prem installations (#109)
## What * Fix `codefresh_account` refresh for on-prem installations ## Why * On-prem API does not return 'limits' field ## Notes <!-- Add any notes here --> ## Checklist * [x] _I have read [CONTRIBUTING.md](https://github.com/codefresh-io/terraform-provider-codefresh/blob/master/README.md)._ * [x] _I have [allowed changes to my fork to be made](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)._ * [x] _I have added tests, assuming new tests are warranted_. * [x] _I understand that the `/test` comment will be ignored by the CI trigger [unless it is made by a repo admin or collaborator](https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)._ Co-authored-by: Yonatan Koren <[email protected]>
1 parent baca012 commit b8ebe90

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

client/account.go

-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ type Account struct {
128128
RepoPermission string `json:"repoPermission,omitempty"`
129129
Limits *Limits `json:"limits,omitempty"`
130130
Features map[string]bool `json:"features,omitempty"`
131-
// Features *Features `json:"features,omitempty"`
132-
// RuntimeEnvironments ToDo
133-
// Remaining ToDo
134-
// ID string `json:"id"`
135131
}
136132

137133
type AccountDetails struct {

codefresh/resource_account.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,21 @@ func resourceAccountDelete(d *schema.ResourceData, meta interface{}) error {
155155
}
156156

157157
func mapAccountToResource(account *cfClient.Account, d *schema.ResourceData) error {
158-
159158
err := d.Set("name", account.Name)
160159
if err != nil {
161160
return err
162161
}
163162

164-
// err = d.Set("admins", account.Admins)
165-
// if err != nil {
166-
// return err
167-
// }
168163
err = d.Set("features", account.Features)
169164
if err != nil {
170165
return err
171166
}
172167

173-
err = d.Set("limits", []map[string]interface{}{flattenLimits(*account.Limits)})
174-
if err != nil {
175-
return err
168+
if account.Limits != nil { // On-prem API does not return 'limits' field
169+
err = d.Set("limits", []map[string]interface{}{flattenLimits(*account.Limits)})
170+
if err != nil {
171+
return err
172+
}
176173
}
177174

178175
err = d.Set("build", []map[string]interface{}{flattenBuild(*account.Build)})
@@ -197,12 +194,9 @@ func flattenBuild(build cfClient.Build) map[string]interface{} {
197194
return res
198195
}
199196
func mapResourceToAccount(d *schema.ResourceData) *cfClient.Account {
200-
// admins := d.Get("admins").(*schema.Set).List()
201-
202197
account := &cfClient.Account{
203198
ID: d.Id(),
204199
Name: d.Get("name").(string),
205-
// Admins: convertStringArr(admins),
206200
}
207201

208202
if _, ok := d.GetOk("features"); ok {

0 commit comments

Comments
 (0)