-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Cloud-Native Toolkit <[email protected]>
- Loading branch information
0 parents
commit 29c8b0c
Showing
31 changed files
with
1,431 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.DS_Store | ||
terraform-provider-hashicups | ||
bin | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/go,terraform | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=go,terraform | ||
|
||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
|
||
### Terraform ### | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most | ||
# .tfvars files are managed as part of configuration and so should be included in | ||
# version control. | ||
# | ||
# example.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Include override files you do wish to add to version control using negated pattern | ||
# !example_override.tf | ||
|
||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan | ||
# example: *tfplan* | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/go,terraform | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc | ||
terraform | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
TEST?=$$(go list ./... | grep -v 'vendor') | ||
HOSTNAME=hashicorp.com | ||
NAMESPACE=cntk | ||
NAME=gitops | ||
BINARY=terraform-provider-${NAME} | ||
VERSION=0.1 | ||
OS_ARCH=darwin_amd64 | ||
|
||
default: install | ||
|
||
build: | ||
go build -o ${BINARY} | ||
|
||
release: | ||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 | ||
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 | ||
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 | ||
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm | ||
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 | ||
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 | ||
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm | ||
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 | ||
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 | ||
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 | ||
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386 | ||
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 | ||
|
||
install: build | ||
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} | ||
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} | ||
|
||
test: | ||
go test -i $(TEST) || exit 1 | ||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 | ||
|
||
testacc: | ||
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Terraform Provider Gitops | ||
|
||
Run the following command to build the provider | ||
|
||
```shell | ||
go build -o terraform-provider-gitops | ||
``` | ||
|
||
## Test sample configuration | ||
|
||
First, build and install the provider. | ||
|
||
```shell | ||
make install | ||
``` | ||
|
||
Then, run the following command to initialize the workspace and apply the sample configuration. | ||
|
||
```shell | ||
terraform init && terraform apply | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"db_connection": "host=db port=5432 user=postgres password=password dbname=products sslmode=disable", | ||
"bind_address": "0.0.0.0:9090", | ||
"metrics_address": "localhost:9102" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: '3.7' | ||
services: | ||
api: | ||
image: "hashicorpdemoapp/product-api:v4280cf7" | ||
ports: | ||
- "19090:9090" | ||
volumes: | ||
- ./conf.json:/config/config.json | ||
environment: | ||
CONFIG_FILE: '/config/config.json' | ||
depends_on: | ||
- db | ||
db: | ||
image: "hashicorpdemoapp/product-api-db:v4280cf7" | ||
ports: | ||
- "15432:5432" | ||
environment: | ||
POSTGRES_DB: 'products' | ||
POSTGRES_USER: 'postgres' | ||
POSTGRES_PASSWORD: 'password' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
terraform apply -auto-approve | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
terraform destroy -auto-approve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
terraform { | ||
required_providers { | ||
gitops = { | ||
version = "0.1" | ||
source = "hashicorp.com/cntk/gitops" | ||
} | ||
} | ||
} | ||
|
||
resource gitops_module ns { | ||
name = var.name | ||
namespace = var.namespace | ||
content_dir = "${path.module}/yaml" | ||
server_name = var.server_name | ||
layer = var.layer | ||
type = var.type | ||
config = var.config | ||
credentials = var.credentials | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
variable "config" { | ||
} | ||
|
||
variable "credentials" { | ||
} | ||
|
||
variable "server_name" { | ||
} | ||
|
||
variable "layer" { | ||
default = "infrastructure" | ||
} | ||
|
||
variable "type" { | ||
default = "base" | ||
} | ||
|
||
variable "namespace" { | ||
} | ||
|
||
variable "name" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: mymodule | ||
data: | ||
test: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
terraform { | ||
required_providers { | ||
gitops = { | ||
version = "0.1" | ||
source = "hashicorp.com/cntk/gitops" | ||
} | ||
} | ||
} | ||
|
||
resource gitops_namespace ns { | ||
name = "cntk" | ||
content_dir = "${path.module}/yaml" | ||
server_name = var.server_name | ||
config = var.config | ||
credentials = var.credentials | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "name" { | ||
value = gitops_namespace.ns.name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
variable "config" { | ||
} | ||
|
||
variable "credentials" { | ||
} | ||
|
||
variable "server_name" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: cntk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
module setup_clis { | ||
source = "github.com/cloud-native-toolkit/terraform-util-clis.git" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
provider "gitops" { | ||
username = var.git_username | ||
token = var.git_token | ||
bin_dir = module.setup_clis.bin_dir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
rm .terraform.lock.hcl | ||
terraform init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module "cert" { | ||
source = "github.com/cloud-native-toolkit/terraform-util-sealed-secret-cert.git" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module "gitops" { | ||
source = "github.com/cloud-native-toolkit/terraform-tools-gitops" | ||
|
||
host = var.git_host | ||
type = var.git_type | ||
org = var.git_org | ||
repo = var.git_repo | ||
token = var.git_token | ||
public = true | ||
username = var.git_username | ||
gitops_namespace = var.gitops_namespace | ||
sealed_secrets_cert = module.cert.cert | ||
} | ||
|
||
resource null_resource gitops_output { | ||
provisioner "local-exec" { | ||
command = "echo -n '${module.gitops.config_repo}' > git_repo" | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = "echo -n '${module.gitops.config_token}' > git_token" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
module cntk_namespace { | ||
source = "./gitops_namespace" | ||
|
||
server_name = module.gitops.server_name | ||
config = jsonencode(module.gitops.gitops_config) | ||
credentials = jsonencode(module.gitops.git_credentials) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
module cntk_module { | ||
source = "./gitops_module" | ||
|
||
name = "my-module" | ||
namespace = module.cntk_namespace.name | ||
server_name = module.gitops.server_name | ||
config = jsonencode(module.gitops.gitops_config) | ||
credentials = jsonencode(module.gitops.git_credentials) | ||
} | ||
|
||
module another_module { | ||
source = "./gitops_module" | ||
|
||
name = "another-module" | ||
namespace = module.cntk_namespace.name | ||
server_name = module.gitops.server_name | ||
config = jsonencode(module.gitops.gitops_config) | ||
credentials = jsonencode(module.gitops.git_credentials) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
git_token="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" | ||
git_username="cloudntivetoolkit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
variable "git_host" { | ||
default = "github.com" | ||
} | ||
|
||
variable "git_type" { | ||
default = "github" | ||
} | ||
|
||
variable "git_org" { | ||
default = "cloud-native-toolkit-test" | ||
} | ||
|
||
variable "git_repo" { | ||
default = "provider-test" | ||
} | ||
|
||
variable "git_token" { | ||
} | ||
|
||
variable "git_username" { | ||
} | ||
|
||
variable "gitops_namespace" { | ||
default = "openshift-gitops" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
terraform { | ||
required_providers { | ||
gitops = { | ||
source = "hashicorp.com/cntk/gitops" | ||
} | ||
} | ||
} |
Oops, something went wrong.