Skip to content

Commit e949e08

Browse files
committed
Fix README.md
Add codefresh.yml
1 parent ab52a88 commit e949e08

File tree

5 files changed

+170
-84
lines changed

5 files changed

+170
-84
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
terraform-provider-codefresh
2+
dist/

.goreleaser.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
builds:
2+
- env:
3+
- CGO_ENABLED=0
4+
goos:
5+
- darwin
6+
- linux
7+
- windows
8+
archives:
9+
- replacements:
10+
darwin: Darwin
11+
linux: Linux
12+
windows: Windows
13+
386: i386
14+
amd64: x86_64
15+
format_overrides:
16+
- goos: windows
17+
format: zip
18+
checksum:
19+
name_template: 'checksums.txt'
20+
snapshot:
21+
name_template: "{{ .Tag }}-next"
22+
changelog:
23+
sort: asc
24+
filters:
25+
exclude:
26+
- '^docs:'
27+
- '^test:'

README.md

Lines changed: 31 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,50 @@
1-
# Setup
1+
# Terraform provider for Codefresh
22

3-
Get an API key from [Codefresh](https://g.codefresh.io/user/settings) and set the following scopes:
4-
* Environments-V2
5-
* Pipeline
6-
* Project
7-
* Repos
8-
* Step-Type
9-
* Step-Types
10-
* View
11-
12-
Add the key to your `.zshrc` file:
3+
This provider was initialized by [LightStep](https://lightstep.com/) and will be maintained as the official Terraform provider for Codefresh.
134

14-
```bash
15-
export CODEFRESH_API_KEY='xyz'
16-
```
17-
18-
# Building
19-
20-
```bash
21-
make build
22-
```
5+
The provider is still under development, and can be used as a terraform [third-party plugin](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins) only.
236

24-
# Testing
7+
## Requirements
258

26-
Create a `main.tf` file in the root directory. Add or import resources there.
9+
- [Terraform](https://www.terraform.io/downloads.html) 0.11+ ;
10+
- [Go](https://golang.org/doc/install) 1.12+ (to build the provider plugin).
2711

28-
## Example
12+
## Build
2913

30-
```yaml
31-
resource "codefresh_project" "test" {
32-
name = "test"
33-
}
14+
```sh
15+
go build
3416
```
3517

36-
Run `terraform plan` or `terraform apply` as usual. Note this will modify the actual Codefresh configuration.
18+
## Usage
3719

38-
# Syntax Examples
20+
Compile or take from the [Releases](https://github.com/codefresh-contrib/terraform-provider-codefresh/releases) `terraform-provider-codefresh` binary and place it locally according the Terraform plugins [documentation](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins).
3921

40-
## Project
22+
For Linux OS it can be:
4123

42-
```yaml
43-
resource "codefresh_project" "docker" {
44-
name = "docker"
45-
}
46-
```
24+
- _~/.terraform.d/plugins/linux\_amd64_
25+
- _./terraform.d/plugins/linux\_amd64_. The relative path in your Terraform project.
4726

48-
## Pipeline
49-
50-
```yaml
51-
resource "codefresh_pipeline" "docker_monorepo" {
52-
name = "docker/docker-monorepo"
53-
project = "docker"
54-
55-
spec = {
56-
repo = "abcinc/monorepo"
57-
path = "./codefresh/docker/docker-monorepo.yaml"
58-
revision = "master"
59-
concurrency = 1
60-
priority = 5
61-
}
62-
63-
tags = [
64-
"docker",
65-
]
66-
67-
variables {
68-
TAG = "master"
69-
}
70-
}
71-
```
27+
## Configuration
7228

73-
## Cron Trigger
29+
There are two environment variables to configure Codefresh provider:
7430

75-
```yaml
76-
resource "codefresh_cron_event" "docker_monorepo_cron" {
77-
expression = "40 0 * * *"
78-
message = "build monorepo docker"
79-
}
31+
- `CODEFRESH_API_URL`. Default value - https://g.codefresh.io/api ;
32+
- `CODEFRESH_API_KEY`.
8033

81-
resource "codefresh_cron_trigger" "docker_monorepo_cron" {
82-
pipeline = "${codefresh_pipeline.docker_monorepo.id}"
83-
event = "${codefresh_cron_event.docker_monorepo_cron.id}"
84-
}
85-
```
34+
Get an API key from [Codefresh](https://g.codefresh.io/user/settings) and set the following scopes:
8635

87-
## Environment
36+
- Environments-V2
37+
- Pipeline
38+
- Project
39+
- Repos
40+
- Step-Type
41+
- Step-Types
42+
- View
8843

89-
```yaml
90-
resource "codefresh_environment" "staging" {
91-
account_id = "<redacted>"
92-
name = "staging"
93-
namespace = "staging"
94-
cluster = "abcinc-staging"
95-
}
44+
```bash
45+
export CODEFRESH_API_KEY='xyz'
9646
```
9747

98-
## User
99-
```yaml
100-
resource "codefresh_user" "john_doe" {
101-
email = "jdoe@abcinc.com"
102-
}
103-
```
48+
## Examples
49+
50+
See the [examples](examples/).

codefresh.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '1.0'
2+
stages:
3+
- clone
4+
- prepare
5+
- release
6+
steps:
7+
main_clone:
8+
title: 'Cloning main repository...'
9+
stage: clone
10+
type: git-clone
11+
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
12+
revision: "${{CF_REVISION}}"
13+
git: "${{GIT_CONTEXT}}"
14+
15+
prepare_env_vars:
16+
title: 'Preparing environment variables...'
17+
stage: prepare
18+
image: codefreshio/ci-helpers
19+
commands:
20+
- source /get-token/get-gh-token.sh
21+
- cf_export GITHUB_TOKEN
22+
23+
go_fmt:
24+
title: 'Formatting'
25+
stage: prepare
26+
image: codefresh/goreleaser:${{GOLANG_VERSION}}
27+
commands:
28+
- go fmt
29+
30+
release_binaries:
31+
title: Create release in Github
32+
image: codefresh/goreleaser:${{GOLANG_VERSION}}
33+
stage: release
34+
commands:
35+
- goreleaser release --rm-dist

examples/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Example
2+
3+
```yaml
4+
resource "codefresh_project" "test" {
5+
name = "test"
6+
}
7+
```
8+
9+
Run `terraform plan` or `terraform apply` as usual. Note this will modify the actual Codefresh configuration.
10+
11+
# Syntax Examples
12+
13+
## Project
14+
15+
```yaml
16+
resource "codefresh_project" "docker" {
17+
name = "docker"
18+
}
19+
```
20+
21+
## Pipeline
22+
23+
```yaml
24+
resource "codefresh_pipeline" "docker_monorepo" {
25+
name = "docker/docker-monorepo"
26+
project = "docker"
27+
28+
spec = {
29+
repo = "abcinc/monorepo"
30+
path = "./codefresh/docker/docker-monorepo.yaml"
31+
revision = "master"
32+
concurrency = 1
33+
priority = 5
34+
}
35+
36+
tags = [
37+
"docker",
38+
]
39+
40+
variables {
41+
TAG = "master"
42+
}
43+
}
44+
```
45+
46+
## Cron Trigger
47+
48+
```yaml
49+
resource "codefresh_cron_event" "docker_monorepo_cron" {
50+
expression = "40 0 * * *"
51+
message = "build monorepo docker"
52+
}
53+
54+
resource "codefresh_cron_trigger" "docker_monorepo_cron" {
55+
pipeline = "${codefresh_pipeline.docker_monorepo.id}"
56+
event = "${codefresh_cron_event.docker_monorepo_cron.id}"
57+
}
58+
```
59+
60+
## Environment
61+
62+
```yaml
63+
resource "codefresh_environment" "staging" {
64+
account_id = "<redacted>"
65+
name = "staging"
66+
namespace = "staging"
67+
cluster = "abcinc-staging"
68+
}
69+
```
70+
71+
## User
72+
```yaml
73+
resource "codefresh_user" "john_doe" {
74+
email = "jdoe@abcinc.com"
75+
}
76+
```

0 commit comments

Comments
 (0)