Skip to content

Commit

Permalink
Continuous Delivery - Git PAT support (IBM-Cloud#4276)
Browse files Browse the repository at this point in the history
* Git PAT support

* Fix example
  • Loading branch information
gmarjoram authored and SunithaGudisagarIBM1 committed Feb 1, 2023
1 parent 20531fb commit 087433d
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "ibm_cd_toolchain_tool_hostedgit" "pipeline_repo" {
name = "pipeline-repo"
initialization {
type = "clone_if_not_exists"
repo_url = var.pipeline_repo
source_repo_url = var.pipeline_repo
private_repo = true
repo_name = join("-", [ var.repositories_prefix, "pipeline-repo" ])
}
Expand All @@ -33,7 +33,7 @@ resource "ibm_cd_toolchain_tool_hostedgit" "tekton_tasks_catalog_repo" {
name = "tasks-repo"
initialization {
type = "clone_if_not_exists"
repo_url = var.tekton_tasks_catalog_repo
source_repo_url = var.tekton_tasks_catalog_repo
private_repo = true
repo_name = join("-", [ var.repositories_prefix, "tasks-repo" ])
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -129,7 +129,7 @@ func DataSourceIBMCdToolchainToolBitbucketgit() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -129,7 +129,7 @@ func DataSourceIBMCdToolchainToolGithubconsolidated() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand All @@ -156,6 +156,17 @@ func DataSourceIBMCdToolchainToolGithubconsolidated() *schema.Resource {
Computed: true,
Description: "The ID of the GitHub repository.",
},
"auth_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Select the method of authentication that will be used to access the git provider.",
},
"api_token": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Sensitive: true,
Description: "Personal Access Token.",
},
"toolchain_issues_enabled": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -129,7 +129,7 @@ func DataSourceIBMCdToolchainToolGitlab() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand All @@ -151,6 +151,17 @@ func DataSourceIBMCdToolchainToolGitlab() *schema.Resource {
Computed: true,
Description: "The ID of the GitLab project.",
},
"auth_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Select the method of authentication that will be used to access the git provider.",
},
"api_token": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Sensitive: true,
Description: "Personal Access Token.",
},
"toolchain_issues_enabled": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -129,7 +129,7 @@ func DataSourceIBMCdToolchainToolHostedgit() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand All @@ -151,6 +151,17 @@ func DataSourceIBMCdToolchainToolHostedgit() *schema.Resource {
Computed: true,
Description: "The ID of the Git Repos and Issue Tracking project.",
},
"auth_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Select the method of authentication that will be used to access the git provider.",
},
"api_token": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Sensitive: true,
Description: "Personal Access Token.",
},
"toolchain_issues_enabled": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -84,7 +84,7 @@ func ResourceIBMCdToolchainToolBitbucketgit() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand Down Expand Up @@ -158,7 +158,7 @@ func ResourceIBMCdToolchainToolBitbucketgit() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -84,7 +84,7 @@ func ResourceIBMCdToolchainToolGithubconsolidated() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand Down Expand Up @@ -113,6 +113,18 @@ func ResourceIBMCdToolchainToolGithubconsolidated() *schema.Resource {
Computed: true,
Description: "The ID of the GitHub repository.",
},
"auth_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "Select the method of authentication that will be used to access the git provider.",
},
"api_token": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: flex.SuppressHashedRawSecret,
Sensitive: true,
Description: "Personal Access Token.",
},
"toolchain_issues_enabled": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -163,7 +175,7 @@ func ResourceIBMCdToolchainToolGithubconsolidated() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand Down
18 changes: 15 additions & 3 deletions ibm/service/cdtoolchain/resource_ibm_cd_toolchain_tool_gitlab.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -84,7 +84,7 @@ func ResourceIBMCdToolchainToolGitlab() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand All @@ -108,6 +108,18 @@ func ResourceIBMCdToolchainToolGitlab() *schema.Resource {
Computed: true,
Description: "The ID of the GitLab project.",
},
"auth_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "Select the method of authentication that will be used to access the git provider.",
},
"api_token": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: flex.SuppressHashedRawSecret,
Sensitive: true,
Description: "Personal Access Token.",
},
"toolchain_issues_enabled": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -158,7 +170,7 @@ func ResourceIBMCdToolchainToolGitlab() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' to create a new git repository, 'clone' to clone an existing repository into a new git repository, 'fork' to fork an existing git repository, or 'link' to link to an existing git repository.",
Description: "The operation that should be performed to initialize the new tool integration. Use 'new' or 'new_if_not_exists' to create a new git repository, 'clone' or 'clone_if_not_exists' to clone an existing repository into a new git repository, 'fork' or 'fork_if_not_exists' to fork an existing git repository, or 'link' to link to an existing git repository. If you attempt to apply a resource with type 'new', 'clone', or 'fork' when the target repo already exists, the attempt will fail. If you apply a resource with type 'new_if_not_exists`, 'clone_if_not_exists', or 'fork_if_not_exists' when the target repo already exists, the existing repo will be used as-is.",
},
"private_repo": &schema.Schema{
Type: schema.TypeBool,
Expand Down
Loading

0 comments on commit 087433d

Please sign in to comment.