Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add pre-commit-config.yaml #123

Merged
merged 10 commits into from
Dec 3, 2024
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code.

Please read the full text at https://www.hashicorp.com/community-guidelines
Please read the full text at <https://www.hashicorp.com/community-guidelines>
17 changes: 15 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,56 @@
Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: <https://www.terraform.io/community.html>.

### Terraform Version

Run `terraform -v` to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

### Affected Resource(s)

Please list the resources as a list, for example:

- opc_instance
- opc_storage_volume

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

### Terraform Configuration Files

```hcl
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
```

### Debug Output
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Please provider a link to a GitHub Gist containing the complete debug output: <https://www.terraform.io/docs/internals/debugging.html>. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

### Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the `crash.log`.

### Expected Behavior

What should have happened?

### Actual Behavior

What actually happened?

### Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

1. `terraform apply`

### Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

### References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

- GH-1234
2 changes: 1 addition & 1 deletion .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Terraform is a mature project with a growing community. There are active, dedicated people willing to help you through various mediums.

Take a look at those mediums listed at https://www.terraform.io/community.html
Take a look at those mediums listed at <https://www.terraform.io/community.html>
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MD010: false
MD013: false
MD033: false
MD003: false
MD045: false
MD041: false
MD025: false
MD040: false
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
name: Format Go code
- id: go-vet
name: Verify Go code
- id: golangci-lint
name: Run golangci-lint
args:
- --exclude
- "Error return value of .(d.Set). is not checked"

- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.83.5
hooks:
- id: terraform_fmt
name: Format Terraform code
- id: terraform_validate
name: Validate Terraform code
- id: terraform_tflint
name: Lint Terraform code

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
hooks:
- id: markdownlint
name: Lint Markdown files
args: [--config=.markdownlint.yaml]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
name: Trim trailing whitespace
- id: end-of-file-fixer
name: Fix end of files
- id: check-yaml
name: Check YAML files
- id: mixed-line-ending
name: Fix line endings
- id: check-merge-conflict
name: Check for merge conflicts
- id: detect-private-key
name: Detect private keys
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ Terraform provider for managing your Cloudsmith resources.
Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) >= 0.12.x
- [Go](https://golang.org/doc/install) >= 1.13 (to build the provider plugin)
- [Terraform](https://www.terraform.io/downloads.html) >= 0.12.x
- [Go](https://golang.org/doc/install) >= 1.13 (to build the provider plugin)

Building The Provider
---------------------

Clone repository:

```sh
$ git clone [email protected]:cloudsmith-io/terraform-provider-cloudsmith
git clone [email protected]:cloudsmith-io/terraform-provider-cloudsmith
```

Enter the provider directory and build the provider:

```sh
$ cd terraform-provider-cloudsmith
$ go build
cd terraform-provider-cloudsmith
go build
```

Using the provider
Expand Down Expand Up @@ -61,7 +61,6 @@ resource "cloudsmith_entitlement" "my_entitlement" {
}
```


Retrieve a list of packages from a repository

```
Expand Down Expand Up @@ -95,7 +94,7 @@ Testing the Provider
In order to test the provider, you can run `go test`.

```sh
$ go test -v ./...
go test -v ./...
```

In order to run the full suite of Acceptance tests, you'll need a paid Cloudsmith account.
Expand All @@ -109,14 +108,14 @@ You'll also need to set a few environment variables:
*Note:* Acceptance tests create real resources, and may cost money to run.

```sh
$ export TF_ACC=1
$ export CLOUDSMITH_API_KEY=mykey
$ export CLOUDSMITH_NAMESPACE=mynamespace
$ go test -v ./...
export TF_ACC=1
export CLOUDSMITH_API_KEY=mykey
export CLOUDSMITH_NAMESPACE=mynamespace
go test -v ./...
```

If needed, you can also run individual tests with the `-run` flag:

```sh
$ go test -v -run=TestAccEntitlement_basic ./...
go test -v -run=TestAccEntitlement_basic ./...
```
16 changes: 9 additions & 7 deletions cloudsmith/resource_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,34 @@ func TestAccOidc_basic(t *testing.T) {
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "enabled", "true"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "name", "test-oidc-terraform-provider"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "provider_url", "https://test.com"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "service_accounts.0", "test-oidc-service-account"),
resource.TestMatchResourceAttr("cloudsmith_oidc.test", "service_accounts.0", regexp.MustCompile("^test-oidc-service-account.*$")),
),
},
{
Config: testAccOidcConfigBasicUpdateName,
Check: resource.ComposeTestCheckFunc(
testAccServiceCheckExists("cloudsmith_service.test"),
testAccOidcCheckExists("cloudsmith_oidc.test"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "namespace", os.Getenv("CLOUDSMITH_NAMESPACE")),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "claims.key", "value2"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "enabled", "false"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "name", "test-oidc-terraform-provider-updated"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "provider_url", "https://test.com"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "service_accounts.0", "test-oidc-service-account"),
resource.TestMatchResourceAttr("cloudsmith_oidc.test", "service_accounts.0", regexp.MustCompile("^test-oidc-service-account.*$")),
),
},
{
Config: testAccOidcConfigBasicUpdateProps,
Check: resource.ComposeTestCheckFunc(
testAccServiceCheckExists("cloudsmith_service.test"),
testAccOidcCheckExists("cloudsmith_oidc.test"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "namespace", os.Getenv("CLOUDSMITH_NAMESPACE")),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "claims.key", "value"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "claims.key2", "value2"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "enabled", "true"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "name", "test-oidc-terraform-provider-updated"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "provider_url", "https://test-updated-url.com"),
resource.TestCheckResourceAttr("cloudsmith_oidc.test", "service_accounts.0", "test-oidc-service-account"),
resource.TestMatchResourceAttr("cloudsmith_oidc.test", "service_accounts.0", regexp.MustCompile("^test-oidc-service-account.*$")),
),
},
{
Expand Down Expand Up @@ -127,7 +129,7 @@ resource "cloudsmith_oidc" "test" {
enabled = true
name = "test-oidc-terraform-provider"
provider_url = "https://test.com"
service_accounts = [cloudsmith_service.test.name]
service_accounts = [cloudsmith_service.test.slug]
}
`, os.Getenv("CLOUDSMITH_NAMESPACE"), os.Getenv("CLOUDSMITH_NAMESPACE"))

Expand All @@ -146,7 +148,7 @@ resource "cloudsmith_oidc" "test" {
enabled = false
name = "test-oidc-terraform-provider-updated"
provider_url = "https://test.com"
service_accounts = [cloudsmith_service.test.name]
service_accounts = [cloudsmith_service.test.slug]
}
`, os.Getenv("CLOUDSMITH_NAMESPACE"), os.Getenv("CLOUDSMITH_NAMESPACE"))

