diff --git a/octopusdeploy/data_source_git_credentials.go b/octopusdeploy/data_source_git_credentials.go index d8317dc86..eb7e0451f 100644 --- a/octopusdeploy/data_source_git_credentials.go +++ b/octopusdeploy/data_source_git_credentials.go @@ -24,9 +24,10 @@ func dataSourceGitCredentialsRead(ctx context.Context, d *schema.ResourceData, m Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingGitCredentials, err := client.GitCredentials.Get(query) + existingGitCredentials, err := credentials.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_git_credential.go b/octopusdeploy/resource_git_credential.go index ed3fd38de..6fdb4cd79 100644 --- a/octopusdeploy/resource_git_credential.go +++ b/octopusdeploy/resource_git_credential.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -29,12 +30,12 @@ func resourceGitCredentialCreate(ctx context.Context, d *schema.ResourceData, m tflog.Info(ctx, fmt.Sprintf("creating Git credential, %s", resource.Name)) client := m.(*client.Client) - createdResource, err := client.GitCredentials.Add(resource) + createdResource, err := credentials.Add(client, resource) if err != nil { return diag.FromErr(err) } - createdResource, err = client.GitCredentials.GetByID(createdResource.GetID()) + createdResource, err = credentials.GetByID(client, d.Get("space_id").(string), createdResource.GetID()) if err != nil { return diag.FromErr(err) } @@ -53,7 +54,7 @@ func resourceGitCredentialDelete(ctx context.Context, d *schema.ResourceData, m tflog.Info(ctx, fmt.Sprintf("deleting Git credential (%s)", d.Id())) client := m.(*client.Client) - if err := client.GitCredentials.DeleteByID(d.Id()); err != nil { + if err := credentials.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -67,7 +68,7 @@ func resourceGitCredentialRead(ctx context.Context, d *schema.ResourceData, m in tflog.Info(ctx, fmt.Sprintf("reading Git credential (%s)", d.Id())) client := m.(*client.Client) - resource, err := client.GitCredentials.GetByID(d.Id()) + resource, err := credentials.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Git credential") } @@ -86,7 +87,7 @@ func resourceGitCredentialUpdate(ctx context.Context, d *schema.ResourceData, m tflog.Info(ctx, fmt.Sprintf("updating Git credential (%s)", resource.GetID())) client := m.(*client.Client) - updatedResource, err := client.GitCredentials.Update(resource) + updatedResource, err := credentials.Update(client, resource) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/schema_git_credential.go b/octopusdeploy/schema_git_credential.go index 469044305..da17119b8 100644 --- a/octopusdeploy/schema_git_credential.go +++ b/octopusdeploy/schema_git_credential.go @@ -55,9 +55,10 @@ func getGitCredentialDataSchema() map[string]*schema.Schema { Optional: true, Type: schema.TypeList, }, - "name": getQueryName(), - "skip": getQuerySkip(), - "take": getQueryTake(), + "name": getQueryName(), + "skip": getQuerySkip(), + "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } }