diff --git a/docs/data-sources/git_auth.md b/docs/data-sources/git_auth.md deleted file mode 100644 index e665aeb1..00000000 --- a/docs/data-sources/git_auth.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "coder_git_auth Data Source - terraform-provider-coder" -subcategory: "" -description: |- - ~> Deprecated - Use the coder_external_auth data source instead. - Use this data source to require users to authenticate with a Git provider prior to workspace creation. This can be used to perform an authenticated git clone in startup scripts. ---- - -# coder_git_auth (Data Source) - -~> **Deprecated** -Use the `coder_external_auth` data source instead. - -Use this data source to require users to authenticate with a Git provider prior to workspace creation. This can be used to perform an authenticated `git clone` in startup scripts. - -## Example Usage - -```terraform -provider "coder" {} - -data "coder_git_auth" "github" { - # Matches the ID of the git auth provider in Coder. - id = "github" -} - -resource "coder_agent" "dev" { - os = "linux" - arch = "amd64" - dir = "~/coder" - env = { - GITHUB_TOKEN : data.coder_git_auth.github.access_token - } - startup_script = < -## Schema - -### Required - -- `id` (String) The identifier of a configured git auth provider set up in your Coder deployment. - -### Read-Only - -- `access_token` (String) The access token returned by the git authentication provider. This can be used to pre-authenticate command-line tools. diff --git a/examples/data-sources/coder_git_auth/data-source.tf b/examples/data-sources/coder_git_auth/data-source.tf deleted file mode 100644 index 488554f2..00000000 --- a/examples/data-sources/coder_git_auth/data-source.tf +++ /dev/null @@ -1,20 +0,0 @@ -provider "coder" {} - -data "coder_git_auth" "github" { - # Matches the ID of the git auth provider in Coder. - id = "github" -} - -resource "coder_agent" "dev" { - os = "linux" - arch = "amd64" - dir = "~/coder" - env = { - GITHUB_TOKEN : data.coder_git_auth.github.access_token - } - startup_script = < **Deprecated**\nUse the `coder_external_auth` data source instead.\n\nUse this data source to require users to authenticate with a Git provider prior to workspace creation. This can be used to perform an authenticated `git clone` in startup scripts.", - ReadContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics { - rawID, ok := rd.GetOk("id") - if !ok { - return diag.Errorf("id is required") - } - id, ok := rawID.(string) - if !ok { - return diag.Errorf("unexpected type %q for id", rawID) - } - rd.SetId(id) - - accessToken := helpers.OptionalEnv(GitAuthAccessTokenEnvironmentVariable(id)) - rd.Set("access_token", accessToken) - - return nil - }, - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Required: true, - Description: "The identifier of a configured git auth provider set up in your Coder deployment.", - }, - "access_token": { - Type: schema.TypeString, - Computed: true, - Description: "The access token returned by the git authentication provider. This can be used to pre-authenticate command-line tools.", - }, - }, - } -} - -func GitAuthAccessTokenEnvironmentVariable(id string) string { - return fmt.Sprintf("CODER_GIT_AUTH_ACCESS_TOKEN_%s", id) -} diff --git a/provider/gitauth_test.go b/provider/gitauth_test.go deleted file mode 100644 index 481d79f5..00000000 --- a/provider/gitauth_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package provider_test - -import ( - "testing" - - "github.com/coder/terraform-provider-coder/provider" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - - "github.com/stretchr/testify/require" -) - -func TestGitAuth(t *testing.T) { - t.Parallel() - - resource.Test(t, resource.TestCase{ - Providers: map[string]*schema.Provider{ - "coder": provider.New(), - }, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: ` - provider "coder" { - } - data "coder_git_auth" "github" { - id = "github" - } - `, - Check: func(state *terraform.State) error { - require.Len(t, state.Modules, 1) - require.Len(t, state.Modules[0].Resources, 1) - resource := state.Modules[0].Resources["data.coder_git_auth.github"] - require.NotNil(t, resource) - - attribs := resource.Primary.Attributes - require.Equal(t, "github", attribs["id"]) - - return nil - }, - }}, - }) -} diff --git a/provider/provider.go b/provider/provider.go index c1991a26..4d513139 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -72,7 +72,6 @@ func New() *schema.Provider { "coder_workspace_tags": workspaceTagDataSource(), "coder_provisioner": provisionerDataSource(), "coder_parameter": parameterDataSource(), - "coder_git_auth": gitAuthDataSource(), "coder_external_auth": externalAuthDataSource(), "coder_workspace_owner": workspaceOwnerDataSource(), }, diff --git a/provider/provider_test.go b/provider/provider_test.go index 7069db09..742eb30b 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -37,9 +37,6 @@ func TestProviderEmpty(t *testing.T) { data "coder_external_auth" "git" { id = "git" } - data "coder_git_auth" "git" { - id = "git" - } data "coder_parameter" "param" { name = "hey" }`,