diff --git a/internal/provider/cert_client.go b/internal/provider/cert_client.go index 7d9ff9b397af51cb698663ab77804bc6ee473998..caa6cba2c722865fecdc3610b2e5dec1e73ad2db 100644 --- a/internal/provider/cert_client.go +++ b/internal/provider/cert_client.go @@ -13,7 +13,7 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -30,7 +30,7 @@ type createTokenResp struct { // Uses a client cert to get an API token and returns a client using that token. // Renews the token just before its 1 hour expiry in case of long running // terraform applies. -func apiClientWithClientCert(ctx context.Context, server, teamID, cert, key string) (*v20231101.Client, error) { +func apiClientWithClientCert(ctx context.Context, server, teamID, cert, key string) (*v20250101.Client, error) { if _, err := uuid.Parse(teamID); err != nil { return nil, fmt.Errorf("team-id argument must be a valid UUID") } @@ -57,12 +57,12 @@ func apiClientWithClientCert(ctx context.Context, server, teamID, cert, key stri var tkn string var m sync.RWMutex - var getTkn = func() error { + getTkn := func() error { post, err := http.NewRequest("POST", authURL, bytes.NewBuffer(b)) if err != nil { return err } - post.Header.Set("X-Smallstep-Api-Version", "2023-11-01") + post.Header.Set("X-Smallstep-Api-Version", "2025-01-01") post.Header.Set("Content-Type", "application/json") transport := http.DefaultTransport.(*http.Transport).Clone() transport.TLSClientConfig = &tls.Config{ @@ -116,9 +116,9 @@ func apiClientWithClientCert(ctx context.Context, server, teamID, cert, key stri } }() - apiClient, err := v20231101.NewClient(server, v20231101.WithRequestEditorFn(v20231101.RequestEditorFn(func(ctx context.Context, r *http.Request) error { + apiClient, err := v20250101.NewClient(server, v20250101.WithRequestEditorFn(v20250101.RequestEditorFn(func(ctx context.Context, r *http.Request) error { m.RLock() - r.Header.Set("X-Smallstep-Api-Version", "2023-11-01") + r.Header.Set("X-Smallstep-Api-Version", "2025-01-01") r.Header.Set("Authorization", fmt.Sprintf("Bearer %s", tkn)) m.RUnlock() return nil diff --git a/internal/provider/provisioner/data_source.go b/internal/provider/provisioner/data_source.go index a6566df3d9cc3d9e30dd1bf875ce2954b05dbd54..bfd8a423cbb420a42f01d95d9f8155a5636ce585 100644 --- a/internal/provider/provisioner/data_source.go +++ b/internal/provider/provisioner/data_source.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -22,7 +22,7 @@ func NewDataSource() datasource.DataSource { // DataSource implements data.smallstep_provisioner type DataSource struct { - client *v20231101.Client + client *v20250101.Client } func (a *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { @@ -36,12 +36,12 @@ func (a *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequ return } - client, ok := req.ProviderData.(*v20231101.Client) + client, ok := req.ProviderData.(*v20250101.Client) if !ok { resp.Diagnostics.AddError( "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + fmt.Sprintf("Expected *v20250101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), ) return } @@ -63,7 +63,7 @@ func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp if nameOrID == "" { nameOrID = config.Name.ValueString() } - httpResp, err := a.client.GetProvisioner(ctx, config.AuthorityID.ValueString(), nameOrID, &v20231101.GetProvisionerParams{}) + httpResp, err := a.client.GetProvisioner(ctx, config.AuthorityID.ValueString(), nameOrID, &v20250101.GetProvisionerParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -82,7 +82,7 @@ func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp return } - provisioner := &v20231101.Provisioner{} + provisioner := &v20250101.Provisioner{} if err := json.NewDecoder(httpResp.Body).Decode(provisioner); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", diff --git a/internal/provider/provisioner/model.go b/internal/provider/provisioner/model.go index 4e012b7eb0b027d9c64ba7228bcebcc7b547e8d7..42922e61f0a96800d020f3140f78c6329b8ca505 100644 --- a/internal/provider/provisioner/model.go +++ b/internal/provider/provisioner/model.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" "go.step.sm/crypto/jose" ) @@ -148,14 +148,14 @@ type AzureModel struct { DisableTrustOnFirstUse types.Bool `tfsdk:"disable_trust_on_first_use"` } -func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { - p := &v20231101.Provisioner{ +func toAPI(ctx context.Context, m *Model) (*v20250101.Provisioner, error) { + p := &v20250101.Provisioner{ Id: m.ID.ValueStringPointer(), Name: m.Name.ValueString(), - Type: v20231101.ProvisionerType(m.Type.ValueString()), + Type: v20250101.ProvisionerType(m.Type.ValueString()), } if m.Claims != nil { - p.Claims = &v20231101.ProvisionerClaims{ + p.Claims = &v20250101.ProvisionerClaims{ DisableRenewal: m.Claims.DisableRenewal.ValueBoolPointer(), AllowRenewalAfterExpiry: m.Claims.AllowRenewalAfterExpiry.ValueBoolPointer(), EnableSSHCA: m.Claims.EnableSSHCA.ValueBoolPointer(), @@ -172,9 +172,9 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { } if m.Options != nil { - p.Options = &v20231101.ProvisionerOptions{} + p.Options = &v20250101.ProvisionerOptions{} if m.Options.X509 != nil { - p.Options.X509 = &v20231101.X509Options{ + p.Options.X509 = &v20250101.X509Options{ Template: m.Options.X509.Template.ValueStringPointer(), } if !m.Options.X509.TemplateData.IsNull() { @@ -187,7 +187,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { } } if m.Options.SSH != nil { - p.Options.Ssh = &v20231101.SshOptions{ + p.Options.Ssh = &v20250101.SshOptions{ Template: m.Options.SSH.Template.ValueStringPointer(), } if !m.Options.SSH.TemplateData.IsNull() { @@ -204,7 +204,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { switch { case m.JWK != nil: ek := m.JWK.EncryptedKey.ValueString() - jwk := v20231101.JwkProvisioner{ + jwk := v20250101.JwkProvisioner{ Key: map[string]any{}, EncryptedKey: &ek, } @@ -223,7 +223,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.OIDC != nil: - oidc := v20231101.OidcProvisioner{ + oidc := v20250101.OidcProvisioner{ ClientID: m.OIDC.ClientID.ValueString(), ClientSecret: m.OIDC.ClientSecret.ValueString(), ConfigurationEndpoint: m.OIDC.ConfigurationEndpoint.ValueString(), @@ -256,7 +256,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.ACME != nil: - acme := v20231101.AcmeProvisioner{ + acme := v20250101.AcmeProvisioner{ ForceCN: m.ACME.ForceCN.ValueBoolPointer(), RequireEAB: m.ACME.RequireEAB.ValueBool(), } @@ -270,7 +270,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.ACMEAttestation != nil: - attest := v20231101.AcmeAttestationProvisioner{ + attest := v20250101.AcmeAttestationProvisioner{ ForceCN: m.ACMEAttestation.ForceCN.ValueBoolPointer(), RequireEAB: m.ACMEAttestation.RequireEAB.ValueBoolPointer(), } @@ -291,7 +291,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.X5C != nil: - x5c := v20231101.X5cProvisioner{} + x5c := v20250101.X5cProvisioner{} diagnostics := m.X5C.Roots.ElementsAs(ctx, &x5c.Roots, false) if err := utils.DiagnosticsToErr(diagnostics); err != nil { return nil, err @@ -301,7 +301,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.AWS != nil: - aws := v20231101.AwsProvisioner{ + aws := v20250101.AwsProvisioner{ DisableTrustOnFirstUse: m.AWS.DisableTrustOnFirstUse.ValueBoolPointer(), DisableCustomSANs: m.AWS.DisableCustomSANs.ValueBoolPointer(), InstanceAge: m.AWS.InstanceAge.ValueStringPointer(), @@ -315,7 +315,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.GCP != nil: - gcp := v20231101.GcpProvisioner{ + gcp := v20250101.GcpProvisioner{ DisableTrustOnFirstUse: m.GCP.DisableTrustOnFirstUse.ValueBoolPointer(), DisableCustomSANs: m.GCP.DisableCustomSANs.ValueBoolPointer(), InstanceAge: m.GCP.InstanceAge.ValueStringPointer(), @@ -335,7 +335,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return nil, err } case m.Azure != nil: - azure := v20231101.AzureProvisioner{ + azure := v20250101.AzureProvisioner{ TenantID: m.Azure.TenantID.ValueString(), Audience: m.Azure.Audience.ValueStringPointer(), DisableTrustOnFirstUse: m.Azure.DisableTrustOnFirstUse.ValueBoolPointer(), @@ -355,7 +355,7 @@ func toAPI(ctx context.Context, m *Model) (*v20231101.Provisioner, error) { return p, nil } -func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityID string, state utils.AttributeGetter) (*Model, diag.Diagnostics) { +func fromAPI(ctx context.Context, provisioner *v20250101.Provisioner, authorityID string, state utils.AttributeGetter) (*Model, diag.Diagnostics) { var diags diag.Diagnostics data := &Model{ @@ -460,7 +460,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI } switch provisioner.Type { - case v20231101.JWK: + case v20250101.JWK: jwk, err := provisioner.AsJwkProvisioner() if err != nil { diags.AddError( @@ -485,7 +485,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI } data.JWK.EncryptedKey = encryptedKey - case v20231101.OIDC: + case v20250101.OIDC: oidc, err := provisioner.AsOidcProvisioner() if err != nil { diags.AddError( @@ -536,7 +536,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI } data.OIDC.TenantID = tenantID - case v20231101.ACME: + case v20250101.ACME: acme, err := provisioner.AsAcmeProvisioner() if err != nil { diags.AddError( @@ -560,7 +560,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI } data.ACME.Challenges = challengesSet - case v20231101.ACMEATTESTATION: + case v20250101.ACMEATTESTATION: attest, err := provisioner.AsAcmeAttestationProvisioner() if err != nil { diags.AddError( @@ -604,7 +604,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI } data.ACMEAttestation.AttestationRoots = attestationRoots - case v20231101.X5C: + case v20250101.X5C: x5c, err := provisioner.AsX5cProvisioner() if err != nil { diags.AddError( @@ -626,7 +626,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI Roots: rootsSet, } - case v20231101.AWS: + case v20250101.AWS: aws, err := provisioner.AsAwsProvisioner() if err != nil { diags.AddError( @@ -667,7 +667,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI DisableCustomSANs: disableCustomSANs, } - case v20231101.GCP: + case v20250101.GCP: gcp, err := provisioner.AsGcpProvisioner() if err != nil { diags.AddError( @@ -710,7 +710,7 @@ func fromAPI(ctx context.Context, provisioner *v20231101.Provisioner, authorityI DisableTrustOnFirstUse: disableTOFU, } - case v20231101.AZURE: + case v20250101.AZURE: azure, err := provisioner.AsAzureProvisioner() if err != nil { diags.AddError( diff --git a/internal/provider/provisioner/resource.go b/internal/provider/provisioner/resource.go index c46eba451a262097bd0afc43cb2bd9c5736c30cf..f94b9b720019650c923163b4d0e86f372e4d3d47 100644 --- a/internal/provider/provisioner/resource.go +++ b/internal/provider/provisioner/resource.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -31,7 +31,7 @@ func NewResource() resource.Resource { // Resource defines the provisioner resource implementation. type Resource struct { - client *v20231101.Client + client *v20250101.Client } func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -647,12 +647,12 @@ func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, return } - client, ok := req.ProviderData.(*v20231101.Client) + client, ok := req.ProviderData.(*v20250101.Client) if !ok { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + fmt.Sprintf("Expected *v20250101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), ) return } @@ -681,7 +681,7 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp b, _ := json.Marshal(p) tflog.Trace(ctx, string(b)) - httpResp, err := a.client.PostAuthorityProvisioners(ctx, plan.AuthorityID.ValueString(), &v20231101.PostAuthorityProvisionersParams{}, *p) + httpResp, err := a.client.PostAuthorityProvisioners(ctx, plan.AuthorityID.ValueString(), &v20250101.PostAuthorityProvisionersParams{}, *p) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -700,7 +700,7 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp return } - provisioner := &v20231101.Provisioner{} + provisioner := &v20250101.Provisioner{} if err := json.NewDecoder(httpResp.Body).Decode(provisioner); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -747,7 +747,7 @@ func (a *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res if nameOrID == "" { nameOrID = state.Name.ValueString() } - httpResp, err := a.client.GetProvisioner(ctx, state.AuthorityID.ValueString(), nameOrID, &v20231101.GetProvisionerParams{}) + httpResp, err := a.client.GetProvisioner(ctx, state.AuthorityID.ValueString(), nameOrID, &v20250101.GetProvisionerParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -771,7 +771,7 @@ func (a *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res return } - provisioner := &v20231101.Provisioner{} + provisioner := &v20250101.Provisioner{} if err := json.NewDecoder(httpResp.Body).Decode(provisioner); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -822,7 +822,7 @@ func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp if nameOrID == "" { nameOrID = state.Name.ValueString() } - httpResp, err := a.client.DeleteProvisioner(ctx, state.AuthorityID.ValueString(), nameOrID, &v20231101.DeleteProvisionerParams{}) + httpResp, err := a.client.DeleteProvisioner(ctx, state.AuthorityID.ValueString(), nameOrID, &v20250101.DeleteProvisionerParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", diff --git a/internal/provider/webhook/data_source.go b/internal/provider/webhook/data_source.go index 7ee715f11aa5abd17d57dd068e2df8048bdd2478..8ecb7dd9549a3784f0ba7557e6221fba945fe831 100644 --- a/internal/provider/webhook/data_source.go +++ b/internal/provider/webhook/data_source.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -40,7 +40,7 @@ func NewDataSource() datasource.DataSource { // DataSource implements data.smallstep_provisioner_webhook type DataSource struct { - client *v20231101.Client + client *v20250101.Client } func (a *DataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { @@ -54,12 +54,12 @@ func (a *DataSource) Configure(ctx context.Context, req datasource.ConfigureRequ return } - client, ok := req.ProviderData.(*v20231101.Client) + client, ok := req.ProviderData.(*v20250101.Client) if !ok { resp.Diagnostics.AddError( "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + fmt.Sprintf("Expected *v20250101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), ) return } @@ -83,7 +83,7 @@ func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp if config.ID.IsNull() { idOrName = config.Name.ValueString() } - httpResp, err := a.client.GetWebhook(ctx, authorityID, provisionerID, idOrName, &v20231101.GetWebhookParams{}) + httpResp, err := a.client.GetWebhook(ctx, authorityID, provisionerID, idOrName, &v20250101.GetWebhookParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -102,7 +102,7 @@ func (a *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp return } - webhook := &v20231101.ProvisionerWebhook{} + webhook := &v20250101.ProvisionerWebhook{} if err := json.NewDecoder(httpResp.Body).Decode(webhook); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", diff --git a/internal/provider/webhook/model.go b/internal/provider/webhook/model.go index 05e74a3e71adab2d11709c8f558d07bacf2e1909..93c7ecab7d33e31f06d70620e29f231c25eb6be0 100644 --- a/internal/provider/webhook/model.go +++ b/internal/provider/webhook/model.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/types" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -33,7 +33,7 @@ type BasicAuthModel struct { Password types.String `tfsdk:"password"` } -func fromAPI(ctx context.Context, webhook *v20231101.ProvisionerWebhook, state utils.AttributeGetter) (*Model, diag.Diagnostics) { +func fromAPI(ctx context.Context, webhook *v20250101.ProvisionerWebhook, state utils.AttributeGetter) (*Model, diag.Diagnostics) { var diags diag.Diagnostics data := &Model{ @@ -49,7 +49,7 @@ func fromAPI(ctx context.Context, webhook *v20231101.ProvisionerWebhook, state u // for EXTERNAL webhooks. If it's nil in the API response use state for // external and null for hosted webhooks. if webhook.Secret == nil { - if webhook.ServerType == v20231101.EXTERNAL { + if webhook.ServerType == v20250101.EXTERNAL { secretFromState := types.String{} d := state.GetAttribute(ctx, path.Root("secret"), &secretFromState) diags = append(diags, d...) @@ -86,22 +86,22 @@ func fromAPI(ctx context.Context, webhook *v20231101.ProvisionerWebhook, state u return data, diags } -func toAPI(model *Model) *v20231101.ProvisionerWebhook { - webhook := &v20231101.ProvisionerWebhook{ +func toAPI(model *Model) *v20250101.ProvisionerWebhook { + webhook := &v20250101.ProvisionerWebhook{ Id: model.ID.ValueStringPointer(), Name: model.Name.ValueString(), BearerToken: model.BearerToken.ValueStringPointer(), - CertType: v20231101.ProvisionerWebhookCertType(model.CertType.ValueString()), + CertType: v20250101.ProvisionerWebhookCertType(model.CertType.ValueString()), DisableTLSClientAuth: model.DisableTLSClientAuth.ValueBoolPointer(), CollectionSlug: model.CollectionSlug.ValueStringPointer(), - Kind: v20231101.ProvisionerWebhookKind(model.Kind.ValueString()), + Kind: v20250101.ProvisionerWebhookKind(model.Kind.ValueString()), Secret: model.Secret.ValueStringPointer(), - ServerType: v20231101.ProvisionerWebhookServerType(model.ServerType.ValueString()), + ServerType: v20250101.ProvisionerWebhookServerType(model.ServerType.ValueString()), Url: model.URL.ValueStringPointer(), } if model.BasicAuth != nil { - webhook.BasicAuth = &v20231101.BasicAuth{ + webhook.BasicAuth = &v20250101.BasicAuth{ Username: model.BasicAuth.Username.ValueString(), Password: model.BasicAuth.Password.ValueString(), } diff --git a/internal/provider/webhook/resource.go b/internal/provider/webhook/resource.go index 5c747a5482562c8aed9ae84560f9b81b0b02f098..0e030b7d957e1bf3f11ab737f6a6327855285cd2 100644 --- a/internal/provider/webhook/resource.go +++ b/internal/provider/webhook/resource.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - v20231101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20231101" + v20250101 "github.com/smallstep/terraform-provider-smallstep/internal/apiclient/v20250101" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" ) @@ -28,7 +28,7 @@ func NewResource() resource.Resource { // Resource defines the resource implementation. type Resource struct { - client *v20231101.Client + client *v20250101.Client } func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -42,12 +42,12 @@ func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, return } - client, ok := req.ProviderData.(*v20231101.Client) + client, ok := req.ProviderData.(*v20250101.Client) if !ok { resp.Diagnostics.AddError( "Get Smallstep API client from provider", - fmt.Sprintf("Expected *v20231101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + fmt.Sprintf("Expected *v20250101.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), ) return } @@ -70,7 +70,7 @@ func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res if idOrName == "" { idOrName = state.Name.ValueString() } - httpResp, err := r.client.GetWebhook(ctx, authorityID, provisionerID, idOrName, &v20231101.GetWebhookParams{}) + httpResp, err := r.client.GetWebhook(ctx, authorityID, provisionerID, idOrName, &v20250101.GetWebhookParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -94,7 +94,7 @@ func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res return } - webhook := &v20231101.ProvisionerWebhook{} + webhook := &v20250101.ProvisionerWebhook{} if err := json.NewDecoder(httpResp.Body).Decode(webhook); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -272,7 +272,7 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp authorityID := plan.AuthorityID.ValueString() provisionerID := plan.ProvisionerID.ValueString() - httpResp, err := a.client.PostWebhooks(ctx, authorityID, provisionerID, &v20231101.PostWebhooksParams{}, *reqBody) + httpResp, err := a.client.PostWebhooks(ctx, authorityID, provisionerID, &v20250101.PostWebhooksParams{}, *reqBody) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -291,7 +291,7 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp return } - webhook := &v20231101.ProvisionerWebhook{} + webhook := &v20250101.ProvisionerWebhook{} if err := json.NewDecoder(httpResp.Body).Decode(webhook); err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", @@ -311,7 +311,6 @@ func (a *Resource) Create(ctx context.Context, req resource.CreateRequest, resp tflog.Trace(ctx, fmt.Sprintf("create webhook %q resource", plan.ID.ValueString())) resp.Diagnostics.Append(resp.State.Set(ctx, state)...) - } func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { @@ -331,7 +330,7 @@ func (a *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp if nameOrID == "" { nameOrID = state.Name.ValueString() } - httpResp, err := a.client.DeleteProvisioner(ctx, state.AuthorityID.ValueString(), nameOrID, &v20231101.DeleteProvisionerParams{}) + httpResp, err := a.client.DeleteProvisioner(ctx, state.AuthorityID.ValueString(), nameOrID, &v20250101.DeleteProvisionerParams{}) if err != nil { resp.Diagnostics.AddError( "Smallstep API Client Error", diff --git a/internal/provider/webhook/resource_test.go b/internal/provider/webhook/resource_test.go index 943397f2720d16a5b8d25b475e481508dc495a85..eebde855252d6fbc8217440e787b706db731ef75 100644 --- a/internal/provider/webhook/resource_test.go +++ b/internal/provider/webhook/resource_test.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-go/tfprotov6" helper "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/smallstep/terraform-provider-smallstep/internal/provider/collection" "github.com/smallstep/terraform-provider-smallstep/internal/provider/provisioner" "github.com/smallstep/terraform-provider-smallstep/internal/provider/utils" "github.com/smallstep/terraform-provider-smallstep/internal/testprovider" @@ -19,7 +18,6 @@ import ( var provider = &testprovider.SmallstepTestProvider{ ResourceFactories: []func() resource.Resource{ NewResource, - collection.NewResource, provisioner.NewResource, }, DataSourceFactories: []func() datasource.DataSource{ @@ -111,12 +109,7 @@ resource "smallstep_provisioner_webhook" "basic" { }, }) - slug := "tfprovider" + utils.Slug(t) hostedConfig := fmt.Sprintf(` -resource "smallstep_collection" "tpms" { - slug = %q -} - resource "smallstep_provisioner" "agents" { authority_id = %q name = "Agents" @@ -133,9 +126,7 @@ resource "smallstep_provisioner_webhook" "hosted" { kind = "ENRICHING" cert_type = "X509" server_type = "HOSTED_ATTESTATION" - collection_slug = smallstep_collection.tpms.slug - depends_on = [smallstep_collection.tpms] -}`, slug, authority.Id) +}`, authority.Id) helper.Test(t, helper.TestCase{ ProtoV6ProviderFactories: providerFactories,