Skip to content

Commit

Permalink
feat: Add management of source control by @grahamhar (#18)
Browse files Browse the repository at this point in the history
Signed-off-by: grahamhar <[email protected]>
  • Loading branch information
grahamhar authored May 7, 2024
1 parent dc2401e commit 097e07e
Show file tree
Hide file tree
Showing 6 changed files with 507 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
example.tf
terraform.tfplan
terraform.tfstate
terraform-provider-sonatypeiq
.terraformrc
bin/
dist/
modules-dev/
Expand Down
65 changes: 65 additions & 0 deletions docs/resources/source_control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sonatypeiq_source_control Resource - terraform-provider-sonatypeiq"
subcategory: ""
description: |-
---

# sonatypeiq_source_control (Resource)



## Example Usage

```terraform
# Create and manage the source control for source control of organizations and applications
# Set source control for an application
data "sonatypeiq_application" "application" {
public_id = "sandbox-application"
}
resource "sonatypeiq_source_control" "application" {
owner_type = "application"
owner_id = data.sonatypeiq_application.application.id
base_branch = "main"
remediation_pull_requests_enabled = true
pull_request_commenting_enabled = true
source_control_evaluation_enabled = false
repository_url = "https://github.com/sonatype-nexus-community/terraform-provider-sonatypeiq.git"
}
# Set source control for an organization
data "sonatypeiq_organization" "sandbox" {
name = "Sandbox Organization"
}
resource "sonatypeiq_source_control" "organization" {
owner_type = "organization"
owner_id = data.sonatypeiq_organization.sandbox.id
remediation_pull_requests_enabled = true
pull_request_commenting_enabled = true
source_control_evaluation_enabled = true
base_branch = "my-cool-branch"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `owner_id` (String) Must be a valid organization or application ID, for the root organization use `ROOT_ORGANIZATION_ID`
- `owner_type` (String) The type of the owner, must be one of 'organization' or 'application'.

### Optional

- `base_branch` (String) The default branch to use.
- `pull_request_commenting_enabled` (Boolean) Set to true to enable the Pull Request Commenting feature.
- `remediation_pull_requests_enabled` (Boolean) Set to true to enable the Automated Pull Requests feature.
- `repository_url` (String) The SCM provider URL for the repository, only valid for `owner_type` of `application`
- `scm_provider` (String) The type of SCM Provider, must be one of 'azure, bitbucket, github or gitlab'. This is required when the organization is set to `ROOT_ORGANIZATION_ID`
- `source_control_evaluation_enabled` (Boolean) Set to true to enable Nexus IQ triggered source control evaluations.
- `token` (String) The token for use with the SCM Provider 'scm_provider'
- `user_name` (String) The user name to use when setting `scm_provider` to `bitbucket`.
30 changes: 30 additions & 0 deletions examples/resources/sonatypeiq_source_control/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Create and manage the source control for source control of organizations and applications

# Set source control for an application
data "sonatypeiq_application" "application" {
public_id = "sandbox-application"
}

resource "sonatypeiq_source_control" "application" {
owner_type = "application"
owner_id = data.sonatypeiq_application.application.id
base_branch = "main"
remediation_pull_requests_enabled = true
pull_request_commenting_enabled = true
source_control_evaluation_enabled = false
repository_url = "https://github.com/sonatype-nexus-community/terraform-provider-sonatypeiq.git"
}

# Set source control for an organization
data "sonatypeiq_organization" "sandbox" {
name = "Sandbox Organization"
}

resource "sonatypeiq_source_control" "organization" {
owner_type = "organization"
owner_id = data.sonatypeiq_organization.sandbox.id
remediation_pull_requests_enabled = true
pull_request_commenting_enabled = true
source_control_evaluation_enabled = true
base_branch = "my-cool-branch"
}
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (p *SonatypeIqProvider) Resources(ctx context.Context) []func() resource.Re
NewUserResource,
NewApplicationRoleMembershipResource,
NewOrganizationRoleMembershipResource,
NewSourceControlResource,
}
}

Expand Down
Loading

0 comments on commit 097e07e

Please sign in to comment.