From 6e44ba529ac18b073f88e6214ce0a886143bca5c Mon Sep 17 00:00:00 2001 From: kosta709 Date: Sun, 18 Oct 2020 07:54:29 +0300 Subject: [PATCH] auth-key sensitive+pipeline update + terr0.13 --- README.md | 25 +++++++++++++++++++++++-- codefresh/resource_api_key.go | 1 + codefresh/resource_pipeline.go | 5 +++-- go.sum | 2 ++ main.go | 7 ++++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 37051279..e053502a 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,32 @@ go build -o terraform-provider-codefresh 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). -For Linux OS it can be: - +### for terraform 0.12: - _~/.terraform.d/plugins/linux\_amd64_ - _./terraform.d/plugins/linux\_amd64_. The relative path in your Terraform project. +### for terraform 0.13 follow [required providers](https://www.terraform.io/docs/configuration/provider-requirements.html): +```bash +# OS is linux|windows|darwin, ARCH is amd64|arm|x86 +PLUGIN_DIR=~/.terraform.d/plugins/codefresh.io/app/codefresh/0.1.0/ +mkdir -p ${PLUGIN_DIR} +cp terraform-provider-codefresh ${PLUGIN_DIR}/ +``` + +add [required_providers block](https://www.terraform.io/docs/configuration/provider-requirements.html#requiring-providers) +```terraform +terraform { + + required_providers { + codefresh = { + versions = ["0.1.0"] + source = "codefresh.io/app/codefresh" + } + } +} +``` + + ## [Documentations](./docs) ## [Examples](./examples) diff --git a/codefresh/resource_api_key.go b/codefresh/resource_api_key.go index 432f4387..0821ab47 100644 --- a/codefresh/resource_api_key.go +++ b/codefresh/resource_api_key.go @@ -32,6 +32,7 @@ func resourceApiKey() *schema.Resource { "token": { Type: schema.TypeString, Computed: true, + Sensitive: true, }, "scopes": { Type: schema.TypeSet, diff --git a/codefresh/resource_pipeline.go b/codefresh/resource_pipeline.go index 8662d295..54e5d4e9 100644 --- a/codefresh/resource_pipeline.go +++ b/codefresh/resource_pipeline.go @@ -27,11 +27,12 @@ func resourcePipeline() *schema.Resource { }, "project_id": { Type: schema.TypeString, - Optional: true, + Computed: true, + }, "revision": { Type: schema.TypeInt, - Optional: true, + Computed: true, }, "tags": { Type: schema.TypeSet, diff --git a/go.sum b/go.sum index 767223e6..30275f4b 100644 --- a/go.sum +++ b/go.sum @@ -252,9 +252,11 @@ github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8j github.com/hashicorp/terraform-plugin-sdk v1.7.0 h1:B//oq0ZORG+EkVrIJy0uPGSonvmXqxSzXe8+GhknoW0= github.com/hashicorp/terraform-plugin-sdk v1.7.0/go.mod h1:OjgQmey5VxnPej/buEhe+YqKm0KNvV3QqU4hkqHqPCY= github.com/hashicorp/terraform-plugin-sdk v1.15.0 h1:bmYnTT7MqNXlUHDc7pT8E6uKT2g/upjlRLypJFK1OQU= +github.com/hashicorp/terraform-plugin-sdk v1.16.0 h1:NrkXMRjHErUPPTHQkZ6JIn6bByiJzGnlJzH1rVdNEuE= github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.2 h1:HHppQ5ly03DFdZpuxiO2qHEbZ8uJHcZiRp37O9OfnCc= github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.2.0.20200717132200-7435e2abc9d1 h1:h8TtYDlIACXQ6LNJesvSHuxskaPUAX/nltvqp0Kp1vk= github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.2.0.20200717132200-7435e2abc9d1/go.mod h1:aWg/hVISyjdpUOt89SSrplxffuq8HPEnIWGyKDpDzCo= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.4 h1:GYkUL3zjrZgig9Gm+/61+YglzESJxXRDMp7qhJsh4j0= github.com/hashicorp/terraform-plugin-test v1.2.0 h1:AWFdqyfnOj04sxTdaAF57QqvW7XXrT8PseUHkbKsE8I= github.com/hashicorp/terraform-plugin-test v1.2.0/go.mod h1:QIJHYz8j+xJtdtLrFTlzQVC0ocr3rf/OjIpgZLK56Hs= github.com/hashicorp/terraform-plugin-test v1.4.4 h1:5Pvg9nESNFDnf6bafUYX5Qk15WaZtv0alxwOKiZo7vQ= diff --git a/main.go b/main.go index 8982b7f9..0ab9d87e 100644 --- a/main.go +++ b/main.go @@ -11,8 +11,13 @@ import ( func main() { debugMode := (os.Getenv("CODEFRESH_PLUGIN_DEBUG") != "") + // for terraform 0.13: export CODEFRESH_PLUGIN_ADDR="codefresh.io/app/codefresh" + providerAddr := os.Getenv("CODEFRESH_PLUGIN_ADDR") + if providerAddr == "" { + providerAddr = "registry.terraform.io/-/codefresh" + } if debugMode { - err := plugin.Debug(context.Background(), "registry.terraform.io/-/codefresh", + err := plugin.Debug(context.Background(), providerAddr, &plugin.ServeOpts{ ProviderFunc: codefresh.Provider, })