Skip to content

Commit 05a8216

Browse files
add docs
1 parent 78a3901 commit 05a8216

File tree

6 files changed

+137
-11
lines changed

6 files changed

+137
-11
lines changed

codefresh/data_account_gitops_settings.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ func dataSourceAccountGitopsSettings() *schema.Resource {
1212
Description: "This data source retrieves gitops settings for the active account",
1313
Read: dataSourceAccountGitopsSettingsRead,
1414
Schema: map[string]*schema.Schema{
15-
"_id": {
16-
Type: schema.TypeString,
17-
Computed: true,
18-
},
1915
"name": {
2016
Type: schema.TypeString,
2117
Computed: true,

codefresh/resource_account_gitops_settings.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package codefresh
33
import (
44
"fmt"
55
"regexp"
6+
"strings"
67

78
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
89
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/internal/gitops"
@@ -12,7 +13,7 @@ import (
1213

1314
func resourceAccountGitopsSettings() *schema.Resource {
1415
return &schema.Resource{
15-
Description: "This data source retrieves gitops settings for the active account",
16+
Description: "Codefresh account gitops setting - such as git provider, API URL for the git provider and internal shared config repository",
1617
Read: resourceAccountGitopsSettingsRead,
1718
Create: resourceAccountGitopsSettingsUpdate,
1819
Update: resourceAccountGitopsSettingsUpdate,
@@ -22,19 +23,14 @@ func resourceAccountGitopsSettings() *schema.Resource {
2223
// Delete not implemenented as gitops settings cannot be removed, only updated
2324
Delete: resourceAccountGitopsSettingsDelete,
2425
Schema: map[string]*schema.Schema{
25-
"_id": {
26-
Type: schema.TypeString,
27-
Description: "Account ID for active account",
28-
Computed: true,
29-
},
3026
"name": {
3127
Type: schema.TypeString,
3228
Description: "Account name for active account",
3329
Computed: true,
3430
},
3531
"git_provider": {
3632
Type: schema.TypeString,
37-
Description: "Git provider name",
33+
Description: fmt.Sprintf("Git provider name - currently supported values are: %s", strings.Join(gitops.GetSupportedGitProvidersList(), " ,")),
3834
Required: true,
3935
ValidateFunc: validation.StringInSlice(gitops.GetSupportedGitProvidersList(), false),
4036
},

codefresh/resource_account_gitops_settings_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
88
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/internal/gitops"
9+
910
//"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1011
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1112
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
@@ -29,6 +30,14 @@ func TestAccCodefreshAccountGitopsSettings_basic(t *testing.T) {
2930
resource.TestCheckResourceAttr(resourceName, "git_provider", gitops.GitProviderGitHub),
3031
),
3132
},
33+
{
34+
Config: testAccountGitopsSettingsGithubExplicitApiUrl("https://github.com/codefresh-io/terraform-provider-isc-test.git", "https://api.mygithub.com"),
35+
Check: resource.ComposeTestCheckFunc(
36+
testAccCheckGitopsSettings(resourceName, gitops.GitProviderGitHub, "https://api.mygithub.com", "https://github.com/codefresh-io/terraform-provider-isc-test.git"),
37+
resource.TestCheckResourceAttr(resourceName, "git_provider", gitops.GitProviderGitHub),
38+
resource.TestCheckResourceAttr(resourceName, "git_provider_api_url", "https://api.mygithub.com"),
39+
),
40+
},
3241
{
3342
ResourceName: resourceName,
3443
ImportState: true,
@@ -80,3 +89,12 @@ func testAccountGitopsSettingsGithubDefaultApiUrl(sharedConfigRepository string)
8089
shared_config_repository = "%s"
8190
}`, sharedConfigRepository)
8291
}
92+
93+
func testAccountGitopsSettingsGithubExplicitApiUrl(sharedConfigRepository string, gitProviderApiUrl string) string {
94+
return fmt.Sprintf(`
95+
resource "codefresh_account_gitops_settings" "test" {
96+
git_provider = "GITHUB"
97+
shared_config_repository = "%s"
98+
git_provider_api_url = "%s"
99+
}`, sharedConfigRepository, gitProviderApiUrl)
100+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "codefresh_account_gitops_settings Data Source - terraform-provider-codefresh"
4+
subcategory: ""
5+
description: |-
6+
This data source retrieves gitops settings for the active account
7+
---
8+
9+
# codefresh_account_gitops_settings (Data Source)
10+
11+
This data source retrieves gitops settings for the active account
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Read-Only
19+
20+
- `_id` (String)
21+
- `admins` (List of String)
22+
- `git_provider` (String)
23+
- `git_provider_api_url` (String)
24+
- `id` (String) The ID of this resource.
25+
- `name` (String)
26+
- `shared_config_repository` (String)
27+
28+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
page_title: "codefresh_account_gitops_settings Resource - terraform-provider-codefresh"
3+
subcategory: ""
4+
description: |-
5+
Codefresh account gitops setting - such as git provider, API URL for the git provider and internal shared config repository
6+
---
7+
8+
# codefresh_account_gitops_settings (Resource)
9+
10+
Codefresh account gitops setting - such as git provider, API URL for the git provider and internal shared config repository
11+
12+
## Example usage
13+
```hcl
14+
resource "codefresh_account_gitops_settings" "gitops-settings" {
15+
git_provider = "GITHUB"
16+
shared_config_repository = "https://github.com/example-org/codefresh-internal-shared-config.git"
17+
}
18+
```
19+
```hcl
20+
resource "codefresh_account_gitops_settings" "gitops-settings" {
21+
git_provider = "BITBUCKET_SERVER"
22+
git_provider_api_url = https://bitbucket.example.com/rest/api/1.0
23+
shared_config_repository = "http://example-bitbucket.com/scm/proj/codefresh-internal-shared-config.git"
24+
}
25+
```
26+
27+
<!-- schema generated by tfplugindocs -->
28+
## Schema
29+
30+
### Required
31+
32+
- `git_provider` (String) Git provider name - currently supported values are: GITHUB ,GERRIT ,GITLAB ,BITBUCKET ,BITBUCKET_SERVER
33+
- `shared_config_repository` (String) Shared config repository url. Must be a valid git url which contains `.git`. May also includ path and branch references
34+
35+
### Optional
36+
37+
- `git_provider_api_url` (String) Git provider API url. If not provided can automatically be set for known SaaS git providers. For example - for github it will be set to https://api.github.com
38+
39+
### Read-Only
40+
41+
- `_id` (String) Account ID for active account
42+
- `id` (String) The ID of this resource.
43+
- `name` (String) Account name for active account
44+
45+
46+
-> Once internal config repository is cloned successfully by one or more runtimes it can no longer be changed and all attempted updates will fail.
47+
If you need to change the repository please contact Codefresh support.
48+
49+
## Import
50+
```sh
51+
terraform import codefresh_account_idp.test <id>
52+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
3+
subcategory: ""
4+
description: |-
5+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
6+
---
7+
8+
# {{.Name}} ({{.Type}})
9+
10+
{{ .Description | trimspace }}
11+
12+
## Example usage
13+
```hcl
14+
resource "codefresh_account_gitops_settings" "gitops-settings" {
15+
git_provider = "GITHUB"
16+
shared_config_repository = "https://github.com/example-org/codefresh-internal-shared-config.git"
17+
}
18+
```
19+
```hcl
20+
resource "codefresh_account_gitops_settings" "gitops-settings" {
21+
git_provider = "BITBUCKET_SERVER"
22+
git_provider_api_url = https://bitbucket.example.com/rest/api/1.0
23+
shared_config_repository = "http://example-bitbucket.com/scm/proj/codefresh-internal-shared-config.git"
24+
}
25+
```
26+
27+
{{ .SchemaMarkdown | trimspace }}
28+
29+
[!WARNING]
30+
Once internal config repository is cloned successfully by one or more runtimes it can no longer be changed and all attempted updated will fail.
31+
If you need to change the repository please contact Codefresh support.
32+
33+
## Import
34+
```sh
35+
terraform import codefresh_account_idp.test <id>
36+
```

0 commit comments

Comments
 (0)