Expand All @@ -166,7 +168,7 @@ resource "cloudsmith_oidc" "test" {
enabled = true
name = "test-oidc-terraform-provider-updated"
provider_url = "https://test-updated-url.com"
service_accounts = [cloudsmith_service.test.name]
service_accounts = [cloudsmith_service.test.slug]
}
`, os.Getenv("CLOUDSMITH_NAMESPACE"), os.Getenv("CLOUDSMITH_NAMESPACE"))

Expand All @@ -187,7 +189,7 @@ resource "cloudsmith_oidc" "test" {
enabled = true
name = "test-oidc-terraform-provider-updated"
provider_url = "invalid-url"
service_accounts = [cloudsmith_service.test.name]
service_accounts = [cloudsmith_service.test.slug]
}
`, os.Getenv("CLOUDSMITH_NAMESPACE"), os.Getenv("CLOUDSMITH_NAMESPACE"))

Expand Down
3 changes: 2 additions & 1 deletion docs/data-sources/entitlement_list.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Entitlement Tokens Data Source

The `entitlement_tokens` data source allows for retrieval of a list of entitlement tokens within a given repository.

## Example Usage
Expand Down Expand Up @@ -80,4 +81,4 @@ The following attribute is additionally exported:
* `updated_by_url` - URL for the user who updated the entitlement token.
* `usage` - The usage associated with the token.
* `user` - The user associated with the token.
* `user_url` - URL for the user associated with the token.
* `user_url` - URL for the user associated with the token.
2 changes: 1 addition & 1 deletion docs/data-sources/organization_list_org_memebrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ The following attribute is additionally exported:
* `last_login_method` - The method used by the member for the last login.
* `role` - The role of the member within the organization.
* `user` - The username of the member.
* `user_id` - The unique identifier of the member.
* `user_id` - The unique identifier of the member.
2 changes: 1 addition & 1 deletion docs/data-sources/organization_member_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ The following attribute is additionally exported:
* `user_id` - The ID of the user (string).
* `user_name` - The username of the user (string).
* `user_url` - The URL of the user's profile (uri).
* `visibility` - The visibility of the member's profile. Defaults to "Public" and can be one of the following: "Public", "Private" (string).
* `visibility` - The visibility of the member's profile. Defaults to "Public" and can be one of the following: "Public", "Private" (string).
46 changes: 23 additions & 23 deletions docs/data-sources/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ data "cloudsmith_package" "test" {

## Argument Reference

- `namespace` (Required): The namespace of the package.
- `repository` (Required): The repository of the package.
- `identifier` (Required): The identifier for the package.
- `download` (Optional): If set to true, the package will be downloaded. Defaults to false. If set to false, the CDN URL will be available in the `output_path`.
- `download_dir` (Optional): The directory where the file will be downloaded to. If not set and `download` is set to `true`, it will default to the operating system's default temporary directory and save the file there.
- `ignore_checksums` (Optional): If set to `true`, any mismatched checksum from our API and local check will be ignored and download the package if `download` is set to `true`.
- `namespace` (Required): The namespace of the package.
- `repository` (Required): The repository of the package.
- `identifier` (Required): The identifier for the package.
- `download` (Optional): If set to true, the package will be downloaded. Defaults to false. If set to false, the CDN URL will be available in the `output_path`.
- `download_dir` (Optional): The directory where the file will be downloaded to. If not set and `download` is set to `true`, it will default to the operating system's default temporary directory and save the file there.
- `ignore_checksums` (Optional): If set to `true`, any mismatched checksum from our API and local check will be ignored and download the package if `download` is set to `true`.

## Attribute Reference

- `cdn_url`: The URL of the package to download. This attribute is computed and available only when the `download` argument is set to `false`.
- `checksum_md5`: MD5 hash of the downloaded package. If `download` is set to `false`, the checksum is returned from the package API instead.
- `checksum_sha1`: SHA1 hash of the downloaded package.If `download` is set to `false`, the checksum is returned from the package API instead.
- `checksum_sha256`: SHA256 hash of the downloaded package.If `download` is set to `false`, the checksum is returned from the package API instead.
- `checksum_sha512`: SHA512 hash of the downloaded package.If `download` is set to `false`, the checksum is returned from the package API instead.
- `format`: The format of the package.
- `is_sync_awaiting`: Indicates whether the package is awaiting synchronization.
- `is_sync_completed`: Indicates whether the package synchronization has completed.
- `is_sync_failed`: Indicates whether the package synchronization has failed.
- `is_sync_in_flight`: Indicates whether the package synchronization is currently in-flight.
- `is_sync_in_progress`: Indicates whether the package synchronization is currently in-progress.
- `name`: The name of the package.
- `output_path`: The location of the package. If the `download` argument is set to `true`, this will provide the path where the package is downloaded.
- `output_directory`: The directory where the package is downloaded.
- `slug`: The public unique identifier for the package.
- `slug_perm`: The slug_perm that immutably identifies the package.
- `version`: The version of the package.
- `cdn_url`: The URL of the package to download. This attribute is computed and available only when the `download` argument is set to `false`.
- `checksum_md5`: MD5 hash of the downloaded package. If `download` is set to `false`, the checksum is returned from the package API instead.
- `checksum_sha1`: SHA1 hash of the downloaded package.If `download` is set to `false`, the checksum is returned from the package API instead.
- `checksum_sha256`: SHA256 hash of the downloaded package.If `download` is set to `false`, the checksum is returned from the package API instead.
- `checksum_sha512`: SHA512 hash of the downloaded package.If `download` is set to `false`, the checksum is returned from the package API instead.
- `format`: The format of the package.
- `is_sync_awaiting`: Indicates whether the package is awaiting synchronization.
- `is_sync_completed`: Indicates whether the package synchronization has completed.
- `is_sync_failed`: Indicates whether the package synchronization has failed.
- `is_sync_in_flight`: Indicates whether the package synchronization is currently in-flight.
- `is_sync_in_progress`: Indicates whether the package synchronization is currently in-progress.
- `name`: The name of the package.
- `output_path`: The location of the package. If the `download` argument is set to `true`, this will provide the path where the package is downloaded.
- `output_directory`: The directory where the package is downloaded.
- `slug`: The public unique identifier for the package.
- `slug_perm`: The slug_perm that immutably identifies the package.
- `version`: The version of the package.
1 change: 0 additions & 1 deletion docs/data-sources/package_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ All of the argument attributes are also exported as result attributes.
The following attribute is additionally exported:

* `packages` - A list of `package` entries as discovered by the data source.

Loading