-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new resource
spacelift_gitlab_integration
(#557)
* refactor: moved CustomVCSInput and CustomVCSUpdateInput to separate package vcs * refactor: moved GitLab schema field name constants to gitlab_integration.go * feat: implemented spacelift_gitlab_integration resource * test: added tests for spacelift_gitlab_integration resource * docs: added examples and docs for spacelift_gitlab_integration resource * chore: added .envrc for easier setup of environment variables from .env file * cicd: added SPACELIFT_PROVIDER_TEST_SOURCECODE_GITLAB_DEFAULT_TOKEN and SPACELIFT_PROVIDER_TEST_SOURCECODE_GITLAB_SPACELEVEL_TOKEN to GitHub test workflows * fix: fix typo in GraphQL query for GitLabIntegration and add ForceNew flag to isDefault field in schema in spacelift/resource_gitlab_integration.go * refactor: rename "webhookURL" field to "webhookUrl" in GitLabIntegration struct and remove "Token" field * refactor: changes to spacelift/resource_gitlab_integration.go * add CustomizeDiff function ensure space is set to root if the integration should be the default * make gitLabUserFacingHost required and removed code to derive it from gitLabAPIHost if not set * set default value for gitLabSpaceID to "root" * docs: updated docs for spacelift_gitlab_integration * tests: updated tests for spacelift_gitlab_integration * added .envrc into .gitignore * minor fixes: naming, messaging, verifying --------- Co-authored-by: Thomas Meckel <[email protected]>
- Loading branch information
1 parent
c8054ad
commit 1cfb831
Showing
17 changed files
with
589 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ key.* | |
dist/ | ||
|
||
test.env | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "spacelift_gitlab_integration Resource - terraform-provider-spacelift" | ||
subcategory: "" | ||
description: |- | ||
spacelift_gitlab_integration represents an integration with a GitLab instance | ||
--- | ||
|
||
# spacelift_gitlab_integration (Resource) | ||
|
||
`spacelift_gitlab_integration` represents an integration with a GitLab instance | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "spacelift_gitlab_integration" "example" { | ||
name = "GitLab integration (public)" | ||
space_id = "root" | ||
api_host = "https://mygitlab.myorg.com" | ||
user_facing_host = "https://mygitlab.myorg.com" | ||
private_token = "gitlab-token" | ||
} | ||
resource "spacelift_gitlab_integration" "private-example" { | ||
name = "GitLab integration (private)" | ||
is_default = true | ||
api_host = "private://mygitlab" | ||
user_facing_host = "https://mygitlab.myorg.com" | ||
private_token = "gitlab-token" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `api_host` (String) API host URL | ||
- `name` (String) The friendly name of the integration | ||
- `private_token` (String, Sensitive) The GitLab API Token | ||
- `user_facing_host` (String) User facing host URL. | ||
|
||
### Optional | ||
|
||
- `description` (String) Description of the integration | ||
- `is_default` (Boolean) Is the GitLab integration the default for all spaces? If set to `true` the space must be set to `root` in `space_id` or left empty which uses the default | ||
- `labels` (Set of String) Labels to set on the integration | ||
- `space_id` (String) ID (slug) of the space the integration is in; Default: `root` | ||
|
||
### Read-Only | ||
|
||
- `id` (String) GitLab integration id. | ||
- `webhook_secret` (String, Sensitive) Secret for webhooks originating from GitLab repositories | ||
- `webhook_url` (String) URL for webhooks originating from GitLab repositories | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import spacelift_gitlab_integration.example spacelift_gitlab_integration_id | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import spacelift_gitlab_integration.example spacelift_gitlab_integration_id |
15 changes: 15 additions & 0 deletions
15
examples/resources/spacelift_gitlab_integration/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "spacelift_gitlab_integration" "example" { | ||
name = "GitLab integration (public)" | ||
space_id = "root" | ||
api_host = "https://mygitlab.myorg.com" | ||
user_facing_host = "https://mygitlab.myorg.com" | ||
private_token = "gitlab-token" | ||
} | ||
|
||
resource "spacelift_gitlab_integration" "private-example" { | ||
name = "GitLab integration (private)" | ||
is_default = true | ||
api_host = "private://mygitlab" | ||
user_facing_host = "https://mygitlab.myorg.com" | ||
private_token = "gitlab-token" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package spacelift | ||
|
||
const ( | ||
gitLabID = "id" | ||
gitLabName = "name" | ||
gitLabDescription = "description" | ||
gitLabIsDefault = "is_default" | ||
gitLabLabels = "labels" | ||
gitLabSpaceID = "space_id" | ||
gitLabUserFacingHost = "user_facing_host" | ||
gitLabAppID = "app_id" | ||
gitLabAPIHost = "api_host" | ||
gitLabToken = "private_token" | ||
gitLabWebhookURL = "webhook_url" | ||
gitLabWebhookSecret = "webhook_secret" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package structs | ||
|
||
// GitLabIntegration represents an GitLab identity provided by the Spacelift | ||
// integration. | ||
type GitLabIntegration struct { | ||
ID string `graphql:"id"` | ||
Name string `graphql:"name"` | ||
Space struct { | ||
ID string `graphql:"id"` | ||
} `graphql:"space"` | ||
IsDefault bool `graphql:"isDefault"` | ||
Labels []string `graphql:"labels"` | ||
Description *string `graphql:"description"` | ||
APIHost string `graphql:"apiHost"` | ||
UserFacingHost string `graphql:"userFacingHost"` | ||
WebhookSecret string `graphql:"webhookSecret"` | ||
WebhookURL string `graphql:"webhookUrl"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package vcs | ||
|
||
import "github.com/shurcooL/graphql" | ||
|
||
// CustomVCSInput represents the custom VCS input data. | ||
type CustomVCSInput struct { | ||
Name graphql.String `json:"name"` | ||
SpaceID graphql.ID `json:"spaceID"` | ||
Labels *[]graphql.String `json:"labels"` | ||
Description *graphql.String `json:"description"` | ||
IsDefault *graphql.Boolean `json:"isDefault"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package vcs | ||
|
||
import "github.com/shurcooL/graphql" | ||
|
||
// CustomVCSUpdateInput represents the custom VCS update input data. | ||
type CustomVCSUpdateInput struct { | ||
ID graphql.ID `json:"id"` | ||
SpaceID graphql.ID `json:"space"` | ||
Labels *[]graphql.String `json:"labels"` | ||
Description *graphql.String `json:"description"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.