Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
fix panic on empty err and usage of revision for detecting an update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Mar 28, 2024
1 parent 117619b commit 4319052
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 81 deletions.
7 changes: 3 additions & 4 deletions terraform/gen/plural_resource.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ func (r resourceTeleport{{.Name}}) Create(ctx context.Context, req tfsdk.CreateR
{{.VarName}}I, err = r.p.Client.{{.GetMethod}}(ctx, {{if .Namespaced}}defaults.Namespace, {{end}}id{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if trace.IsNotFound(err) {
if bErr := backoff.Do(ctx); bErr != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}"))
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(bErr), "{{.Kind}}"))
return
}
if tries >= r.p.RetryConfig.MaxTries {
diagMessage := fmt.Sprintf("Error reading {{.Name}} (tried %d times) - state outdated, please import resource", tries)
resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "{{.Kind}}"))
return
resp.Diagnostics.AddError(diagMessage, "{{.Kind}}")
}
continue
}
Expand Down Expand Up @@ -344,7 +343,7 @@ func (r resourceTeleport{{.Name}}) Update(ctx context.Context, req tfsdk.UpdateR
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", err, "{{.Kind}}"))
return
}
if {{.VarName}}Before.GetMetadata().ID != {{.VarName}}I.GetMetadata().ID || {{.HasStaticID}} {
if {{.VarName}}Before.GetMetadata().Revision != {{.VarName}}I.GetMetadata().Revision || {{.HasStaticID}} {
break
}

Expand Down
8 changes: 4 additions & 4 deletions terraform/gen/singular_resource.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ func (r resourceTeleport{{.Name}}) Create(ctx context.Context, req tfsdk.CreateR
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}"))
return
}
if {{.VarName}}Before.GetMetadata().ID != {{.VarName}}I.GetMetadata().ID || {{.HasStaticID}} {
if {{.VarName}}Before.GetMetadata().Revision != {{.VarName}}I.GetMetadata().Revision || {{.HasStaticID}} {
break
}
if bErr := backoff.Do(ctx); bErr != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}"))
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(bErr), "{{.Kind}}"))
return
}
if tries >= r.p.RetryConfig.MaxTries {
diagMessage := fmt.Sprintf("Error reading {{.Name}} (tried %d times) - state outdated, please import resource", tries)
resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "{{.Kind}}"))
resp.Diagnostics.AddError(diagMessage, "{{.Kind}}")
return
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func (r resourceTeleport{{.Name}}) Update(ctx context.Context, req tfsdk.UpdateR
break
}
if bErr := backoff.Do(ctx); bErr != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}"))
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(bErr), "{{.Kind}}"))
return
}
if tries >= r.p.RetryConfig.MaxTries {
Expand Down
7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_access_list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions terraform/provider/resource_teleport_auth_preference.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_device_trust.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_github_connector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_login_rule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_oidc_connector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_okta_import_rule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_provision_token.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions terraform/provider/resource_teleport_role.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4319052

Please sign in to comment.