Skip to content

Commit

Permalink
Mention OpenTofu; clean up repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
korenyoni committed Oct 17, 2023
1 parent 00721ed commit ab5847e
Show file tree
Hide file tree
Showing 50 changed files with 166 additions and 280 deletions.
41 changes: 18 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Terraform Provider for Codefresh

This is the official Terraform Provider for Codefresh.
The official Terraform and OpenTofu Provider for [Codefresh](https://codefresh.io/).

Terraform Registry: [registry.terraform.io/providers/codefresh-io/codefresh](https://registry.terraform.io/providers/codefresh-io/codefresh/latest)

## Requirements

- [Terraform](https://www.terraform.io/downloads.html) `1.x.x`

## Download the Provider

Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases)
- [Terraform](https://www.terraform.io/downloads.html) `1.x.x` or [OpenTofu](https://github.com/opentofu/opentofu/releases/latest) `1.x.x`.

## Using the Provider

Expand All @@ -21,12 +17,14 @@ terraform {
required_providers {
codefresh = {
version = "x.y.z" # Optional but recommended; replace with latest semantic version
source = "codefresh-io/codefresh"
source = "registry.terraform.io/codefresh-io/codefresh" # registry.terraform.io/ is optional for Terraform users, but required for OpenTofu users
}
}
}
```

You can also download and extract the provider binary (`terraform-provider-codefresh`) from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases).

## Building the Provider Locally

```sh
Expand All @@ -39,37 +37,34 @@ The documentation is generated using [tfplugindocs](https://github.com/hashicorp

See: [CONTRIBUTING.md](./CONTRIBUTING.md#documentation)

## To configure Codefresh provider:
## Provider Configuration:

```hcl
provider "codefresh" {
api_url = "<MY API URL>" # Default value - https://g.codefresh.io/api
token = "<MY API TOKEN>" # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable
}
```
See the [Provider Documentation](https://registry.terraform.io/providers/codefresh-io/codefresh/latest/docs#schema).

Get an API key from [Codefresh](https://g.codefresh.io/user/settings) and set the following scopes:
The provider requires a Codefresh API in order to authenticate to the Codefresh API. Generate the API key [here](https://g.codefresh.io/user/settings) and set the scopes [according to the resources you wish to create](https://codefresh.io/docs/docs/integrations/codefresh-api/#access-scopes). Note that some resource require platform admin permissions and hence can only be created for on-prem installations and not our SaaS offering.

- Environments-V2
- Pipeline
- Project
- Repos
- Step-Type
- Step-Types
- View
The key can be set as an environment variable:

```bash
export CODEFRESH_API_KEY='xyz'
```

## Testing the Provider

**NOTE:** Acceptance tests create real resources, including admin resources (accounts, users) so make sure that `CODEFRESH_API_KEY` is set to an account that you are ok with being modified.
**NOTE:** Acceptance tests create real resources, including admin resources (accounts, users) so make sure that `CODEFRESH_API_KEY` is set to a Codefresh installation and an account that you are ok with being modified.

```bash
make testacc
```

## OpenTofu Support

This provider supports [OpenTofu](https://opentofu.org/).

[Equivalence Testing](https://github.com/opentofu/equivalence-testing) is performed on the `examples/` directory in order to ensure that the provider behaves identically when used by either `terraform` and `tofu` binaries.

The [OpenTofu Registry](https://registry.opentofu.org/) seems to be unpublished at time of writing. As of now, the provider is only published to the [Terraform Registry](https://registry.terraform.io/providers/codefresh-io/codefresh/latest).

## Contributors

<a href="https://github.com/codefresh-io/terraform-provider-codefresh/graphs/contributors">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions examples/abac_rules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ resource "codefresh_abac_rules" "app_rule" {
actions = ["REFRESH", "SYNC", "TERMINATE_SYNC", "VIEW_POD_LOGS", "APP_ROLLBACK"]

attribute {
name = "LABEL"
key = "KEY"
name = "LABEL"
key = "KEY"
value = "VALUE"
}

tags = ["dev", "untagged"]
tags = ["dev", "untagged"]
}
6 changes: 3 additions & 3 deletions examples/abac_rules/provider.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "codefresh" {
api_url = var.api_url
api_url_v2 = var.api_url_v2
token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable
api_url = var.api_url
api_url_v2 = var.api_url_v2
token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable
}
4 changes: 2 additions & 2 deletions examples/abac_rules/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
api_url = "https://my-codefresh.example.com/api"
api_url = "https://my-codefresh.example.com/api"
api_url_v2 = "https://my-codefresh.example.com/2.0/api/graphql"
token = ""
token = ""
8 changes: 4 additions & 4 deletions examples/abac_rules/vars.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
variable api_url {
variable "api_url" {
type = string
}

variable api_url_v2 {
variable "api_url_v2" {
type = string
}

variable token {
type = string
variable "token" {
type = string
default = ""
}
2 changes: 1 addition & 1 deletion examples/abac_rules/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
codefresh = {
source = "codefresh-io/codefresh"
source = "registry.terraform.io/codefresh-io/codefresh"
version = "~> 0.1"
}
}
Expand Down
16 changes: 8 additions & 8 deletions examples/account_tokens/main.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
variable api_url {
variable "api_url" {
type = string
}

#
variable token {
type = string
variable "token" {
type = string
default = ""
}

## Set of account names
variable accounts {
variable "accounts" {
type = set(string)
}

module "account_tokens" {
source = "../../tf_modules/account_tokens"
api_url = var.api_url
accounts = var.accounts
source = "../.modules/account_tokens"
api_url = var.api_url
accounts = var.accounts
}

output "account_tokens" {
value = module.account_tokens.tokens
value = module.account_tokens.tokens
}
2 changes: 1 addition & 1 deletion examples/account_tokens/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
api_url = "https://my-codefresh-example.com/api"

accounts = [
"acc1", "acc2"
"acc1", "acc2"
]
2 changes: 1 addition & 1 deletion examples/account_tokens/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
codefresh = {
source = "codefresh-io/codefresh"
source = "registry.terraform.io/codefresh-io/codefresh"
version = "~> 0.1"
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/account_user_associations/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "codefresh_account_user_association" "user" {
email = "[email protected]"
email = "[email protected]"
}

resource "codefresh_account_user_association" "admin" {
email = "[email protected]"
admin = true
email = "[email protected]"
admin = true
}
2 changes: 1 addition & 1 deletion examples/account_user_associations/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
codefresh = {
source = "codefresh-io/codefresh"
source = "registry.terraform.io/codefresh-io/codefresh"
}
}
}
8 changes: 4 additions & 4 deletions examples/accounts_users/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module "codefresh_access_control" {
source = "../../tf_modules/accounts_users"
api_url = var.api_url
source = "../.modules/accounts_users"
api_url = var.api_url
default_idps = var.default_idps
accounts = var.accounts
users = var.users
accounts = var.accounts
users = var.users

default_acccount_limits = var.default_acccount_limits
}
84 changes: 42 additions & 42 deletions examples/accounts_users/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
api_url = "https://my-codefresh.example.com/api"
token = "cfAdmin-token"
token = "cfAdmin-token"

default_idps = {
local = {
display_name = "local"
sso = false
}
azure_sso = {
display_name = "azure-sso-1"
sso = true
}
local = {
display_name = "local"
sso = false
}
azure_sso = {
display_name = "azure-sso-1"
sso = true
}
}

accounts = {
acc1 = {}
acc2 = {
limits = {
collaborators = 50
parallel_builds = 5
}
acc1 = {}
acc2 = {
limits = {
collaborators = 50
parallel_builds = 5
}
}
}

users = {
user1 = {
email = "[email protected]"
personal = {
first_name = "John"
last_name = "Smith"
}
accounts = ["acc1", "acc2"]
admin_of_accounts = ["acc1"]
global_admin = true
user1 = {
email = "[email protected]"
personal = {
first_name = "John"
last_name = "Smith"
}
user2 = {
email = "live.com#[email protected]"
personal = {
first_name = "Q"
last_name = "D"
}
accounts = ["acc2"]
admin_of_accounts = []
global_admin = false
accounts = ["acc1", "acc2"]
admin_of_accounts = ["acc1"]
global_admin = true
}
user2 = {
email = "live.com#[email protected]"
personal = {
first_name = "Q"
last_name = "D"
}
user3 = {
email = "[email protected]"
personal = {
first_name = "Sam"
last_name = "Johnson"
}
accounts = ["acc1", "acc2"]
admin_of_accounts = ["acc1", "acc2"]
global_admin = true
accounts = ["acc2"]
admin_of_accounts = []
global_admin = false
}
user3 = {
email = "[email protected]"
personal = {
first_name = "Sam"
last_name = "Johnson"
}
accounts = ["acc1", "acc2"]
admin_of_accounts = ["acc1", "acc2"]
global_admin = true
}
}
20 changes: 10 additions & 10 deletions examples/accounts_users/vars.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
variable api_url {}
variable "api_url" {}

variable default_acccount_limits {
type = map(any)
default = {
collaborators = 100
parallel_builds = 10
}
variable "default_acccount_limits" {
type = map(any)
default = {
collaborators = 100
parallel_builds = 10
}
}

variable default_idps {
variable "default_idps" {
type = map(any)
}

variable accounts {
variable "accounts" {
type = map(any)
}

variable users {
variable "users" {
//type = map(any)
}

2 changes: 1 addition & 1 deletion examples/accounts_users/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
codefresh = {
source = "codefresh-io/codefresh"
source = "registry.terraform.io/codefresh-io/codefresh"
version = "~> 0.1"
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/permissions/provider.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
provider "codefresh" {
api_url = var.api_url
token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable
api_url = var.api_url
token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable
}
6 changes: 3 additions & 3 deletions examples/permissions/vars.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
variable api_url {
variable "api_url" {
type = string
}

variable token {
type = string
variable "token" {
type = string
default = ""
}
Loading

0 comments on commit ab5847e

Please sign in to comment.