From ea1a6a2f732d5f3c282efe137abdd7576edc5b41 Mon Sep 17 00:00:00 2001 From: Paul Otto Date: Wed, 25 Apr 2018 13:25:21 -0600 Subject: [PATCH 1/3] Fix gofmt issues for build. --- apigee/provider.go | 8 ++++---- apigee/resource_company.go | 10 +++++----- apigee/resource_company_app.go | 10 +++++----- apigee/resource_developer.go | 12 ++++++------ apigee/resource_developer_app.go | 12 ++++++------ apigee/resource_developer_app_test.go | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/apigee/provider.go b/apigee/provider.go index 6b666e7..142c787 100644 --- a/apigee/provider.go +++ b/apigee/provider.go @@ -39,10 +39,10 @@ func Provider() terraform.ResourceProvider { ResourcesMap: map[string]*schema.Resource{ "apigee_api_proxy": resourceApiProxy(), "apigee_api_proxy_deployment": resourceApiProxyDeployment(), - "apigee_company": resourceCompany(), - "apigee_company_app": resourceCompanyApp(), - "apigee_developer": resourceDeveloper(), - "apigee_developer_app": resourceDeveloperApp(), + "apigee_company": resourceCompany(), + "apigee_company_app": resourceCompanyApp(), + "apigee_developer": resourceDeveloper(), + "apigee_developer_app": resourceDeveloperApp(), "apigee_product": resourceProduct(), "apigee_target_server": resourceTargetServer(), }, diff --git a/apigee/resource_company.go b/apigee/resource_company.go index cba169a..6d671bb 100644 --- a/apigee/resource_company.go +++ b/apigee/resource_company.go @@ -157,12 +157,12 @@ func setCompanyData(d *schema.ResourceData) (apigee.Company, error) { } Company := apigee.Company{ - Name: d.Get("name").(string), - DisplayName: d.Get("display_name").(string), - Attributes: attributes, + Name: d.Get("name").(string), + DisplayName: d.Get("display_name").(string), + Attributes: attributes, - Apps: apps, - Status: d.Get("status").(string), + Apps: apps, + Status: d.Get("status").(string), } return Company, nil diff --git a/apigee/resource_company_app.go b/apigee/resource_company_app.go index 321757e..6fe8d48 100644 --- a/apigee/resource_company_app.go +++ b/apigee/resource_company_app.go @@ -178,11 +178,11 @@ func setCompanyAppData(d *schema.ResourceData) (apigee.CompanyApp, error) { } CompanyApp := apigee.CompanyApp{ - Name: d.Get("name").(string), - Attributes: attributes, - ApiProducts: apiProducts, - Scopes: scopes, - CallbackUrl: d.Get("callback_url").(string), + Name: d.Get("name").(string), + Attributes: attributes, + ApiProducts: apiProducts, + Scopes: scopes, + CallbackUrl: d.Get("callback_url").(string), } return CompanyApp, nil diff --git a/apigee/resource_developer.go b/apigee/resource_developer.go index 579286c..83da648 100644 --- a/apigee/resource_developer.go +++ b/apigee/resource_developer.go @@ -162,12 +162,12 @@ func setDeveloperData(d *schema.ResourceData) (apigee.Developer, error) { } Developer := apigee.Developer{ - Email: d.Get("email").(string), - FirstName: d.Get("first_name").(string), - LastName: d.Get("last_name").(string), - UserName: d.Get("user_name").(string), - Attributes: attributes, - Apps: apps, + Email: d.Get("email").(string), + FirstName: d.Get("first_name").(string), + LastName: d.Get("last_name").(string), + UserName: d.Get("user_name").(string), + Attributes: attributes, + Apps: apps, } return Developer, nil diff --git a/apigee/resource_developer_app.go b/apigee/resource_developer_app.go index 9230cfb..f0cfcd8 100644 --- a/apigee/resource_developer_app.go +++ b/apigee/resource_developer_app.go @@ -186,12 +186,12 @@ func setDeveloperAppData(d *schema.ResourceData) (apigee.DeveloperApp, error) { } DeveloperApp := apigee.DeveloperApp{ - Name: d.Get("name").(string), - Attributes: attributes, - ApiProducts: apiProducts, - KeyExpiresIn: d.Get("key_expires_in").(int), - Scopes: scopes, - CallbackUrl: d.Get("callback_url").(string), + Name: d.Get("name").(string), + Attributes: attributes, + ApiProducts: apiProducts, + KeyExpiresIn: d.Get("key_expires_in").(int), + Scopes: scopes, + CallbackUrl: d.Get("callback_url").(string), } return DeveloperApp, nil diff --git a/apigee/resource_developer_app_test.go b/apigee/resource_developer_app_test.go index d6a5c10..b2de75e 100644 --- a/apigee/resource_developer_app_test.go +++ b/apigee/resource_developer_app_test.go @@ -6,9 +6,9 @@ import ( "github.com/hashicorp/terraform/terraform" "github.com/zambien/go-apigee-edge" "log" + "regexp" "strings" "testing" - "regexp" ) func TestAccDeveloperApp_Updated(t *testing.T) { From 455f43dc3c21eb02bd6a06b6a2d8984f23503991 Mon Sep 17 00:00:00 2001 From: Paul Otto Date: Wed, 25 Apr 2018 14:46:19 -0600 Subject: [PATCH 2/3] Eliminate local import. Fix use of multi-value functions for modern Go strictness. Add Glide for vendoring. --- .gitignore | 3 ++- apigee/resource_api_proxy.go | 2 +- apigee/resource_api_proxy_deployment.go | 3 ++- apigee/resource_company.go | 2 +- apigee/resource_company_app.go | 2 +- apigee/resource_developer.go | 2 +- apigee/resource_developer_app.go | 2 +- apigee/resource_product.go | 2 +- apigee/resource_target_server.go | 2 +- glide.yaml | 10 ++++++++++ main.go | 2 +- 11 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 glide.yaml diff --git a/.gitignore b/.gitignore index bc83e5b..9a43fd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.iml .idea -terraform-provider-apigee* \ No newline at end of file +terraform-provider-apigee* +vendor \ No newline at end of file diff --git a/apigee/resource_api_proxy.go b/apigee/resource_api_proxy.go index d93c830..af3bb03 100644 --- a/apigee/resource_api_proxy.go +++ b/apigee/resource_api_proxy.go @@ -51,7 +51,7 @@ func resourceApiProxyCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() proxyRev, _, err := client.Proxies.Import(d.Get("name").(string), d.Get("bundle").(string)) diff --git a/apigee/resource_api_proxy_deployment.go b/apigee/resource_api_proxy_deployment.go index 16122f1..499a910 100644 --- a/apigee/resource_api_proxy_deployment.go +++ b/apigee/resource_api_proxy_deployment.go @@ -125,7 +125,8 @@ func resourceApiProxyDeploymentCreate(d *schema.ResourceData, meta interface{}) } } - d.SetId(uuid.NewV4().String()) + id, _ := uuid.NewV4() + d.SetId(id.String()) d.Set("revision", proxyDep.Revision.String()) return resourceApiProxyDeploymentRead(d, meta) diff --git a/apigee/resource_company.go b/apigee/resource_company.go index 6d671bb..5bf7998 100644 --- a/apigee/resource_company.go +++ b/apigee/resource_company.go @@ -50,7 +50,7 @@ func resourceCompanyCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() d.SetId(u1.String()) CompanyData, err := setCompanyData(d) diff --git a/apigee/resource_company_app.go b/apigee/resource_company_app.go index 6fe8d48..e425df1 100644 --- a/apigee/resource_company_app.go +++ b/apigee/resource_company_app.go @@ -63,7 +63,7 @@ func resourceCompanyAppCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() d.SetId(u1.String()) CompanyAppData, err := setCompanyAppData(d) diff --git a/apigee/resource_developer.go b/apigee/resource_developer.go index 83da648..e00d9ff 100644 --- a/apigee/resource_developer.go +++ b/apigee/resource_developer.go @@ -61,7 +61,7 @@ func resourceDeveloperCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() d.SetId(u1.String()) DeveloperData, err := setDeveloperData(d) diff --git a/apigee/resource_developer_app.go b/apigee/resource_developer_app.go index f0cfcd8..14068c4 100644 --- a/apigee/resource_developer_app.go +++ b/apigee/resource_developer_app.go @@ -71,7 +71,7 @@ func resourceDeveloperAppCreate(d *schema.ResourceData, meta interface{}) error client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() d.SetId(u1.String()) DeveloperAppData, err := setDeveloperAppData(d) diff --git a/apigee/resource_product.go b/apigee/resource_product.go index 7fb5855..4e34712 100644 --- a/apigee/resource_product.go +++ b/apigee/resource_product.go @@ -76,7 +76,7 @@ func resourceProductCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() d.SetId(u1.String()) ProductData, err := setProductData(d) diff --git a/apigee/resource_target_server.go b/apigee/resource_target_server.go index 636631c..0d04ddd 100644 --- a/apigee/resource_target_server.go +++ b/apigee/resource_target_server.go @@ -94,7 +94,7 @@ func resourceTargetServerCreate(d *schema.ResourceData, meta interface{}) error client := meta.(*apigee.EdgeClient) - u1 := uuid.NewV4() + u1, _ := uuid.NewV4() d.SetId(u1.String()) targetServerData, err := setTargetServerData(d) diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 0000000..fdcef46 --- /dev/null +++ b/glide.yaml @@ -0,0 +1,10 @@ +package: github.com/zambien/terraform-provider-apigee +import: +- package: github.com/hashicorp/terraform + subpackages: + - helper/schema + - plugin + - terraform +- package: github.com/satori/go.uuid +- package: github.com/zambien/go-apigee-edge +- package: github.com/bgentry/go-netrc/netrc diff --git a/main.go b/main.go index 619f191..11c0b63 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,9 @@ package main import ( - "./apigee" "github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/terraform" + "github.com/zambien/terraform-provider-apigee/apigee" ) func main() { From b17a93767e499a9172ba59ffcbadef0b10a015f3 Mon Sep 17 00:00:00 2001 From: Paul Otto Date: Wed, 25 Apr 2018 15:14:33 -0600 Subject: [PATCH 3/3] Update makefile to use Glide. Add static linking with non CGO and non debug linking. --- GNUmakefile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index c3d4fb0..c897d51 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,8 +3,17 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) default: build -build: fmtcheck - go install +build: vendor fmtcheck + @rm -rf build/ + @mkdir -p build/ + CGO_ENABLED=0 go build -ldflags '-w -extldflags "-static"' -o build/terraform-provider-apigee + +GLIDE := $(shell command -v glide 2> /dev/null) +ifndef GLIDE +$(error "glide is not available. Install using `curl https://glide.sh/get | sh`") +endif +vendor: glide.yaml ## Install vendor dependencies + glide update --no-recursive test: fmtcheck go test -i $(TEST) || exit 1 @@ -32,9 +41,6 @@ fmtcheck: errcheck: @sh -c "'$(CURDIR)/scripts/errcheck.sh'" -vendor-status: - @govendor status - test-compile: @if [ "$(TEST)" = "./..." ]; then \ echo "ERROR: Set TEST to a specific package. For example,"; \ @@ -43,4 +49,4 @@ test-compile: fi go test -c $(TEST) $(TESTARGS) -.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile +.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile