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

Commit

Permalink
Release 14.2.1 (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0mant authored and rosstimothy committed Dec 4, 2023
1 parent 0037058 commit f3b30e7
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 35 deletions.
18 changes: 10 additions & 8 deletions terraform/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ type payload struct {
UpsertMethodArity int
// WithSecrets value for a withSecrets param of Get method (empty means no param used)
WithSecrets string
// GetWithoutContext indicates that get method has no context parameter (workaround for the User)
GetWithoutContext bool
// ID id value on create and import
ID string
// RandomMetadataName indicates that Metadata.Name must be generated (supported by plural resources only)
Expand Down Expand Up @@ -218,8 +216,9 @@ var (
TypeName: "GithubConnectorV3",
VarName: "githubConnector",
GetMethod: "GetGithubConnector",
CreateMethod: "UpsertGithubConnector",
CreateMethod: "CreateGithubConnector",
UpdateMethod: "UpsertGithubConnector",
UpsertMethodArity: 2,
DeleteMethod: "DeleteGithubConnector",
WithSecrets: "true",
ID: "githubConnector.Metadata.Name",
Expand All @@ -234,8 +233,9 @@ var (
TypeName: "OIDCConnectorV3",
VarName: "oidcConnector",
GetMethod: "GetOIDCConnector",
CreateMethod: "UpsertOIDCConnector",
CreateMethod: "CreateOIDCConnector",
UpdateMethod: "UpsertOIDCConnector",
UpsertMethodArity: 2,
DeleteMethod: "DeleteOIDCConnector",
WithSecrets: "true",
ID: "oidcConnector.Metadata.Name",
Expand All @@ -250,8 +250,9 @@ var (
TypeName: "SAMLConnectorV2",
VarName: "samlConnector",
GetMethod: "GetSAMLConnector",
CreateMethod: "UpsertSAMLConnector",
CreateMethod: "CreateSAMLConnector",
UpdateMethod: "UpsertSAMLConnector",
UpsertMethodArity: 2,
DeleteMethod: "DeleteSAMLConnector",
WithSecrets: "true",
ID: "samlConnector.Metadata.Name",
Expand Down Expand Up @@ -283,8 +284,9 @@ var (
TypeName: "RoleV6",
VarName: "role",
GetMethod: "GetRole",
CreateMethod: "UpsertRole",
CreateMethod: "CreateRole",
UpdateMethod: "UpsertRole",
UpsertMethodArity: 2,
DeleteMethod: "DeleteRole",
ID: "role.Metadata.Name",
Kind: "role",
Expand Down Expand Up @@ -330,10 +332,10 @@ var (
VarName: "user",
GetMethod: "GetUser",
CreateMethod: "CreateUser",
UpdateMethod: "UpdateUser",
UpdateMethod: "UpsertUser",
UpsertMethodArity: 2,
DeleteMethod: "DeleteUser",
WithSecrets: "false",
GetWithoutContext: true,
ID: "user.Metadata.Name",
Kind: "user",
HasStaticID: false,
Expand Down
2 changes: 1 addition & 1 deletion terraform/gen/plural_data_source.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (r dataSourceTeleport{{.Name}}) Read(ctx context.Context, req tfsdk.ReadDat
return
}

{{.VarName}}I, err := r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}id.Value{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
{{.VarName}}I, err := r.p.Client.{{.GetMethod}}(ctx, id.Value{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if err != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}"))
return
Expand Down
12 changes: 6 additions & 6 deletions terraform/gen/plural_resource.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (r resourceTeleport{{.Name}}) Create(ctx context.Context, req tfsdk.CreateR
{{end}}
id := {{.VarName}}Resource.Metadata.Name

_, err = r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}id{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
_, err = r.p.Client.{{.GetMethod}}(ctx, id{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if !trace.IsNotFound(err) {
if err == nil {
existErr := fmt.Sprintf("{{.Name}} exists in Teleport. Either remove it (tctl rm {{.Kind}}/%v)"+
Expand Down Expand Up @@ -160,7 +160,7 @@ func (r resourceTeleport{{.Name}}) Create(ctx context.Context, req tfsdk.CreateR
backoff := backoff.NewDecorr(r.p.RetryConfig.Base, r.p.RetryConfig.Cap, clockwork.NewRealClock())
for {
tries = tries + 1
{{.VarName}}I, err = r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}id{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
{{.VarName}}I, err = r.p.Client.{{.GetMethod}}(ctx, 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}}"))
Expand Down Expand Up @@ -232,7 +232,7 @@ func (r resourceTeleport{{.Name}}) Read(ctx context.Context, req tfsdk.ReadResou
return
}

{{.VarName}}I, err := r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}id.Value{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
{{.VarName}}I, err := r.p.Client.{{.GetMethod}}(ctx, id.Value{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if trace.IsNotFound(err) {
resp.State.RemoveResource(ctx)
return
Expand Down Expand Up @@ -301,7 +301,7 @@ func (r resourceTeleport{{.Name}}) Update(ctx context.Context, req tfsdk.UpdateR
{{- end}}
name := {{.VarName}}Resource.Metadata.Name

{{.VarName}}Before, err := r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}name{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
{{.VarName}}Before, err := r.p.Client.{{.GetMethod}}(ctx, name{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if err != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", err, "{{.Kind}}"))
return
Expand All @@ -328,7 +328,7 @@ func (r resourceTeleport{{.Name}}) Update(ctx context.Context, req tfsdk.UpdateR
backoff := backoff.NewDecorr(r.p.RetryConfig.Base, r.p.RetryConfig.Cap, clockwork.NewRealClock())
for {
tries = tries + 1
{{.VarName}}I, err = r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}name{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
{{.VarName}}I, err = r.p.Client.{{.GetMethod}}(ctx, name{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if err != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", err, "{{.Kind}}"))
return
Expand Down Expand Up @@ -394,7 +394,7 @@ func (r resourceTeleport{{.Name}}) Delete(ctx context.Context, req tfsdk.DeleteR

// ImportState imports {{.Name}} state
func (r resourceTeleport{{.Name}}) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) {
{{.VarName}}, err := r.p.Client.{{.GetMethod}}({{if not .GetWithoutContext}}ctx, {{end}}req.ID{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
{{.VarName}}, err := r.p.Client.{{.GetMethod}}(ctx, req.ID{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}})
if err != nil {
resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}"))
return
Expand Down
2 changes: 1 addition & 1 deletion terraform/provider/data_source_teleport_user.go

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

7 changes: 4 additions & 3 deletions terraform/provider/resource_teleport_bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"context"
"time"

"github.com/gravitational/teleport/api/client/proto"
"github.com/gravitational/teleport/api/types/wrappers"
"github.com/gravitational/trace"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/gravitational/teleport/api/client/proto"
"github.com/gravitational/teleport/api/types/wrappers"

"github.com/gravitational/teleport-plugins/terraform/tfschema"
)

Expand Down Expand Up @@ -210,7 +211,7 @@ func (r resourceTeleportBot) Read(ctx context.Context, req tfsdk.ReadResourceReq
return
}

_, err := r.p.Client.GetUser(plan.UserName.Value, false)
_, err := r.p.Client.GetUser(ctx, plan.UserName.Value, false)
if trace.IsNotFound(err) {
resp.State.RemoveResource(ctx)
return
Expand Down
4 changes: 2 additions & 2 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.

4 changes: 2 additions & 2 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.

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

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

4 changes: 2 additions & 2 deletions terraform/provider/resource_teleport_saml_connector.go

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

16 changes: 8 additions & 8 deletions terraform/provider/resource_teleport_user.go

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

1 change: 1 addition & 0 deletions terraform/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,7 @@ Specification of the device.
| model_identifier | string | | |
| os_build | string | | |
| os_build_supplemental | string | | |
| os_id | string | | |
| os_usernames | array of strings | | |
| os_version | string | | |
| update_time | RFC3339 time | | |
Expand Down
44 changes: 44 additions & 0 deletions terraform/tfschema/devicetrust/v1/device_terraform.go

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

0 comments on commit f3b30e7

Please sign in to comment.