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

Add 'project_environment' resource #81

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.2.0 (August 29 29, 2023). Tested on Artifactory 7.63.14 and Xray 3.80.9

FEATURES:

* **New Resource:** `project_environment` Issue: [#78](https://github.com/jfrog/terraform-provider-project/issues/78) PR: [#81](https://github.com/jfrog/terraform-provider-project/pull/81)

## 1.1.16 (March 29, 2023). Tested on Artifactory 7.55.9 and Xray 3.69.3

IMPROVEMENTS:
Expand Down
3 changes: 2 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ update_pkg_cache:
GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/jfrog/terraform-provider-${PRODUCT}@v${VERSION}

build: fmt
GORELEASER_CURRENT_TAG=${NEXT_VERSION} goreleaser build --single-target --rm-dist --snapshot
GORELEASER_CURRENT_TAG=${NEXT_VERSION} goreleaser build --single-target --clean --snapshot

test:
@echo "==> Starting unit tests"
Expand All @@ -65,6 +65,7 @@ fmt:
@go fmt ./...

doc:
rm -r -v docs/*
go generate

.PHONY: build fmt
16 changes: 3 additions & 13 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,8 @@ provider "project" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **access_token** (String, Sensitive) This is a Bearer token that can be given to you by your admin under `Identity and Access`. This can also be sourced from the `PROJECT_ACCESS_TOKEN` or `JFROG_ACCESS_TOKEN` environment variable. Defauult to empty string if not set.
- **url** (String) URL of Artifactory. This can also be sourced from the `PROJECT_URL` or `JFROG_URL` environment variable. Default to 'http://localhost:8081' if not set.

### Optional

- **check_license** (Boolean) Toggle for pre-flight checking of Artifactory Enterprise license. Default to `true`.

## Import

Existing projects can be imported like this:
```shell
terraform import project.<name> <project_key>
```
- `access_token` (String, Sensitive) This is a Bearer token that can be given to you by your admin under `Identity and Access`. This can also be sourced from the `PROJECT_ACCESS_TOKEN` or `JFROG_ACCESS_TOKEN` environment variable. Defauult to empty string if not set.
- `check_license` (Boolean) Toggle for pre-flight checking of Artifactory Enterprise license. Default to `true`.
- `url` (String) URL of Artifactory. This can also be sourced from the `PROJECT_URL` or `JFROG_URL` environment variable. Default to 'http://localhost:8081' if not set.
42 changes: 42 additions & 0 deletions docs/resources/environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "project_environment Resource - terraform-provider-project"
subcategory: ""
description: |-
Creates a new environment for the specified project.
~>Note The combined length of project_key and name (separated by '-') cannot not exceeds 32 characters.
---

# project_environment (Resource)

Creates a new environment for the specified project.
~>**Note** The combined length of `project_key` and `name` (separated by '-') cannot not exceeds 32 characters.

## Example Usage

```terraform
resource "project_environment" "myenv" {
name = "myenv"
project_key = "myproj"
}
```

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

### Required

- `name` (String) Environment name. Must start with a letter and can contain letters, digits and `-` character.
- `project_key` (String) Project key for this environment. This field supports only 2 - 20 lowercase alphanumeric and hyphen characters. Must begin with a letter.

### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import project_environment.myenv myproj:myenv
```
15 changes: 8 additions & 7 deletions docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ description: |-
project_key
]
}

}
``
~>We strongly recommend using the repos attribute to manage the list of repositories. See below for additional details.
```
~>We strongly recommend using the 'repos' attribute to manage the list of repositories. See below for additional details.
---

# project (Resource)
Expand All @@ -42,7 +42,7 @@ resource "artifactory_local_maven_repository" "my_maven_releases" {
}
}
```
~>We strongly recommend using the `repos` attribute to manage the list of repositories. See below for additional details.
~>We strongly recommend using the 'repos' attribute to manage the list of repositories. See below for additional details.

## Example Usage

Expand Down Expand Up @@ -115,7 +115,6 @@ resource "project" "myproject" {
- `description` (String)
- `email_notification` (Boolean) Alerts will be sent when reaching 75% and 95% of the storage quota. This serves as a notification only and is not a blocker
- `group` (Block Set) Project group. Element has one to one mapping with the [JFrog Project Groups API](https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateGroupinProject) (see [below for nested schema](#nestedblock--group))
- `id` (String) The ID of this resource.
- `max_storage_in_gibibytes` (Number) Storage quota in GiB. Must be 1 or larger. Set to -1 for unlimited storage. This is translated to binary bytes for Artifactory API. So for a 1TB quota, this should be set to 1024 (vs 1000) which will translate to 1099511627776 bytes for the API.
- `member` (Block Set) Member of the project. Element has one to one mapping with the [JFrog Project Users API](https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateUserinProject). (see [below for nested schema](#nestedblock--member))
- `repos` (Set of String) (Optional) List of existing repo keys to be assigned to the project. **Note** We *strongly* recommend using this attribute to manage the list of repositories. If you wish to use the alternate method of setting `project_key` attribute in each `artifactory_*_repository` resource in the `artifactory` provider, you will need to use `lifecycle.ignore_changes` in the `project` resource to avoid state drift.
Expand All @@ -129,6 +128,10 @@ lifecycle {
```
- `role` (Block Set) Project role. Element has one to one mapping with the [JFrog Project Roles API](https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-AddaNewRole) (see [below for nested schema](#nestedblock--role))

### Read-Only

- `id` (String) The ID of this resource.
alexhung marked this conversation as resolved.
Show resolved Hide resolved

<a id="nestedblock--admin_privileges"></a>
### Nested Schema for `admin_privileges`

Expand Down Expand Up @@ -170,5 +173,3 @@ Required:
Optional:

- `description` (String)


1 change: 1 addition & 0 deletions examples/resources/project_environment/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import project_environment.myenv myproj:myenv
4 changes: 4 additions & 0 deletions examples/resources/project_environment/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "project_environment" "myenv" {
name = "myenv"
project_key = "myproj"
}
53 changes: 28 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ module github.com/jfrog/terraform-provider-project

require (
github.com/go-resty/resty/v2 v2.7.0
github.com/hashicorp/terraform-plugin-docs v0.7.0
github.com/hashicorp/terraform-plugin-log v0.8.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0
github.com/jfrog/terraform-provider-shared v1.14.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
Expand All @@ -30,20 +33,20 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.9 // indirect
github.com/hashicorp/go-plugin v1.4.10 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.5.0 // indirect
github.com/hashicorp/hcl/v2 v2.16.2 // indirect
github.com/hashicorp/hc-install v0.5.2 // indirect
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.18.1 // indirect
github.com/hashicorp/terraform-json v0.16.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.15.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.0 // indirect
github.com/hashicorp/terraform-svchost v0.1.0 // indirect
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.18.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.1 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
Expand All @@ -53,23 +56,23 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/posener/complete v1.1.1 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.13.1 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230327215041-6ac7f18bb9d5 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/ldap.v2 v2.5.1 // indirect
)
Expand Down
Loading
Loading