From 8b2683f854fcb1f8220730974f2dd98ffd6512a0 Mon Sep 17 00:00:00 2001 From: Adam Boscarino Date: Thu, 10 Jun 2021 19:14:23 +0000 Subject: [PATCH 1/3] move to official sdk and 4.0 api --- VERSION | 2 +- docs/index.md | 2 +- docs/resources/child_space.md | 31 -- docs/resources/connection.md | 54 ---- docs/resources/content_metadata_access.md | 40 --- docs/resources/git_deploy_key.md | 36 --- docs/resources/group.md | 5 +- docs/resources/main_space.md | 42 --- docs/resources/permission_set.md | 4 +- docs/resources/project.md | 32 -- docs/resources/project_git_details.md | 27 -- docs/resources/role.md | 8 +- docs/resources/role_groups.md | 7 +- docs/resources/user.md | 5 + docs/resources/user_api_key.md | 41 --- docs/resources/user_email.md | 27 -- docs/resources/user_roles.md | 6 +- .../resources/looker_connection/resource.tf | 14 - .../resource.tf | 5 - .../looker_git_deploy_key/resource.tf | 3 - examples/resources/looker_group/resource.tf | 5 +- .../resources/looker_main_space/resource.tf | 5 - .../looker_permission_set/resource.tf | 4 +- examples/resources/looker_project/resource.tf | 3 - examples/resources/looker_role/resource.tf | 4 +- .../resources/looker_role_groups/resource.tf | 7 +- examples/resources/looker_user/resource.tf | 1 + .../resources/looker_user_api_key/resource.tf | 8 - .../resources/looker_user_roles/resource.tf | 4 +- go.mod | 6 +- go.sum | 13 + pkg/looker/helper.go | 54 ---- pkg/looker/provider.go | 64 ++-- pkg/looker/resource_child_space.go | 179 ----------- pkg/looker/resource_connection.go | 248 ---------------- .../resource_content_metadata_access.go | 240 --------------- pkg/looker/resource_git_deploy_key.go | 130 -------- pkg/looker/resource_group.go | 87 ++---- pkg/looker/resource_main_space.go | 280 ------------------ pkg/looker/resource_model_set.go | 97 ++---- pkg/looker/resource_permission_set.go | 95 ++---- pkg/looker/resource_project.go | 167 ----------- pkg/looker/resource_project_git_details.go | 156 ---------- pkg/looker/resource_role.go | 121 +++----- pkg/looker/resource_role_groups.go | 110 ++----- pkg/looker/resource_user.go | 130 ++++---- pkg/looker/resource_user_api_key.go | 184 ------------ pkg/looker/resource_user_attribute.go | 105 +++---- pkg/looker/resource_user_email.go | 159 ---------- pkg/looker/resource_user_roles.go | 105 +++---- templates/index.md.tmpl | 2 +- 51 files changed, 352 insertions(+), 2812 deletions(-) delete mode 100644 docs/resources/child_space.md delete mode 100644 docs/resources/connection.md delete mode 100644 docs/resources/content_metadata_access.md delete mode 100644 docs/resources/git_deploy_key.md delete mode 100644 docs/resources/main_space.md delete mode 100644 docs/resources/project.md delete mode 100644 docs/resources/project_git_details.md delete mode 100644 docs/resources/user_api_key.md delete mode 100644 docs/resources/user_email.md delete mode 100644 examples/resources/looker_connection/resource.tf delete mode 100644 examples/resources/looker_content_metadata_access/resource.tf delete mode 100644 examples/resources/looker_git_deploy_key/resource.tf delete mode 100644 examples/resources/looker_main_space/resource.tf delete mode 100644 examples/resources/looker_project/resource.tf delete mode 100644 examples/resources/looker_user_api_key/resource.tf delete mode 100644 pkg/looker/helper.go delete mode 100644 pkg/looker/resource_child_space.go delete mode 100644 pkg/looker/resource_connection.go delete mode 100644 pkg/looker/resource_content_metadata_access.go delete mode 100644 pkg/looker/resource_git_deploy_key.go delete mode 100644 pkg/looker/resource_main_space.go delete mode 100644 pkg/looker/resource_project.go delete mode 100644 pkg/looker/resource_project_git_details.go delete mode 100644 pkg/looker/resource_user_api_key.go delete mode 100644 pkg/looker/resource_user_email.go diff --git a/VERSION b/VERSION index 6c6aa7c..341cf11 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.2.0 \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index a9cb2e3..b742a75 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,7 +6,7 @@ description: Manage Looker with Terraform. # Looker Provider This is a terraform provider plugin for managing [Looker](https://www.looker.com/) accounts. -Coverage is focused on part of Looker related to access control. +Coverage is focused on the part of Looker related to access control. ## Example Provider Configuration diff --git a/docs/resources/child_space.md b/docs/resources/child_space.md deleted file mode 100644 index f5f7935..0000000 --- a/docs/resources/child_space.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_child_space Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_child_space (Resource) - - - - - - -## Schema - -### Required - -- **name** (String) -- **parent_id** (String) - -### Optional - -- **id** (String) The ID of this resource. - -### Read-Only - -- **content_metadata_id** (String) - - diff --git a/docs/resources/connection.md b/docs/resources/connection.md deleted file mode 100644 index 699aa5b..0000000 --- a/docs/resources/connection.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_connection Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_connection (Resource) - - - -## Example Usage - -```terraform -resource "looker_connection" "snowflake_connection" { - name = "snowflake" - dialect_name = "snowflake" - host = var.snowflake_host - port = "443" - database = "MY_DATABASE" - username = var.snowflake_username - password = var.snowflake_password - schema = "PUBLIC" - jdbc_additional_params = "account=${var.snowflake_account}&warehouse=LOAD_WH" - ssl = true - db_timezone = "UTC" - query_timezone = "UTC" -} -``` - - -## Schema - -### Required - -- **database** (String) -- **dialect_name** (String) -- **host** (String) -- **name** (String) -- **password** (String) -- **schema** (String) -- **username** (String) - -### Optional - -- **db_timezone** (String) -- **id** (String) The ID of this resource. -- **jdbc_additional_params** (String) -- **port** (String) -- **query_timezone** (String) -- **ssl** (Boolean) - - diff --git a/docs/resources/content_metadata_access.md b/docs/resources/content_metadata_access.md deleted file mode 100644 index 43ad8c7..0000000 --- a/docs/resources/content_metadata_access.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_content_metadata_access Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_content_metadata_access (Resource) - - - -## Example Usage - -```terraform -resource "looker_content_metadata_access" "embed_groups_space_access" { - group_id = looker_group.embed_group.id - content_metadata_id = looker_main_space.my_shared_space.content_metadata_id - permission_type = "view" -} -``` - - -## Schema - -### Required - -- **content_metadata_id** (String) -- **group_id** (String) -- **permission_type** (String) - -### Optional - -- **id** (String) The ID of this resource. - -### Read-Only - -- **content_metadata_access_id** (String) - - diff --git a/docs/resources/git_deploy_key.md b/docs/resources/git_deploy_key.md deleted file mode 100644 index ae28a34..0000000 --- a/docs/resources/git_deploy_key.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_git_deploy_key Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_git_deploy_key (Resource) - - - -## Example Usage - -```terraform -resource "looker_project" "my_project" { - name = "My_Project_Name" -} -``` - - -## Schema - -### Required - -- **project_id** (String) - -### Optional - -- **id** (String) The ID of this resource. - -### Read-Only - -- **ssh_deploy_key** (String) - - diff --git a/docs/resources/group.md b/docs/resources/group.md index c39a3dc..e19be66 100644 --- a/docs/resources/group.md +++ b/docs/resources/group.md @@ -13,9 +13,8 @@ description: |- ## Example Usage ```terraform -resource "looker_role_groups" "embed_role_groups" { - role_id = looker_role.embed_role.id - group_ids = ["${looker_group.embed_group.id}"] +resource "looker_group" "group" { + name = "MyGroup" } ``` diff --git a/docs/resources/main_space.md b/docs/resources/main_space.md deleted file mode 100644 index 545dbbf..0000000 --- a/docs/resources/main_space.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_main_space Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_main_space (Resource) - - - -## Example Usage - -```terraform -resource "looker_main_space" "my_shared_space" { - name = "My Shared Space" - parent_space_name = "Embed Groups" - content_metadata_inherits = false -} -``` - - -## Schema - -### Required - -- **content_metadata_inherits** (Boolean) -- **name** (String) -- **parent_space_name** (String) - -### Optional - -- **id** (String) The ID of this resource. - -### Read-Only - -- **content_metadata_id** (String) -- **parent_content_metadata_id** (String) -- **parent_id** (String) - - diff --git a/docs/resources/permission_set.md b/docs/resources/permission_set.md index ba65699..a2fd84f 100644 --- a/docs/resources/permission_set.md +++ b/docs/resources/permission_set.md @@ -13,8 +13,8 @@ description: |- ## Example Usage ```terraform -resource "looker_permission_set" "embed_permission_set" { - name = "Embed Permission Set" +resource "looker_permission_set" "permission_set" { + name = "Permission Set" permissions = ["access_data", "download_with_limit", "schedule_look_emails", "schedule_external_look_emails", "see_user_dashboards"] } ``` diff --git a/docs/resources/project.md b/docs/resources/project.md deleted file mode 100644 index ed90290..0000000 --- a/docs/resources/project.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_project Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_project (Resource) - - - -## Example Usage - -```terraform -resource "looker_git_deploy_key" "project_git_deploy_key" { - project_id = looker_project.my_project.id -} -``` - - -## Schema - -### Required - -- **name** (String) - -### Optional - -- **id** (String) The ID of this resource. - - diff --git a/docs/resources/project_git_details.md b/docs/resources/project_git_details.md deleted file mode 100644 index ea46790..0000000 --- a/docs/resources/project_git_details.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_project_git_details Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_project_git_details (Resource) - - - - - - -## Schema - -### Required - -- **git_remote_url** (String) -- **project_id** (String) - -### Optional - -- **id** (String) The ID of this resource. - - diff --git a/docs/resources/role.md b/docs/resources/role.md index 3034a5f..f35008d 100644 --- a/docs/resources/role.md +++ b/docs/resources/role.md @@ -13,8 +13,8 @@ description: |- ## Example Usage ```terraform -resource "looker_role" "embed_role" { - name = "Embed User Role" +resource "looker_role" "role" { + name = "Role" permission_set_id = looker_permission_set.embed_permission_set.id model_set_id = looker_model_set.model_set.id } @@ -25,9 +25,9 @@ resource "looker_role" "embed_role" { ### Required -- **model_set_id** (String) +- **model_set_id** (Number) - **name** (String) -- **permission_set_id** (String) +- **permission_set_id** (Number) ### Optional diff --git a/docs/resources/role_groups.md b/docs/resources/role_groups.md index c8f0446..3e232f6 100644 --- a/docs/resources/role_groups.md +++ b/docs/resources/role_groups.md @@ -13,10 +13,9 @@ description: |- ## Example Usage ```terraform -resource "looker_role" "embed_role" { - name = "Embed User Role" - permission_set_id = looker_permission_set.embed_permission_set.id - model_set_id = looker_model_set.model_set.id +resource "looker_role_groups" "role_groups" { + role_id = looker_role.embed_role.id + group_ids = ["${looker_group.embed_group.id}"] } ``` diff --git a/docs/resources/user.md b/docs/resources/user.md index 8cf8845..1cec9e3 100644 --- a/docs/resources/user.md +++ b/docs/resources/user.md @@ -14,6 +14,7 @@ description: |- ```terraform resource "looker_user" "user" { + email = "user@email.com" first_name = "Reporting" last_name = "API User" } @@ -22,6 +23,10 @@ resource "looker_user" "user" { ## Schema +### Required + +- **email** (String) + ### Optional - **first_name** (String) diff --git a/docs/resources/user_api_key.md b/docs/resources/user_api_key.md deleted file mode 100644 index ff45048..0000000 --- a/docs/resources/user_api_key.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_user_api_key Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_user_api_key (Resource) - - - -## Example Usage - -```terraform -resource "looker_user_api_key" "user_api_key" { - user_id = looker_user.user.id - - provisioner "local-exec" { - command = "google-chrome ${var.looker_base_url}/admin/users/api3_key/${self.user_id}" - on_failure = "continue" - } -} -``` - - -## Schema - -### Required - -- **user_id** (String) - -### Optional - -- **id** (String) The ID of this resource. - -### Read-Only - -- **client_id** (String) - - diff --git a/docs/resources/user_email.md b/docs/resources/user_email.md deleted file mode 100644 index 367bbbe..0000000 --- a/docs/resources/user_email.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "looker_user_email Resource - terraform-provider-looker" -subcategory: "" -description: |- - ---- - -# looker_user_email (Resource) - - - - - - -## Schema - -### Required - -- **email** (String) -- **user_id** (String) - -### Optional - -- **id** (String) The ID of this resource. - - diff --git a/docs/resources/user_roles.md b/docs/resources/user_roles.md index becacf3..99e08ba 100644 --- a/docs/resources/user_roles.md +++ b/docs/resources/user_roles.md @@ -14,8 +14,8 @@ description: |- ```terraform resource "looker_user_roles" "user_roles" { - user_id = looker_user.user.id - role_names = ["Admin"] + user_id = looker_user.user.id + role_ids = [looker_role.role.id] } ``` @@ -24,7 +24,7 @@ resource "looker_user_roles" "user_roles" { ### Required -- **role_names** (Set of String) +- **role_ids** (Set of Number) - **user_id** (String) ### Optional diff --git a/examples/resources/looker_connection/resource.tf b/examples/resources/looker_connection/resource.tf deleted file mode 100644 index a28cbe4..0000000 --- a/examples/resources/looker_connection/resource.tf +++ /dev/null @@ -1,14 +0,0 @@ -resource "looker_connection" "snowflake_connection" { - name = "snowflake" - dialect_name = "snowflake" - host = var.snowflake_host - port = "443" - database = "MY_DATABASE" - username = var.snowflake_username - password = var.snowflake_password - schema = "PUBLIC" - jdbc_additional_params = "account=${var.snowflake_account}&warehouse=LOAD_WH" - ssl = true - db_timezone = "UTC" - query_timezone = "UTC" -} diff --git a/examples/resources/looker_content_metadata_access/resource.tf b/examples/resources/looker_content_metadata_access/resource.tf deleted file mode 100644 index 7e32f62..0000000 --- a/examples/resources/looker_content_metadata_access/resource.tf +++ /dev/null @@ -1,5 +0,0 @@ -resource "looker_content_metadata_access" "embed_groups_space_access" { - group_id = looker_group.embed_group.id - content_metadata_id = looker_main_space.my_shared_space.content_metadata_id - permission_type = "view" -} diff --git a/examples/resources/looker_git_deploy_key/resource.tf b/examples/resources/looker_git_deploy_key/resource.tf deleted file mode 100644 index 9fde8bb..0000000 --- a/examples/resources/looker_git_deploy_key/resource.tf +++ /dev/null @@ -1,3 +0,0 @@ -resource "looker_project" "my_project" { - name = "My_Project_Name" -} diff --git a/examples/resources/looker_group/resource.tf b/examples/resources/looker_group/resource.tf index fb351c9..9f183cb 100644 --- a/examples/resources/looker_group/resource.tf +++ b/examples/resources/looker_group/resource.tf @@ -1,4 +1,3 @@ -resource "looker_role_groups" "embed_role_groups" { - role_id = looker_role.embed_role.id - group_ids = ["${looker_group.embed_group.id}"] +resource "looker_group" "group" { + name = "MyGroup" } diff --git a/examples/resources/looker_main_space/resource.tf b/examples/resources/looker_main_space/resource.tf deleted file mode 100644 index 0ff9871..0000000 --- a/examples/resources/looker_main_space/resource.tf +++ /dev/null @@ -1,5 +0,0 @@ -resource "looker_main_space" "my_shared_space" { - name = "My Shared Space" - parent_space_name = "Embed Groups" - content_metadata_inherits = false -} diff --git a/examples/resources/looker_permission_set/resource.tf b/examples/resources/looker_permission_set/resource.tf index 46daf4c..a4f918d 100644 --- a/examples/resources/looker_permission_set/resource.tf +++ b/examples/resources/looker_permission_set/resource.tf @@ -1,4 +1,4 @@ -resource "looker_permission_set" "embed_permission_set" { - name = "Embed Permission Set" +resource "looker_permission_set" "permission_set" { + name = "Permission Set" permissions = ["access_data", "download_with_limit", "schedule_look_emails", "schedule_external_look_emails", "see_user_dashboards"] } diff --git a/examples/resources/looker_project/resource.tf b/examples/resources/looker_project/resource.tf deleted file mode 100644 index a90d325..0000000 --- a/examples/resources/looker_project/resource.tf +++ /dev/null @@ -1,3 +0,0 @@ -resource "looker_git_deploy_key" "project_git_deploy_key" { - project_id = looker_project.my_project.id -} diff --git a/examples/resources/looker_role/resource.tf b/examples/resources/looker_role/resource.tf index fa7f75f..5700adf 100644 --- a/examples/resources/looker_role/resource.tf +++ b/examples/resources/looker_role/resource.tf @@ -1,5 +1,5 @@ -resource "looker_role" "embed_role" { - name = "Embed User Role" +resource "looker_role" "role" { + name = "Role" permission_set_id = looker_permission_set.embed_permission_set.id model_set_id = looker_model_set.model_set.id } diff --git a/examples/resources/looker_role_groups/resource.tf b/examples/resources/looker_role_groups/resource.tf index fa7f75f..3a95142 100644 --- a/examples/resources/looker_role_groups/resource.tf +++ b/examples/resources/looker_role_groups/resource.tf @@ -1,5 +1,4 @@ -resource "looker_role" "embed_role" { - name = "Embed User Role" - permission_set_id = looker_permission_set.embed_permission_set.id - model_set_id = looker_model_set.model_set.id +resource "looker_role_groups" "role_groups" { + role_id = looker_role.embed_role.id + group_ids = ["${looker_group.embed_group.id}"] } diff --git a/examples/resources/looker_user/resource.tf b/examples/resources/looker_user/resource.tf index 0935d08..fb3dbc2 100644 --- a/examples/resources/looker_user/resource.tf +++ b/examples/resources/looker_user/resource.tf @@ -1,4 +1,5 @@ resource "looker_user" "user" { + email = "user@email.com" first_name = "Reporting" last_name = "API User" } diff --git a/examples/resources/looker_user_api_key/resource.tf b/examples/resources/looker_user_api_key/resource.tf deleted file mode 100644 index fda3651..0000000 --- a/examples/resources/looker_user_api_key/resource.tf +++ /dev/null @@ -1,8 +0,0 @@ -resource "looker_user_api_key" "user_api_key" { - user_id = looker_user.user.id - - provisioner "local-exec" { - command = "google-chrome ${var.looker_base_url}/admin/users/api3_key/${self.user_id}" - on_failure = "continue" - } -} diff --git a/examples/resources/looker_user_roles/resource.tf b/examples/resources/looker_user_roles/resource.tf index 53e1e95..b9fad27 100644 --- a/examples/resources/looker_user_roles/resource.tf +++ b/examples/resources/looker_user_roles/resource.tf @@ -1,4 +1,4 @@ resource "looker_user_roles" "user_roles" { - user_id = looker_user.user.id - role_names = ["Admin"] + user_id = looker_user.user.id + role_ids = [looker_role.role.id] } diff --git a/go.mod b/go.mod index 6db7492..552af07 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,10 @@ go 1.15 require ( github.com/billtrust/looker-go-sdk v0.0.0-20190925193822-162d0cd95cb7 - github.com/go-openapi/runtime v0.19.28 - github.com/go-openapi/strfmt v0.20.1 + github.com/go-openapi/runtime v0.19.28 // indirect + github.com/go-openapi/strfmt v0.20.1 // indirect github.com/hashicorp/terraform-plugin-docs v0.4.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.4 + github.com/looker-open-source/sdk-codegen/go v0.0.1 + github.com/smartystreets/goconvey v1.6.4 // indirect ) diff --git a/go.sum b/go.sum index 00ba845..337bd9b 100644 --- a/go.sum +++ b/go.sum @@ -271,6 +271,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= @@ -341,6 +343,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= @@ -361,6 +365,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/looker-open-source/sdk-codegen/go v0.0.1 h1:4urA2OZ3Z9YRwINNJ2wjaZqMHwD5114RJQT5tWX0gvw= +github.com/looker-open-source/sdk-codegen/go v0.0.1/go.mod h1:JxOlImdS7EdABZUGACwR1U0GBA/QolfXAqTPoo7fPfs= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -437,6 +443,10 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -637,6 +647,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -764,6 +775,8 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8X gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.61.0 h1:LBCdW4FmFYL4s/vDZD1RQYX7oAR6IjujCYgMdbHBR10= +gopkg.in/ini.v1 v1.61.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/looker/helper.go b/pkg/looker/helper.go deleted file mode 100644 index beae221..0000000 --- a/pkg/looker/helper.go +++ /dev/null @@ -1,54 +0,0 @@ -package looker - -import ( - "strconv" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/client/role" - "github.com/billtrust/looker-go-sdk/client/session" - "github.com/billtrust/looker-go-sdk/models" -) - -func updateSession(client *apiclient.LookerAPI30Reference, mode string) error { - params := session.NewUpdateSessionParams() - params.Body = &models.APISession{} - params.Body.WorkspaceID = mode - - _, err := client.Session.UpdateSession(params) - if err != nil { - return err - } - - return nil -} - -func getRoleIds(roleNames []string, client *apiclient.LookerAPI30Reference) ([]int64, error) { - rolesOK, err := client.Role.AllRoles(role.NewAllRolesParams()) - if err != nil { - return nil, err - } - - roleIds := []int64{} - for _, roleName := range roleNames { - for _, role := range rolesOK.Payload { - if role.Name == roleName { - roleIds = append(roleIds, role.ID) - } - } - } - - return roleIds, nil -} - -func getIDFromString(id string) (int64, error) { - i, err := strconv.ParseInt(id, 10, 64) - if err != nil { - return 0, err - } - - return i, nil -} - -func getStringFromID(i int64) string { - return strconv.FormatInt(i, 10) -} diff --git a/pkg/looker/provider.go b/pkg/looker/provider.go index 3de06e3..b46bb00 100644 --- a/pkg/looker/provider.go +++ b/pkg/looker/provider.go @@ -1,15 +1,9 @@ package looker import ( - "log" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/client/api_auth" - - "github.com/go-openapi/strfmt" - - httptransport "github.com/go-openapi/runtime/client" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/looker-open-source/sdk-codegen/go/rtl" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func Provider() *schema.Provider { @@ -35,23 +29,14 @@ func Provider() *schema.Provider { }, }, ResourcesMap: map[string]*schema.Resource{ - "looker_user": resourceUser(), - "looker_user_email": resourceUserEmail(), - "looker_user_roles": resourceUserRoles(), - "looker_user_api_key": resourceUserAPIKey(), - "looker_permission_set": resourcePermissionSet(), - "looker_model_set": resourceModelSet(), - "looker_group": resourceGroup(), - "looker_role": resourceRole(), - "looker_role_groups": resourceRoleGroups(), - "looker_main_space": resourceMainSpace(), - "looker_child_space": resourceChildSpace(), - "looker_content_metadata_access": resourceContentMetadataAccess(), - "looker_connection": resourceConnection(), - "looker_project": resourceProject(), - "looker_git_deploy_key": resourceGitDeployKey(), - "looker_project_git_details": resourceProjectGitDetails(), - "looker_user_attribute": resourceUserAttribute(), + "looker_user": resourceUser(), + "looker_user_roles": resourceUserRoles(), + "looker_permission_set": resourcePermissionSet(), + "looker_model_set": resourceModelSet(), + "looker_group": resourceGroup(), + "looker_role": resourceRole(), + "looker_role_groups": resourceRoleGroups(), + "looker_user_attribute": resourceUserAttribute(), }, ConfigureFunc: providerConfigure, @@ -59,29 +44,18 @@ func Provider() *schema.Provider { } func providerConfigure(d *schema.ResourceData) (interface{}, error) { - transport := httptransport.New(d.Get("base_url").(string), "/api/3.0/", nil) - client := apiclient.New(transport, strfmt.Default) - + baseUrl := d.Get("base_url").(string) clientID := d.Get("client_id").(string) clientSecret := d.Get("client_secret").(string) - pd := api_auth.NewLoginParams() - pd.ClientID = &clientID - pd.ClientSecret = &clientSecret - - resp, err := client.APIAuth.Login(pd) - - if err != nil { - return nil, err + apiSettings := rtl.ApiSettings{ + BaseUrl: baseUrl, + ClientId: clientID, + ClientSecret: clientSecret, + ApiVersion: "4.0", } + authSession := rtl.NewAuthSession(apiSettings) + client := apiclient.NewLookerSDK(authSession) - token := resp.Payload.AccessToken - log.Println("[INFO] token " + token) - - authInfoWriter := httptransport.APIKeyAuth("Authorization", "header", "token "+token) - transport.DefaultAuthentication = authInfoWriter - - authClient := apiclient.New(transport, strfmt.Default) - - return authClient, nil + return client, nil } diff --git a/pkg/looker/resource_child_space.go b/pkg/looker/resource_child_space.go deleted file mode 100644 index 62c7d25..0000000 --- a/pkg/looker/resource_child_space.go +++ /dev/null @@ -1,179 +0,0 @@ -package looker - -import ( - "log" - "strings" - - "github.com/billtrust/looker-go-sdk/client/space" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceChildSpace() *schema.Resource { - return &schema.Resource{ - Create: resourceChildSpaceCreate, - Read: resourceChildSpaceRead, - Update: resourceChildSpaceUpdate, - Delete: resourceChildSpaceDelete, - Exists: resourceChildSpaceExists, - Importer: &schema.ResourceImporter{ - State: resourceChildSpaceImport, - }, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - "parent_id": { - Type: schema.TypeString, - Required: true, - }, - "content_metadata_id": { - Type: schema.TypeString, - Computed: true, - }, - }, - } -} - -func getChildSpaceByID(d *schema.ResourceData, m interface{}, id int64) (*models.Space, error) { - client := m.(*apiclient.LookerAPI30Reference) - - params := space.NewSpaceParams() - params.SpaceID = id - - result, err := client.Space.Space(params) - if err != nil { - log.Printf("[ERROR] Error while getting space by id, %s", err.Error()) - return nil, err - } - - return result.Payload, nil -} - -func resourceChildSpaceCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - parentID, err := getIDFromString(d.Get("parent_id").(string)) - if err != nil { - return err - } - - params := space.NewCreateSpaceParams() - params.Body = &models.Space{} - params.Body.Name = d.Get("name").(string) - params.Body.ParentID = &parentID - - result, err := client.Space.CreateSpace(params) - if err != nil { - return err - } - - d.SetId(getStringFromID(result.Payload.ID)) - - return resourceChildSpaceRead(d, m) -} - -func resourceChildSpaceRead(d *schema.ResourceData, m interface{}) error { - ID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - space, err := getChildSpaceByID(d, m, ID) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("name", space.Name); err != nil { - return err - } - if err = d.Set("content_metadata_id", getStringFromID(space.ContentMetadataID)); err != nil { - return err - } - if err = d.Set("parent_id", getStringFromID(*space.ParentID)); err != nil { - return err - } - - return nil -} - -func resourceChildSpaceUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - parentID, err := getIDFromString(d.Get("parent_id").(string)) - if err != nil { - return err - } - - params := space.NewUpdateSpaceParams() - params.SpaceID = ID - params.Body = &models.Space{} - params.Body.Name = d.Get("name").(string) - params.Body.ParentID = &parentID - - _, err = client.Space.UpdateSpace(params) - if err != nil { - return err - } - - return resourceChildSpaceRead(d, m) -} - -func resourceChildSpaceDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - params := space.NewDeleteSpaceParams() - params.SpaceID = ID - - _, err = client.Space.DeleteSpace(params) - if err != nil { - return err - } - - return nil -} - -func resourceChildSpaceExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - _, err = getChildSpaceByID(d, m, ID) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceChildSpaceImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceChildSpaceRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_connection.go b/pkg/looker/resource_connection.go deleted file mode 100644 index a2d2904..0000000 --- a/pkg/looker/resource_connection.go +++ /dev/null @@ -1,248 +0,0 @@ -package looker - -import ( - "fmt" - "strings" - - "github.com/billtrust/looker-go-sdk/client/connection" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceConnection() *schema.Resource { - return &schema.Resource{ - Create: resourceConnectionCreate, - Read: resourceConnectionRead, - Update: resourceConnectionUpdate, - Delete: resourceConnectionDelete, - Exists: resourceConnectionExists, - Importer: &schema.ResourceImporter{ - State: resourceConnectionImport, - }, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, // todo: the ID is the name of the connection so if it changes i think it would require a new object be created. I should verify this - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - return strings.EqualFold(old, new) - }, - ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { - v := val.(string) - if strings.Contains(v, " ") { - errs = append(errs, fmt.Errorf("%q must not contain any spaces, got: %q", key, v)) - } - return - }, - }, - "dialect_name": { - Type: schema.TypeString, - Required: true, - }, - "host": { - Type: schema.TypeString, - Required: true, - }, - "port": { - Type: schema.TypeString, - Optional: true, - Default: "443", - }, - "database": { - Type: schema.TypeString, - Required: true, - }, - "username": { - Type: schema.TypeString, - Required: true, - }, - "password": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - // TODO: not sure how to handle this scenario. The terraform sets the password for the connection on create, but this value is not returned on get - // TODO: to handle this, DiffSupressFunc always say this field is not changed to handle this. And if the user changes the field, ForceNew should create a new one - return d.Id() != "" - }, - }, - "schema": { - Type: schema.TypeString, - Required: true, - }, - "jdbc_additional_params": { - Type: schema.TypeString, - Optional: true, - Default: "", - }, - "ssl": { - Type: schema.TypeBool, - Optional: true, - Default: true, - }, - "db_timezone": { - Type: schema.TypeString, - Optional: true, - }, - "query_timezone": { - Type: schema.TypeString, - Optional: true, - }, - }, - } -} - -func resourceConnectionCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := connection.NewCreateConnectionParams() - params.Body = &models.DBConnection{} - params.Body.Name = d.Get("name").(string) - params.Body.DialectName = d.Get("dialect_name").(string) - params.Body.Host = d.Get("host").(string) - params.Body.Port = d.Get("port").(string) - params.Body.Database = d.Get("database").(string) - params.Body.Username = d.Get("username").(string) - params.Body.Password = d.Get("password").(string) - params.Body.Schema = d.Get("schema").(string) - params.Body.JdbcAdditionalParams = d.Get("jdbc_additional_params").(string) - params.Body.Ssl = d.Get("ssl").(bool) - params.Body.DbTimezone = d.Get("db_timezone").(string) - params.Body.QueryTimezone = d.Get("query_timezone").(string) - - result, err := client.Connection.CreateConnection(params) - if err != nil { - return err - } - - d.SetId(result.Payload.Name) - - return resourceConnectionRead(d, m) -} - -func resourceConnectionRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := connection.NewConnectionParams() - params.ConnectionName = d.Id() - - result, err := client.Connection.Connection(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - - return err - } - - if err = d.Set("name", result.Payload.Name); err != nil { - return err - } - if err = d.Set("dialect_name", result.Payload.DialectName); err != nil { - return err - } - if err = d.Set("host", result.Payload.Host); err != nil { - return err - } - if err = d.Set("port", result.Payload.Port); err != nil { - return err - } - if err = d.Set("database", result.Payload.Database); err != nil { - return err - } - if err = d.Set("username", result.Payload.Username); err != nil { - return err - } - if err = d.Set("password", result.Payload.Password); err != nil { - return err - } - if err = d.Set("schema", result.Payload.Schema); err != nil { - return err - } - if err = d.Set("jdbc_additional_params", result.Payload.JdbcAdditionalParams); err != nil { - return err - } - if err = d.Set("ssl", result.Payload.Ssl); err != nil { - return err - } - if err = d.Set("db_timezone", result.Payload.DbTimezone); err != nil { - return err - } - if err = d.Set("query_timezone", result.Payload.QueryTimezone); err != nil { - return err - } - - return nil -} - -func resourceConnectionUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := connection.NewUpdateConnectionParams() - params.ConnectionName = d.Get("name").(string) - params.Body = &models.DBConnection{} - params.Body.Name = d.Get("name").(string) - params.Body.DialectName = d.Get("dialect_name").(string) - params.Body.Host = d.Get("host").(string) - params.Body.Port = d.Get("port").(string) - params.Body.Database = d.Get("database").(string) - params.Body.Username = d.Get("username").(string) - params.Body.Password = d.Get("password").(string) - params.Body.Schema = d.Get("schema").(string) - params.Body.JdbcAdditionalParams = d.Get("jdbc_additional_params").(string) - params.Body.Ssl = d.Get("ssl").(bool) - params.Body.DbTimezone = d.Get("db_timezone").(string) - params.Body.QueryTimezone = d.Get("query_timezone").(string) - - _, err := client.Connection.UpdateConnection(params) - if err != nil { - return err - } - - return resourceConnectionRead(d, m) -} - -func resourceConnectionDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := connection.NewDeleteConnectionParams() - params.ConnectionName = d.Id() - - _, err := client.Connection.DeleteConnection(params) - if err != nil { - return err - } - - return nil -} - -func resourceConnectionExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - params := connection.NewConnectionParams() - params.ConnectionName = d.Id() - - _, err := client.Connection.Connection(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceConnectionImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceConnectionRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_content_metadata_access.go b/pkg/looker/resource_content_metadata_access.go deleted file mode 100644 index 8726e24..0000000 --- a/pkg/looker/resource_content_metadata_access.go +++ /dev/null @@ -1,240 +0,0 @@ -package looker - -import ( - "fmt" - "log" - "strings" - "time" - - "github.com/billtrust/looker-go-sdk/client/content" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -// The GET resource for metadata content access does not exist, we need to search all the metadata content access for a specific contentmetadaid and than look for the group id. -// for this reason, i am setting the id to be "content_metadata_id:group_id", and have content_metadata_access_id be a computed field -// Since this is just access and nothing depends on it, I Am going to make this simpler by just implenting create, delete, read and skipping update -func resourceContentMetadataAccess() *schema.Resource { - return &schema.Resource{ - Create: resourceContentMetadataAccessCreate, - Read: resourceContentMetadataAccessRead, - Delete: resourceContentMetadataAccessDelete, - Exists: resourceContentMetadataAccessExists, - Importer: &schema.ResourceImporter{ - State: resourceContentMetadataAccessImport, - }, - - Schema: map[string]*schema.Schema{ - "content_metadata_access_id": { - Type: schema.TypeString, - Computed: true, - }, - "group_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "content_metadata_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "permission_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - } -} - -func getContentMetadataAccess(m interface{}, contentMetadataID int64, groupID int64) (*models.ContentMetaGroupUser, error) { - client := m.(*apiclient.LookerAPI30Reference) - - params := content.NewAllContentMetadataAccesssParams() - params.SetTimeout(time.Minute * 5) - params.ContentMetadataID = &contentMetadataID - - result, err := client.Content.AllContentMetadataAccesss(params) - if err != nil { - return nil, err - } - - for _, contentMetaGroupUser := range result.Payload { - if contentMetaGroupUser.GroupID == groupID { - return contentMetaGroupUser, nil - } - } - - return nil, fmt.Errorf("Content Metadata Access Not found") -} - -func resourceContentMetadataAccessCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - groupID, err := getIDFromString(d.Get("group_id").(string)) - if err != nil { - return err - } - - contentMetadataID, err := getIDFromString(d.Get("content_metadata_id").(string)) - if err != nil { - return err - } - - params := content.NewCreateContentMetadataAccessParams() - params.SetTimeout(time.Minute * 5) - params.Body = &models.ContentMetaGroupUser{} - params.Body.ContentMetadataID = contentMetadataID - params.Body.GroupID = groupID - params.Body.PermissionType = d.Get("permission_type").(string) - - result, err := client.Content.CreateContentMetadataAccess(params) - if err != nil { - if !strings.Contains(err.Error(), "already has access on content") { - return err - } - - access, err := getContentMetadataAccess(m, contentMetadataID, groupID) - if err != nil { - return err - } - - d.SetId(getStringFromID(access.ContentMetadataID) + ":" + getStringFromID(access.GroupID)) - } else { - d.SetId(getStringFromID(result.Payload.ContentMetadataID) + ":" + getStringFromID(result.Payload.GroupID)) - } - - return resourceContentMetadataAccessRead(d, m) -} - -func resourceContentMetadataAccessRead(d *schema.ResourceData, m interface{}) error { - id := strings.Split(d.Id(), ":") - if len(id) != 2 { - return fmt.Errorf("ID Should be two strings separated by a colon (:)") - } - - sContentMetadataID := id[0] - sGroupID := id[1] - - groupID, err := getIDFromString(sGroupID) - if err != nil { - return err - } - - contentMetadataID, err := getIDFromString(sContentMetadataID) - if err != nil { - return err - } - - access, err := getContentMetadataAccess(m, contentMetadataID, groupID) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("content_metadata_access_id", getStringFromID(access.ID)); err != nil { - return err - } - if err = d.Set("group_id", getStringFromID(access.GroupID)); err != nil { - return err - } - if err = d.Set("content_metadata_id", getStringFromID(access.ContentMetadataID)); err != nil { - return err - } - if err = d.Set("permission_type", access.PermissionType); err != nil { - return err - } - - return nil -} - -func resourceContentMetadataAccessDelete(d *schema.ResourceData, m interface{}) error { - id := strings.Split(d.Id(), ":") - if len(id) != 2 { - return fmt.Errorf("ID Should be two strings separated by a colon (:)") - } - - sContentMetadataID := id[0] - sGroupID := id[1] - - groupID, err := getIDFromString(sGroupID) - if err != nil { - return err - } - - contentMetadataID, err := getIDFromString(sContentMetadataID) - if err != nil { - return err - } - - access, err := getContentMetadataAccess(m, contentMetadataID, groupID) - if err != nil { - // if attempting to delete and it is already deleted say it was succesful - if strings.Contains(err.Error(), "Not found") { - return nil - } - return err - } - - client := m.(*apiclient.LookerAPI30Reference) - params := content.NewDeleteContentMetadataAccessParams() - params.SetTimeout(time.Minute * 5) - params.ContentMetadataAccessID = access.ID - - _, err = client.Content.DeleteContentMetadataAccess(params) - if err != nil { - // if the error is "Cannot remove access for [group_name] Group with edit on parent", I think the correct thing to do is ignore this error since the user already has edit on parent. - // When/if parent access is deleted, it deletes access on child (verified) - if strings.Contains(err.Error(), "with edit on parent") { - log.Printf("[WARN] Deleting access from child does not work since it is inherited from parent., %s", err.Error()) - return nil - } - return err - } - - return nil -} - -func resourceContentMetadataAccessExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - id := strings.Split(d.Id(), ":") - if len(id) != 2 { - return false, fmt.Errorf("ID Should be two strings separated by a colon (:)") - } - sContentMetadataID := id[0] - sGroupID := id[1] - - groupID, err := getIDFromString(sGroupID) - if err != nil { - return false, err - } - - contentMetadataID, err := getIDFromString(sContentMetadataID) - if err != nil { - return false, err - } - - _, err = getContentMetadataAccess(m, contentMetadataID, groupID) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - return false, err - } - - return true, nil -} - -func resourceContentMetadataAccessImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceContentMetadataAccessRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_git_deploy_key.go b/pkg/looker/resource_git_deploy_key.go deleted file mode 100644 index 39e21f2..0000000 --- a/pkg/looker/resource_git_deploy_key.go +++ /dev/null @@ -1,130 +0,0 @@ -package looker - -import ( - "strings" - - "github.com/billtrust/looker-go-sdk/client/project" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceGitDeployKey() *schema.Resource { - return &schema.Resource{ - Create: resourceGitDeployKeyCreate, - Read: resourceGitDeployKeyRead, - Delete: resourceGitDeployKeyDelete, - Exists: resourceGitDeployKeyExists, - Importer: &schema.ResourceImporter{ - State: resourceGitDeployKeyImport, - }, - - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "ssh_deploy_key": { - Type: schema.TypeString, - Computed: true, - }, - }, - } -} - -func resourceGitDeployKeyCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - err := updateSession(client, "dev") - if err != nil { - return err - } - - projectID := d.Get("project_id").(string) - params := project.NewCreateGitDeployKeyParams() - params.ProjectID = projectID - - _, err = client.Project.CreateGitDeployKey(params) - if err != nil { - return err - } - - d.SetId(projectID) - - return resourceGitDeployKeyRead(d, m) -} - -func resourceGitDeployKeyRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - err := updateSession(client, "dev") - if err != nil { - return err - } - - projectID := d.Id() - - params := project.NewGitDeployKeyParams() - params.ProjectID = projectID - - result, err := client.Project.GitDeployKey(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("project_id", projectID); err != nil { - return err - } - - // the payload is a string with 3 values separated by spaces. The first index contains "ssh-rsa", the second index includes the key, the third index contains the project id - // the project id doesn't appear to be part of the key though since when adding it to github, it is ignored it seems - sshKey := strings.Fields(result.Payload) - if err = d.Set("ssh_deploy_key", sshKey[0]+" "+sshKey[1]); err != nil { - return err - } - - return nil -} - -func resourceGitDeployKeyDelete(d *schema.ResourceData, m interface{}) error { - // TODO There is no way to delete a git deploy key, possibly put this into the project resource (but there is no way to delete project either) - return nil -} - -func resourceGitDeployKeyExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - // TODO Not sure if we should always set session to "dev" instead of "production" when checking if it exists? will dev always show all dev+prod projects? - err := updateSession(client, "dev") - if err != nil { - return false, err - } - - params := project.NewGitDeployKeyParams() - params.ProjectID = d.Id() - - _, err = client.Project.GitDeployKey(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceGitDeployKeyImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceGitDeployKeyRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_group.go b/pkg/looker/resource_group.go index d728ad7..6a970f5 100644 --- a/pkg/looker/resource_group.go +++ b/pkg/looker/resource_group.go @@ -1,14 +1,10 @@ package looker import ( - "strings" + "strconv" - "github.com/billtrust/looker-go-sdk/client/group" - - "github.com/billtrust/looker-go-sdk/models" - - apiclient "github.com/billtrust/looker-go-sdk/client" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceGroup() *schema.Resource { @@ -17,7 +13,6 @@ func resourceGroup() *schema.Resource { Read: resourceGroupRead, Update: resourceGroupUpdate, Delete: resourceGroupDelete, - Exists: resourceGroupExists, Importer: &schema.ResourceImporter{ State: resourceGroupImport, }, @@ -32,43 +27,38 @@ func resourceGroup() *schema.Resource { } func resourceGroupCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) + groupName := d.Get("name").(string) - params := group.NewCreateGroupParams() - params.Body = &models.Group{} - params.Body.Name = d.Get("name").(string) + writeGroup := apiclient.WriteGroup{ + Name: &groupName, + } - result, err := client.Group.CreateGroup(params) + group, err := client.CreateGroup(writeGroup, "", nil) if err != nil { return err } - d.SetId(getStringFromID(result.Payload.ID)) + groupID := *group.Id + d.SetId(strconv.Itoa(int(groupID))) return resourceGroupRead(d, m) } func resourceGroupRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + groupID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := group.NewGroupParams() - params.GroupID = ID - - result, err := client.Group.Group(params) + group, err := client.Group(groupID, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("name", result.Payload.Name); err != nil { + if err = d.Set("group", group.Name); err != nil { return err } @@ -76,19 +66,18 @@ func resourceGroupRead(d *schema.ResourceData, m interface{}) error { } func resourceGroupUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + groupID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := group.NewUpdateGroupParams() - params.GroupID = ID - params.Body = &models.Group{} - params.Body.Name = d.Get("name").(string) - - _, err = client.Group.UpdateGroup(params) + groupName := d.Get("name").(string) + writeGroup := apiclient.WriteGroup{ + Name: &groupName, + } + _, err = client.UpdateGroup(groupID, writeGroup, "", nil) if err != nil { return err } @@ -97,17 +86,14 @@ func resourceGroupUpdate(d *schema.ResourceData, m interface{}) error { } func resourceGroupDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + groupID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := group.NewDeleteGroupParams() - params.GroupID = ID - - _, err = client.Group.DeleteGroup(params) + _, err = client.DeleteGroup(groupID, nil) if err != nil { return err } @@ -115,31 +101,6 @@ func resourceGroupDelete(d *schema.ResourceData, m interface{}) error { return nil } -func resourceGroupExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := group.NewGroupParams() - params.GroupID = ID - - _, err = client.Group.Group(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourceGroupImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourceGroupRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_main_space.go b/pkg/looker/resource_main_space.go deleted file mode 100644 index a077b5c..0000000 --- a/pkg/looker/resource_main_space.go +++ /dev/null @@ -1,280 +0,0 @@ -package looker - -import ( - "fmt" - "log" - "strings" - - "github.com/billtrust/looker-go-sdk/client/content" - - "github.com/billtrust/looker-go-sdk/client/space" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceMainSpace() *schema.Resource { - return &schema.Resource{ - Create: resourceMainSpaceCreate, - Read: resourceMainSpaceRead, - Update: resourceMainSpaceUpdate, - Delete: resourceMainSpaceDelete, - Exists: resourceMainSpaceExists, - Importer: &schema.ResourceImporter{ - State: resourceMainSpaceImport, - }, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - "parent_space_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "parent_id": { - Type: schema.TypeString, - Computed: true, - }, - "parent_content_metadata_id": { - Type: schema.TypeString, - Computed: true, - }, - "content_metadata_id": { - Type: schema.TypeString, - Computed: true, - }, - "content_metadata_inherits": { - Type: schema.TypeBool, - Required: true, - }, - }, - } -} - -func getRootSpace(d *schema.ResourceData, m interface{}, name string) (*models.Space, error) { - client := m.(*apiclient.LookerAPI30Reference) - - params := space.NewSearchSpacesParams() - params.Name = &name - - result, err := client.Space.SearchSpaces(params) - if err != nil { - log.Printf("[ERROR] Error while searching spaces with name '%s', %s", name, err.Error()) - return nil, err - } - - for _, item := range result.Payload { - if item.Name == name && item.ParentID == nil { - return item, nil - } - } - - if name == "Embed Groups" { - return nil, fmt.Errorf("[ERROR] 'Embed Groups' does not exist. Goto https://[domain].looker.com/admin/embed and set 'Embed Authentication' to Enabled") - } - - return nil, fmt.Errorf("No root space with name '%s'", name) -} - -func getSpaceByID(d *schema.ResourceData, m interface{}, id int64) (*models.Space, error) { - client := m.(*apiclient.LookerAPI30Reference) - - params := space.NewSpaceParams() - params.SpaceID = id - - result, err := client.Space.Space(params) - if err != nil { - log.Printf("[ERROR] Error while getting space by id, %s", err.Error()) - return nil, err - } - - return result.Payload, nil -} - -func resourceMainSpaceCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - rootSpace, err := getRootSpace(d, m, d.Get("parent_space_name").(string)) - if err != nil { - return err - } - - params := space.NewCreateSpaceParams() - params.Body = &models.Space{} - params.Body.Name = d.Get("name").(string) - params.Body.ParentID = &rootSpace.ID - - result, err := client.Space.CreateSpace(params) - if err != nil { - return err - } - - d.SetId(getStringFromID(result.Payload.ID)) - - // TODO: should SetId happen before or after logic to update content_metadata? - contentMetadataParams := content.NewUpdateContentMetadataParams() - contentMetadataParams.ContentMetadataID = result.Payload.ContentMetadataID - contentMetadataParams.Body = &models.ContentMeta{} - inherits := d.Get("content_metadata_inherits").(bool) - contentMetadataParams.Body.Inherits = &inherits - - _, err = client.Content.UpdateContentMetadata(contentMetadataParams) - if err != nil { - return err - } - - return resourceMainSpaceRead(d, m) -} - -func resourceMainSpaceRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - space, err := getSpaceByID(d, m, ID) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("name", space.Name); err != nil { - return err - } - if err = d.Set("content_metadata_id", getStringFromID(space.ContentMetadataID)); err != nil { - return err - } - if err = d.Set("parent_id", getStringFromID(*space.ParentID)); err != nil { - return err - } - - parentSpace, err := getSpaceByID(d, m, *space.ParentID) - if err != nil { - return err - } - - if err = d.Set("parent_space_name", parentSpace.Name); err != nil { - return err - } - if err = d.Set("parent_content_metadata_id", getStringFromID(parentSpace.ContentMetadataID)); err != nil { - return err - } - - contentMetadataParams := content.NewContentMetadataParams() - contentMetadataParams.ContentMetadataID = space.ContentMetadataID - - contentMetadataResult, err := client.Content.ContentMetadata(contentMetadataParams) - if err != nil { - return err - } - - if err = d.Set("content_metadata_inherits", contentMetadataResult.Payload.Inherits); err != nil { - return err - } - - return nil -} - -func resourceMainSpaceUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - rootSpace, err := getRootSpace(d, m, d.Get("parent_space_name").(string)) - if err != nil { - return err - } - - params := space.NewUpdateSpaceParams() - params.SpaceID = ID - params.Body = &models.Space{} - params.Body.Name = d.Get("name").(string) - params.Body.ParentID = &rootSpace.ID - - _, err = client.Space.UpdateSpace(params) - if err != nil { - return err - } - - if d.HasChange("content_metadata_inherits") { - contentMetadataID, err := getIDFromString(d.Get("content_metadata_id").(string)) - if err != nil { - return err - } - - contentMetadataInherts := d.Get("content_metadata_inherits").(bool) - contentMetadataParams := content.NewUpdateContentMetadataParams() - contentMetadataParams.ContentMetadataID = contentMetadataID - contentMetadataParams.Body = &models.ContentMeta{} - contentMetadataParams.Body.Inherits = &contentMetadataInherts - contentMetadataParams.Body.Name = d.Get("name").(string) - contentMetadataParams.Body.InheritingID = 0 - - log.Printf("[DEBUG] metadata id: %d, inherits %t", contentMetadataID, contentMetadataInherts) - - _, err = client.Content.UpdateContentMetadata(contentMetadataParams) - if err != nil { - return err - } - } - - return resourceMainSpaceRead(d, m) -} - -func resourceMainSpaceDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - params := space.NewDeleteSpaceParams() - params.SpaceID = ID - - _, err = client.Space.DeleteSpace(params) - if err != nil { - return err - } - - return nil -} - -func resourceMainSpaceExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - _, err = getSpaceByID(d, m, ID) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceMainSpaceImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceMainSpaceRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_model_set.go b/pkg/looker/resource_model_set.go index a71514c..970386d 100644 --- a/pkg/looker/resource_model_set.go +++ b/pkg/looker/resource_model_set.go @@ -1,13 +1,10 @@ package looker import ( - "strings" + "strconv" - "github.com/billtrust/looker-go-sdk/client/role" - "github.com/billtrust/looker-go-sdk/models" - - apiclient "github.com/billtrust/looker-go-sdk/client" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceModelSet() *schema.Resource { @@ -16,7 +13,6 @@ func resourceModelSet() *schema.Resource { Read: resourceModelSetRead, Update: resourceModelSetUpdate, Delete: resourceModelSetDelete, - Exists: resourceModelSetExists, Importer: &schema.ResourceImporter{ State: resourceModelSetImport, }, @@ -36,52 +32,48 @@ func resourceModelSet() *schema.Resource { } func resourceModelSetCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) + + modelSetName := d.Get("name").(string) var modelNames []string for _, modelName := range d.Get("models").(*schema.Set).List() { modelNames = append(modelNames, modelName.(string)) } - params := role.NewCreateModelSetParams() - params.Body = &models.ModelSet{} - params.Body.Name = d.Get("name").(string) - params.Body.Models = modelNames + writeModelSet := apiclient.WriteModelSet{ + Name: &modelSetName, + Models: &modelNames, + } - result, err := client.Role.CreateModelSet(params) + modelSet, err := client.CreateModelSet(writeModelSet, nil) if err != nil { return err } - d.SetId(getStringFromID(result.Payload.ID)) + modelSetID := *modelSet.Id + d.SetId(strconv.Itoa(int(modelSetID))) return resourceModelSetRead(d, m) } func resourceModelSetRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + modelSetID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewModelSetParams() - params.ModelSetID = ID - - result, err := client.Role.ModelSet(params) + modelSet, err := client.ModelSet(modelSetID, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("name", result.Payload.Name); err != nil { + if err = d.Set("name", modelSet.Name); err != nil { return err } - if err = d.Set("models", result.Payload.Models); err != nil { + if err = d.Set("models", modelSet.Models); err != nil { return err } @@ -89,76 +81,45 @@ func resourceModelSetRead(d *schema.ResourceData, m interface{}) error { } func resourceModelSetUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + modelSetID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } + modelSetName := d.Get("name").(string) var modelNames []string for _, modelName := range d.Get("models").(*schema.Set).List() { modelNames = append(modelNames, modelName.(string)) } - - params := role.NewUpdateModelSetParams() - params.ModelSetID = ID - params.Body = &models.ModelSet{} - params.Body.Name = d.Get("name").(string) - params.Body.Models = modelNames - - _, err = client.Role.UpdateModelSet(params) + writeModelSet := apiclient.WriteModelSet{ + Name: &modelSetName, + Models: &modelNames, + } + _, err = client.UpdateModelSet(modelSetID, writeModelSet, nil) if err != nil { return err } - return resourceModelSetRead(d, m) + return resourceModelSetCreate(d, m) } func resourceModelSetDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + modelSetID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewDeleteModelSetParams() - params.ModelSetID = ID - - _, err = client.Role.DeleteModelSet(params) + _, err = client.DeleteModelSet(modelSetID, nil) if err != nil { return err } return nil } - -func resourceModelSetExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := role.NewModelSetParams() - params.ModelSetID = ID - - _, err = client.Role.ModelSet(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourceModelSetImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourceModelSetRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_permission_set.go b/pkg/looker/resource_permission_set.go index 61a93e8..1451fe0 100644 --- a/pkg/looker/resource_permission_set.go +++ b/pkg/looker/resource_permission_set.go @@ -1,13 +1,10 @@ package looker import ( - "strings" + "strconv" - "github.com/billtrust/looker-go-sdk/client/role" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourcePermissionSet() *schema.Resource { @@ -16,7 +13,6 @@ func resourcePermissionSet() *schema.Resource { Read: resourcePermissionSetRead, Update: resourcePermissionSetUpdate, Delete: resourcePermissionSetDelete, - Exists: resourcePermissionSetExists, Importer: &schema.ResourceImporter{ State: resourcePermissionSetImport, }, @@ -36,78 +32,71 @@ func resourcePermissionSet() *schema.Resource { } func resourcePermissionSetCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) + + permissionSetName := d.Get("name").(string) var permissions []string for _, permission := range d.Get("permissions").(*schema.Set).List() { permissions = append(permissions, permission.(string)) } - params := role.NewCreatePermissionSetParams() - params.Body = &models.PermissionSet{} - params.Body.Name = d.Get("name").(string) - params.Body.Permissions = permissions + writePermissionSet := apiclient.WritePermissionSet{ + Name: &permissionSetName, + Permissions: &permissions, + } - result, err := client.Role.CreatePermissionSet(params) + permissionSet, err := client.CreatePermissionSet(writePermissionSet, nil) if err != nil { return err } - d.SetId(getStringFromID(result.Payload.ID)) + permissionSetID := *permissionSet.Id + d.SetId(strconv.Itoa(int(permissionSetID))) return resourcePermissionSetRead(d, m) } func resourcePermissionSetRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + permissionSetID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewPermissionSetParams() - params.PermissionSetID = ID - - result, err := client.Role.PermissionSet(params) + permissionSet, err := client.PermissionSet(permissionSetID, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("name", result.Payload.Name); err != nil { + if err = d.Set("name", permissionSet.Name); err != nil { return err } - if err = d.Set("permissions", result.Payload.Permissions); err != nil { + if err = d.Set("permissions", permissionSet.Permissions); err != nil { return err } - return nil } func resourcePermissionSetUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + permissionSetID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } + permissionSetName := d.Get("name").(string) var permissions []string for _, permission := range d.Get("permissions").(*schema.Set).List() { permissions = append(permissions, permission.(string)) } - - params := role.NewUpdatePermissionSetParams() - params.PermissionSetID = ID - params.Body = &models.PermissionSet{} - params.Body.Name = d.Get("name").(string) - params.Body.Permissions = permissions - - _, err = client.Role.UpdatePermissionSet(params) + writePermissionSet := apiclient.WritePermissionSet{ + Name: &permissionSetName, + Permissions: &permissions, + } + _, err = client.UpdatePermissionSet(permissionSetID, writePermissionSet, nil) if err != nil { return err } @@ -116,17 +105,14 @@ func resourcePermissionSetUpdate(d *schema.ResourceData, m interface{}) error { } func resourcePermissionSetDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + permissionSetID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewDeletePermissionSetParams() - params.PermissionSetID = ID - - _, err = client.Role.DeletePermissionSet(params) + _, err = client.DeletePermissionSet(permissionSetID, nil) if err != nil { return err } @@ -134,31 +120,6 @@ func resourcePermissionSetDelete(d *schema.ResourceData, m interface{}) error { return nil } -func resourcePermissionSetExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := role.NewPermissionSetParams() - params.PermissionSetID = ID - - _, err = client.Role.PermissionSet(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourcePermissionSetImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourcePermissionSetRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_project.go b/pkg/looker/resource_project.go deleted file mode 100644 index e17d242..0000000 --- a/pkg/looker/resource_project.go +++ /dev/null @@ -1,167 +0,0 @@ -package looker - -import ( - "fmt" - "strings" - - "github.com/billtrust/looker-go-sdk/client/project" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func getProject(projectID string, client *apiclient.LookerAPI30Reference) (*project.ProjectOK, error) { - params := project.NewProjectParams() - params.ProjectID = projectID - - result, err := client.Project.Project(params) - return result, err -} - -func resourceProject() *schema.Resource { - return &schema.Resource{ - Create: resourceProjectCreate, - Read: resourceProjectRead, - Update: resourceProjectUpdate, - Delete: resourceProjectDelete, - Exists: resourceProjectExists, - Importer: &schema.ResourceImporter{ - State: resourceProjectImport, - }, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { - v := val.(string) - if strings.Contains(v, " ") { - errs = append(errs, fmt.Errorf("%q must not contain any spaces, got: %q", key, v)) - } - return - }, - }, - }, - } -} - -func resourceProjectCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - err := updateSession(client, "dev") - if err != nil { - return err - } - - name := d.Get("name").(string) - params := project.NewCreateProjectParams() - params.Body = &models.Project{} - params.Body.Name = name - - _, err = client.Project.CreateProject(params) - if err != nil { - return err - } - - d.SetId(name) - - return resourceProjectRead(d, m) -} - -func resourceProjectRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := project.NewProjectParams() - params.ProjectID = d.Id() - - result, err := client.Project.Project(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("name", result.Payload.Name); err != nil { - return err - } - - return nil -} - -func resourceProjectUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - err := updateSession(client, "dev") - if err != nil { - return err - } - - name := d.Get("name").(string) - - params := project.NewUpdateProjectParams() - params.ProjectID = d.Id() - params.Body = &models.Project{} - params.Body.Name = name - - _, err = client.Project.UpdateProject(params) - if err != nil { - // looker gives "An error has occured" 500 error even though the name correctly is updated - if !strings.Contains(err.Error(), "An error has occurred.") { - return err - } - - // the project might be updated correctly, check by getting the project with the new name - _, readError := getProject(name, client) - if readError != nil { - return err // return original error for the update - } - - // looks like update of the name was succesful because we can query for it now. Update the ID to be the new name and read it back - d.SetId(name) - - return resourceProjectRead(d, m) - } - - return resourceProjectRead(d, m) -} - -func resourceProjectDelete(d *schema.ResourceData, m interface{}) error { - // TODO: Looker doesn't appear to support deleting projects from the API - return nil -} - -func resourceProjectExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - // TODO Not sure if we should always set session to "dev" instead of "production" when checking if it exists? will dev always show all dev+prod projects? - err := updateSession(client, "dev") - if err != nil { - return false, err - } - - params := project.NewProjectParams() - params.ProjectID = d.Id() - - _, err = client.Project.Project(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceProjectImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceProjectRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_project_git_details.go b/pkg/looker/resource_project_git_details.go deleted file mode 100644 index 0f1e4ec..0000000 --- a/pkg/looker/resource_project_git_details.go +++ /dev/null @@ -1,156 +0,0 @@ -package looker - -import ( - "strings" - - "github.com/billtrust/looker-go-sdk/client/project" - "github.com/billtrust/looker-go-sdk/models" - "github.com/go-openapi/strfmt" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceProjectGitDetails() *schema.Resource { - return &schema.Resource{ - Create: resourceProjectGitDetailsCreate, - Read: resourceProjectGitDetailsRead, - Delete: resourceProjectGitDetailsDelete, - Update: resourceProjectGitDetailsUpdate, - Exists: resourceProjectGitDetailsExists, - Importer: &schema.ResourceImporter{ - State: resourceProjectGitDetailsImport, - }, - - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - }, - "git_remote_url": { - Type: schema.TypeString, - Required: true, - }, - }, - } -} - -func setProjectGitDetails(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - err := updateSession(client, "dev") - if err != nil { - return err - } - - gitRemoteURL := strfmt.URI(d.Get("git_remote_url").(string)) - - projectID := d.Get("project_id").(string) - params := project.NewUpdateProjectParams() - params.ProjectID = projectID - params.Body = &models.Project{} - params.Body.GitRemoteURL = &gitRemoteURL - - _, err = client.Project.UpdateProject(params) - if err != nil { - return err - } - - return nil -} - -func resourceProjectGitDetailsCreate(d *schema.ResourceData, m interface{}) error { - err := setProjectGitDetails(d, m) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - - return err - } - - d.SetId(d.Get("project_id").(string)) - - return resourceProjectGitDetailsRead(d, m) -} - -func resourceProjectGitDetailsRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - err := updateSession(client, "dev") - if err != nil { - return err - } - - projectID := d.Id() - - params := project.NewProjectParams() - params.ProjectID = projectID - - result, err := client.Project.Project(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - - return err - } - - if err = d.Set("project_id", result.Payload.ID); err != nil { - return err - } - if err = d.Set("git_remote_url", result.Payload.GitRemoteURL.String()); err != nil { - return err - } - - return nil -} - -func resourceProjectGitDetailsUpdate(d *schema.ResourceData, m interface{}) error { - err := setProjectGitDetails(d, m) - if err != nil { - return err - } - - return resourceProjectGitDetailsRead(d, m) -} - -func resourceProjectGitDetailsDelete(d *schema.ResourceData, m interface{}) error { - // TODO: Deleting this resource should set the git fields back to blank values. not implementing this yet since leaving the values does not have any negative effect - return nil -} - -func resourceProjectGitDetailsExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - // TODO Not sure if we should always set session to "dev" instead of "production" when checking if it exists? will dev always show all dev+prod projects? - err := updateSession(client, "dev") - if err != nil { - return false, err - } - - params := project.NewProjectParams() - params.ProjectID = d.Id() - - _, err = client.Project.Project(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceProjectGitDetailsImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceProjectGitDetailsRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_role.go b/pkg/looker/resource_role.go index 031e28d..ff1a4c9 100644 --- a/pkg/looker/resource_role.go +++ b/pkg/looker/resource_role.go @@ -1,13 +1,10 @@ package looker import ( - "strings" + "strconv" - "github.com/billtrust/looker-go-sdk/client/role" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceRole() *schema.Resource { @@ -16,7 +13,6 @@ func resourceRole() *schema.Resource { Read: resourceRoleRead, Update: resourceRoleUpdate, Delete: resourceRoleDelete, - Exists: resourceRoleExists, Importer: &schema.ResourceImporter{ State: resourceRoleImport, }, @@ -27,11 +23,11 @@ func resourceRole() *schema.Resource { Required: true, }, "permission_set_id": { - Type: schema.TypeString, + Type: schema.TypeInt, Required: true, }, "model_set_id": { - Type: schema.TypeString, + Type: schema.TypeInt, Required: true, }, }, @@ -39,61 +35,49 @@ func resourceRole() *schema.Resource { } func resourceRoleCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - permissionSetID, err := getIDFromString(d.Get("permission_set_id").(string)) - if err != nil { - return err - } + roleName := d.Get("name").(string) + permissionSetID := d.Get("permission_set_id").(int64) + modelSetID := d.Get("model_set_id").(int64) - modelSetID, err := getIDFromString(d.Get("model_set_id").(string)) - if err != nil { - return err + writeRole := apiclient.WriteRole{ + Name: &roleName, + PermissionSetId: &permissionSetID, + ModelSetId: &modelSetID, } - params := role.NewCreateRoleParams() - params.Body = &models.Role{} - params.Body.Name = d.Get("name").(string) - params.Body.PermissionSetID = permissionSetID - params.Body.ModelSetID = modelSetID - - result, err := client.Role.CreateRole(params) + role, err := client.CreateRole(writeRole, nil) if err != nil { return err } - d.SetId(getStringFromID(result.Payload.ID)) + roleID := *role.Id + d.SetId(strconv.Itoa(int(roleID))) return resourceRoleRead(d, m) } func resourceRoleRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + roleID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewRoleParams() - params.RoleID = ID - - result, err := client.Role.Role(params) + role, err := client.Role(roleID, nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("name", result.Payload.Name); err != nil { + if err = d.Set("name", role.Name); err != nil { return err } - if err = d.Set("permission_set_id", result.Payload.PermissionSetID); err != nil { + if err = d.Set("permission_set_id", role.PermissionSetId); err != nil { return err } - if err = d.Set("model_set_id", result.Payload.ModelSetID); err != nil { + if err = d.Set("model_set_id", role.ModelSetId); err != nil { return err } @@ -101,31 +85,22 @@ func resourceRoleRead(d *schema.ResourceData, m interface{}) error { } func resourceRoleUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + roleID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - permissionSetID, err := getIDFromString(d.Get("permission_set_id").(string)) - if err != nil { - return err - } - - modelSetID, err := getIDFromString(d.Get("model_set_id").(string)) - if err != nil { - return err + roleName := d.Get("name").(string) + permissionSetID := d.Get("permission_set_id").(int64) + modelSetID := d.Get("model_set_id").(int64) + writeRole := apiclient.WriteRole{ + Name: &roleName, + PermissionSetId: &permissionSetID, + ModelSetId: &modelSetID, } - - params := role.NewUpdateRoleParams() - params.RoleID = ID - params.Body = &models.Role{} - params.Body.Name = d.Get("name").(string) - params.Body.PermissionSetID = permissionSetID - params.Body.ModelSetID = modelSetID - - _, err = client.Role.UpdateRole(params) + _, err = client.UpdateRole(roleID, writeRole, nil) if err != nil { return err } @@ -134,17 +109,14 @@ func resourceRoleUpdate(d *schema.ResourceData, m interface{}) error { } func resourceRoleDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + roleID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewDeleteRoleParams() - params.RoleID = ID - - _, err = client.Role.DeleteRole(params) + _, err = client.DeleteRole(roleID, nil) if err != nil { return err } @@ -152,31 +124,6 @@ func resourceRoleDelete(d *schema.ResourceData, m interface{}) error { return nil } -func resourceRoleExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := role.NewRoleParams() - params.RoleID = ID - - _, err = client.Role.Role(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourceRoleImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourceRoleRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_role_groups.go b/pkg/looker/resource_role_groups.go index 92aa8e4..77be01b 100644 --- a/pkg/looker/resource_role_groups.go +++ b/pkg/looker/resource_role_groups.go @@ -1,12 +1,10 @@ package looker import ( - "strings" + "strconv" - "github.com/billtrust/looker-go-sdk/client/role" - - apiclient "github.com/billtrust/looker-go-sdk/client" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceRoleGroups() *schema.Resource { @@ -15,7 +13,6 @@ func resourceRoleGroups() *schema.Resource { Read: resourceRoleGroupsRead, Update: resourceRoleGroupsUpdate, Delete: resourceRoleGroupsDelete, - Exists: resourceRoleGroupsExists, Importer: &schema.ResourceImporter{ State: resourceRoleGroupsImport, }, @@ -28,68 +25,60 @@ func resourceRoleGroups() *schema.Resource { "group_ids": { Type: schema.TypeSet, Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeInt}, }, }, } } func resourceRoleGroupsCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) + + roleIDString := d.Get("role_id").(string) - ID, err := getIDFromString(d.Get("role_id").(string)) + roleID, err := strconv.ParseInt(roleIDString, 10, 64) if err != nil { return err } var groupIDs []int64 - for _, sGroupID := range d.Get("group_ids").(*schema.Set).List() { - iGroupID, err := getIDFromString(sGroupID.(string)) - if err != nil { - return err - } - - groupIDs = append(groupIDs, iGroupID) + for _, groupID := range d.Get("group_ids").(*schema.Set).List() { + groupIDs = append(groupIDs, groupID.(int64)) } - params := role.NewSetRoleGroupsParams() - params.RoleID = ID - params.Body = groupIDs - - _, err = client.Role.SetRoleGroups(params) + _, err = client.SetRoleGroups(roleID, groupIDs, nil) if err != nil { return err } - d.SetId(d.Get("role_id").(string)) + d.SetId(roleIDString) return resourceRoleGroupsRead(d, m) } func resourceRoleGroupsRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + roleID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewRoleGroupsParams() - params.RoleID = ID - - result, err := client.Role.RoleGroups(params) + groups, err := client.RoleGroups(roleID, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("role_id", ID); err != nil { + var groupIDs []int64 + for _, group := range groups { + groupIDs = append(groupIDs, *group.Id) + } + + if err = d.Set("role_id", roleID); err != nil { return err } - if err = d.Set("group_ids", result.Payload); err != nil { + + if err = d.Set("group_ids", groupIDs); err != nil { return err } @@ -97,28 +86,19 @@ func resourceRoleGroupsRead(d *schema.ResourceData, m interface{}) error { } func resourceRoleGroupsUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + roleID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } var groupIDs []int64 - for _, sGroupID := range d.Get("group_ids").(*schema.Set).List() { - iGroupID, err := getIDFromString(sGroupID.(string)) - if err != nil { - return err - } - - groupIDs = append(groupIDs, iGroupID) + for _, groupID := range d.Get("group_ids").(*schema.Set).List() { + groupIDs = append(groupIDs, groupID.(int64)) } - params := role.NewSetRoleGroupsParams() - params.RoleID = ID - params.Body = groupIDs - - _, err = client.Role.SetRoleGroups(params) + _, err = client.SetRoleGroups(roleID, groupIDs, nil) if err != nil { return err } @@ -127,18 +107,15 @@ func resourceRoleGroupsUpdate(d *schema.ResourceData, m interface{}) error { } func resourceRoleGroupsDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + roleID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := role.NewSetRoleGroupsParams() - params.RoleID = ID - params.Body = []int64{} - - _, err = client.Role.SetRoleGroups(params) + groupIDs := []int64{} + _, err = client.SetRoleGroups(roleID, groupIDs, nil) if err != nil { return err } @@ -146,31 +123,6 @@ func resourceRoleGroupsDelete(d *schema.ResourceData, m interface{}) error { return nil } -func resourceRoleGroupsExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := role.NewRoleGroupsParams() - params.RoleID = ID - - _, err = client.Role.RoleGroups(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourceRoleGroupsImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourceRoleGroupsRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_user.go b/pkg/looker/resource_user.go index e8a637c..e7579da 100644 --- a/pkg/looker/resource_user.go +++ b/pkg/looker/resource_user.go @@ -1,12 +1,10 @@ package looker import ( - "strings" + "strconv" - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/client/user" - "github.com/billtrust/looker-go-sdk/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceUser() *schema.Resource { @@ -15,12 +13,14 @@ func resourceUser() *schema.Resource { Read: resourceUserRead, Update: resourceUserUpdate, Delete: resourceUserDelete, - Exists: resourceUserExists, Importer: &schema.ResourceImporter{ State: resourceUserImport, }, - Schema: map[string]*schema.Schema{ + "email": { + Type: schema.TypeString, + Required: true, + }, "first_name": { Type: schema.TypeString, Optional: true, @@ -34,47 +34,58 @@ func resourceUser() *schema.Resource { } func resourceUserCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := user.NewCreateUserParams() - params.Body = &models.User{} - params.Body.FirstName = d.Get("first_name").(string) - params.Body.LastName = d.Get("last_name").(string) + client := m.(*apiclient.LookerSDK) + firstName := d.Get("first_name").(string) + lastName := d.Get("last_name").(string) + email := d.Get("email").(string) + + writeUser := apiclient.WriteUser{ + FirstName: &firstName, + LastName: &lastName, + } - user, err := client.User.CreateUser(params) + user, err := client.CreateUser(writeUser, "", nil) if err != nil { return err } - d.SetId(getStringFromID(user.Payload.ID)) + userID := *user.Id + d.SetId(strconv.Itoa(int(userID))) + + writeCredentialsEmail := apiclient.WriteCredentialsEmail{ + Email: &email, + } + _, err = client.CreateUserCredentialsEmail(userID, writeCredentialsEmail, "", nil) + if err != nil { + if _, err = client.DeleteUser(userID, nil); err != nil { + return err + } + return err + } return resourceUserRead(d, m) } func resourceUserRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - userID, err := getIDFromString(d.Id()) + userID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user.NewUserParams() - params.UserID = userID - - user, err := client.User.User(params) + user, err := client.User(userID, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("first_name", user.Payload.FirstName); err != nil { + if err = d.Set("email", user.Email); err != nil { return err } - if err = d.Set("last_name", user.Payload.LastName); err != nil { + if err = d.Set("first_name", user.FirstName); err != nil { + return err + } + if err = d.Set("last_name", user.LastName); err != nil { return err } @@ -82,39 +93,49 @@ func resourceUserRead(d *schema.ResourceData, m interface{}) error { } func resourceUserUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - userID, err := getIDFromString(d.Id()) + userID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user.NewUpdateUserParams() - params.UserID = userID - params.Body = &models.User{} - params.Body.FirstName = d.Get("first_name").(string) - params.Body.LastName = d.Get("last_name").(string) + if d.HasChanges("first_name", "last_name") { + firstName := d.Get("first_name").(string) + lastName := d.Get("last_name").(string) + writeUser := apiclient.WriteUser{ + FirstName: &firstName, + LastName: &lastName, + } + _, err = client.UpdateUser(userID, writeUser, "", nil) + if err != nil { + return err + } + } - _, err = client.User.UpdateUser(params) - if err != nil { - return err + if d.HasChange("email") { + email := d.Get("email").(string) + writeCredentialsEmail := apiclient.WriteCredentialsEmail{ + Email: &email, + } + _, err = client.UpdateUserCredentialsEmail(userID, writeCredentialsEmail, "", nil) + if err != nil { + return err + } } return resourceUserRead(d, m) } func resourceUserDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - userID, err := getIDFromString(d.Id()) + userID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user.NewDeleteUserParams() - params.UserID = userID - - _, err = client.User.DeleteUser(params) + _, err = client.DeleteUser(userID, nil) if err != nil { return err } @@ -122,31 +143,6 @@ func resourceUserDelete(d *schema.ResourceData, m interface{}) error { return nil } -func resourceUserExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - userID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := user.NewUserParams() - params.UserID = userID - - _, err = client.User.User(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourceUserImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourceUserRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_user_api_key.go b/pkg/looker/resource_user_api_key.go deleted file mode 100644 index 4593677..0000000 --- a/pkg/looker/resource_user_api_key.go +++ /dev/null @@ -1,184 +0,0 @@ -package looker - -import ( - "fmt" - "strings" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/client/user" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceUserAPIKey() *schema.Resource { - return &schema.Resource{ - Create: resourceUserAPIKeyCreate, - Read: resourceUserAPIKeyRead, - Delete: resourceUserAPIKeyDelete, - Exists: resourceUserAPIKeyExists, - Importer: &schema.ResourceImporter{ - State: resourceUserAPIKeyImport, - }, - - Schema: map[string]*schema.Schema{ - "user_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "client_id": { - Type: schema.TypeString, - Computed: true, - }, - }, - } -} - -func resourceUserAPIKeyCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - sUserID := d.Get("user_id").(string) - - iUserID, err := getIDFromString(sUserID) - if err != nil { - return err - } - - params := user.NewCreateUserCredentialsApi3Params() - params.UserID = iUserID - params.Body = &models.CredentialsApi3{} - - resp, err := client.User.CreateUserCredentialsApi3(params) - if err != nil { - return err - } - - id := sUserID + ":" + getStringFromID(resp.Payload.ID) - d.SetId(id) - - return resourceUserAPIKeyRead(d, m) -} - -func resourceUserAPIKeyRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - id := strings.Split(d.Id(), ":") - if len(id) != 2 { - return fmt.Errorf("ID Should be two strings separated by a colon (:)") - } - - sUserID := id[0] - sAPIID := id[1] - - iUserID, err := getIDFromString(sUserID) - if err != nil { - return err - } - - iAPIID, err := getIDFromString(sAPIID) - if err != nil { - return err - } - - params := user.NewUserCredentialsApi3Params() - params.UserID = iUserID - params.CredentialsApi3ID = iAPIID - - resp, err := client.User.UserCredentialsApi3(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("user_id", sUserID); err != nil { - return err - } - if err = d.Set("client_id", resp.Payload.ClientID); err != nil { - return err - } - - return nil -} - -func resourceUserAPIKeyDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - id := strings.Split(d.Id(), ":") - if len(id) != 2 { - return fmt.Errorf("ID Should be two strings separated by a colon (:)") - } - - sUserID := id[0] - sAPIID := id[1] - - iUserID, err := getIDFromString(sUserID) - if err != nil { - return err - } - - iAPIID, err := getIDFromString(sAPIID) - if err != nil { - return err - } - - params := user.NewDeleteUserCredentialsApi3Params() - params.UserID = iUserID - params.CredentialsApi3ID = iAPIID - - _, err = client.User.DeleteUserCredentialsApi3(params) - if err != nil { - return err - } - - return nil -} - -func resourceUserAPIKeyExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - id := strings.Split(d.Id(), ":") - if len(id) != 2 { - return false, fmt.Errorf("ID Should be two strings separated by a colon (:)") - } - - sUserID := id[0] - sAPIID := id[1] - - iUserID, err := getIDFromString(sUserID) - if err != nil { - return false, err - } - - iAPIID, err := getIDFromString(sAPIID) - if err != nil { - return false, err - } - - params := user.NewUserCredentialsApi3Params() - params.UserID = iUserID - params.CredentialsApi3ID = iAPIID - - _, err = client.User.UserCredentialsApi3(params) - - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceUserAPIKeyImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceUserAPIKeyRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_user_attribute.go b/pkg/looker/resource_user_attribute.go index b34a221..06ce3d0 100644 --- a/pkg/looker/resource_user_attribute.go +++ b/pkg/looker/resource_user_attribute.go @@ -1,13 +1,10 @@ package looker import ( - "strings" + "strconv" - "github.com/billtrust/looker-go-sdk/client/user_attribute" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceUserAttribute() *schema.Resource { @@ -16,7 +13,6 @@ func resourceUserAttribute() *schema.Resource { Read: resourceUserAttributeRead, Update: resourceUserAttributeUpdate, Delete: resourceUserAttributeDelete, - Exists: resourceUserAttributeExists, Importer: &schema.ResourceImporter{ State: resourceUserAttributeImport, }, @@ -29,7 +25,6 @@ func resourceUserAttribute() *schema.Resource { "type": { Type: schema.TypeString, Required: true, - // TODO: hard code to only allow "advanced_filter_string" for now }, "label": { Type: schema.TypeString, @@ -40,51 +35,48 @@ func resourceUserAttribute() *schema.Resource { } func resourceUserAttributeCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := user_attribute.NewCreateUserAttributeParams() - params.Body = &models.UserAttribute{} - params.Body.Name = d.Get("name").(string) - params.Body.Type = d.Get("type").(string) - params.Body.Label = d.Get("label").(string) + client := m.(*apiclient.LookerSDK) + userAttributeName := d.Get("name").(string) + userAttributeLabel := d.Get("label").(string) + userAttributeType := d.Get("type").(string) + + writeUserAttribute := apiclient.WriteUserAttribute{ + Name: &userAttributeName, + Label: &userAttributeLabel, + Type: &userAttributeType, + } - result, err := client.UserAttribute.CreateUserAttribute(params) + userAttribute, err := client.CreateUserAttribute(writeUserAttribute, "", nil) if err != nil { return err } - d.SetId(getStringFromID(result.Payload.ID)) + userAttributeID := *userAttribute.Id + d.SetId(strconv.Itoa(int(userAttributeID))) return resourceUserAttributeRead(d, m) } func resourceUserAttributeRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + userAttributeID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user_attribute.NewUserAttributeParams() - params.UserAttributeID = ID - - result, err := client.UserAttribute.UserAttribute(params) + userAttribute, err := client.UserAttribute(userAttributeID, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - if err = d.Set("name", result.Payload.Name); err != nil { + if err = d.Set("name", userAttribute.Name); err != nil { return err } - if err = d.Set("type", result.Payload.Type); err != nil { + if err = d.Set("type", userAttribute.Type); err != nil { return err } - if err = d.Set("label", result.Payload.Label); err != nil { + if err = d.Set("label", userAttribute.Label); err != nil { return err } @@ -92,21 +84,24 @@ func resourceUserAttributeRead(d *schema.ResourceData, m interface{}) error { } func resourceUserAttributeUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + userAttributeID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user_attribute.NewUpdateUserAttributeParams() - params.UserAttributeID = ID - params.Body = &models.UserAttribute{} - params.Body.Name = d.Get("name").(string) - params.Body.Type = d.Get("type").(string) - params.Body.Label = d.Get("label").(string) + userAttributeName := d.Get("name").(string) + userAttributeType := d.Get("type").(string) + userAttributeLabel := d.Get("type").(string) - _, err = client.UserAttribute.UpdateUserAttribute(params) + writeUserAttribute := apiclient.WriteUserAttribute{ + Name: &userAttributeName, + Label: &userAttributeLabel, + Type: &userAttributeType, + } + + _, err = client.UpdateUserAttribute(userAttributeID, writeUserAttribute, "", nil) if err != nil { return err } @@ -115,17 +110,14 @@ func resourceUserAttributeUpdate(d *schema.ResourceData, m interface{}) error { } func resourceUserAttributeDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - ID, err := getIDFromString(d.Id()) + userAttributeID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user_attribute.NewDeleteUserAttributeParams() - params.UserAttributeID = ID - - _, err = client.UserAttribute.DeleteUserAttribute(params) + _, err = client.DeleteUserAttribute(userAttributeID, nil) if err != nil { return err } @@ -133,31 +125,6 @@ func resourceUserAttributeDelete(d *schema.ResourceData, m interface{}) error { return nil } -func resourceUserAttributeExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - ID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := user_attribute.NewUserAttributeParams() - params.UserAttributeID = ID - - _, err = client.UserAttribute.UserAttribute(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - func resourceUserAttributeImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { if err := resourceUserAttributeRead(d, m); err != nil { return nil, err diff --git a/pkg/looker/resource_user_email.go b/pkg/looker/resource_user_email.go deleted file mode 100644 index bab566c..0000000 --- a/pkg/looker/resource_user_email.go +++ /dev/null @@ -1,159 +0,0 @@ -package looker - -import ( - "strings" - - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/client/user" - "github.com/billtrust/looker-go-sdk/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceUserEmail() *schema.Resource { - return &schema.Resource{ - Create: resourceUserEmailCreate, - Read: resourceUserEmailRead, - Update: resourceUserEmailUpdate, - Delete: resourceUserEmailDelete, - Exists: resourceUserEmailExists, - Importer: &schema.ResourceImporter{ - State: resourceUserEmailImport, - }, - - Schema: map[string]*schema.Schema{ - "user_id": { - Type: schema.TypeString, - Required: true, - }, - "email": { - Type: schema.TypeString, - Required: true, - }, - }, - } -} - -func resourceUserEmailCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - params := user.NewCreateUserCredentialsEmailParams() - - sUserID := d.Get("user_id").(string) - - iUserID, err := getIDFromString(sUserID) - if err != nil { - return err - } - - params.UserID = iUserID - params.Body = &models.CredentialsEmail{} - params.Body.Email = d.Get("email").(string) - - _, err = client.User.CreateUserCredentialsEmail(params) - if err != nil { - return err - } - - d.SetId(sUserID) - - return resourceUserEmailRead(d, m) -} - -func resourceUserEmailRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - userID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - params := user.NewUserCredentialsEmailParams() - params.UserID = userID - - user, err := client.User.UserCredentialsEmail(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } - return err - } - - if err = d.Set("email", user.Payload.Email); err != nil { - return err - } - - return nil -} - -func resourceUserEmailUpdate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - userID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - params := user.NewUpdateUserCredentialsEmailParams() - params.UserID = userID - params.Body = &models.CredentialsEmail{} - params.Body.Email = d.Get("email").(string) - - _, err = client.User.UpdateUserCredentialsEmail(params) - if err != nil { - return err - } - - return resourceUserEmailRead(d, m) -} - -func resourceUserEmailDelete(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) - - userID, err := getIDFromString(d.Id()) - if err != nil { - return err - } - - params := user.NewDeleteUserCredentialsEmailParams() - params.UserID = userID - - _, err = client.User.DeleteUserCredentialsEmail(params) - if err != nil { - return err - } - - return nil -} - -func resourceUserEmailExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) - - userID, err := getIDFromString(d.Id()) - if err != nil { - return false, err - } - - params := user.NewUserCredentialsEmailParams() - params.UserID = userID - - _, err = client.User.UserCredentialsEmail(params) - if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err - } - - return true, nil -} - -func resourceUserEmailImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - if err := resourceUserEmailRead(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil -} diff --git a/pkg/looker/resource_user_roles.go b/pkg/looker/resource_user_roles.go index 9972289..7a035fb 100644 --- a/pkg/looker/resource_user_roles.go +++ b/pkg/looker/resource_user_roles.go @@ -1,11 +1,10 @@ package looker import ( - "strings" + "strconv" - apiclient "github.com/billtrust/looker-go-sdk/client" - "github.com/billtrust/looker-go-sdk/client/user" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) func resourceUserRoles() *schema.Resource { @@ -14,7 +13,6 @@ func resourceUserRoles() *schema.Resource { Read: resourceUserRolesRead, Update: resourceUserRolesUpdate, Delete: resourceUserRolesDelete, - Exists: resourceUserRolesExists, Importer: &schema.ResourceImporter{ State: resourceUserRolesImport, }, @@ -24,80 +22,65 @@ func resourceUserRoles() *schema.Resource { Type: schema.TypeString, Required: true, }, - "role_names": { + "role_ids": { Type: schema.TypeSet, Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeInt}, }, }, } } func resourceUserRolesCreate(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - sUserID := d.Get("user_id").(string) + userIDString := d.Get("user_id").(string) - iUserID, err := getIDFromString(sUserID) + userID, err := strconv.ParseInt(userIDString, 10, 64) if err != nil { return err } - var roleNames []string - for _, roleName := range d.Get("role_names").(*schema.Set).List() { - roleNames = append(roleNames, roleName.(string)) + var roleIDs []int64 + for _, roleID := range d.Get("role_ids").(*schema.Set).List() { + roleIDs = append(roleIDs, roleID.(int64)) } - // TODO: if role name does not exist, what should it do? through an error? try to create the role? - roleIds, err := getRoleIds(roleNames, client) - - if err != nil { - return err - } - - params := user.NewSetUserRolesParams() - params.UserID = iUserID - params.Body = roleIds - - _, err = client.User.SetUserRoles(params) + _, err = client.SetUserRoles(userID, roleIDs, "", nil) if err != nil { return err } - d.SetId(sUserID) + d.SetId(userIDString) return resourceUserRolesRead(d, m) } func resourceUserRolesRead(d *schema.ResourceData, m interface{}) error { - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - userID, err := getIDFromString(d.Id()) + userID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user.NewUserRolesParams() - params.UserID = userID + request := apiclient.RequestUserRoles{UserId: userID} - rolesResult, err := client.User.UserRoles(params) + userRoles, err := client.UserRoles(request, nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - d.SetId("") - return nil - } return err } - roleNames := []string{} - for _, role := range rolesResult.Payload { - roleNames = append(roleNames, role.Name) + var roleIDs []int64 + for _, role := range userRoles { + roleIDs = append(roleIDs, *role.Id) } if err = d.Set("user_id", userID); err != nil { return err } - if err = d.Set("role_names", roleNames); err != nil { + + if err = d.Set("role_ids", roleIDs); err != nil { return err } @@ -105,55 +88,41 @@ func resourceUserRolesRead(d *schema.ResourceData, m interface{}) error { } func resourceUserRolesUpdate(d *schema.ResourceData, m interface{}) error { - // TODO: There is no functional difference between "Creating" and "updating" which roles a user has. Only settings the roles currently assigned to the user. Is this the correct implemenation in thise case? - return resourceUserRolesCreate(d, m) -} - -func resourceUserRolesDelete(d *schema.ResourceData, m interface{}) error { - // TODO: Delete really just removes all the roles from the user. Is this the correct way to implement delete in this case? - client := m.(*apiclient.LookerAPI30Reference) + client := m.(*apiclient.LookerSDK) - userID, err := getIDFromString(d.Id()) + userID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } - params := user.NewSetUserRolesParams() - params.UserID = userID - params.Body = []int64{} + var roleIDs []int64 + for _, roleID := range d.Get("role_ids").(*schema.Set).List() { + roleIDs = append(roleIDs, roleID.(int64)) + } - _, err = client.User.SetUserRoles(params) + _, err = client.SetUserRoles(userID, roleIDs, "", nil) if err != nil { return err } - return nil + return resourceUserRolesRead(d, m) } -func resourceUserRolesExists(d *schema.ResourceData, m interface{}) (b bool, e error) { - // Exists - This is called to verify a resource still exists. It is called prior to Read, - // and lowers the burden of Read to be able to assume the resource exists. - client := m.(*apiclient.LookerAPI30Reference) +func resourceUserRolesDelete(d *schema.ResourceData, m interface{}) error { + client := m.(*apiclient.LookerSDK) - userID, err := getIDFromString(d.Id()) + userID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { - return false, err + return err } - // TODO: as long as the user exists, we will say the "roles" exist. Not sure if this is correct though? - params := user.NewUserParams() - params.UserID = userID - - _, err = client.User.User(params) + roleIDs := []int64{} + _, err = client.SetUserRoles(userID, roleIDs, "", nil) if err != nil { - if strings.Contains(err.Error(), "Not found") { - return false, nil - } - - return false, err + return err } - return true, nil + return nil } func resourceUserRolesImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 1eb4afe..bb655b3 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -6,7 +6,7 @@ description: Manage Looker with Terraform. # Looker Provider This is a terraform provider plugin for managing [Looker](https://www.looker.com/) accounts. -Coverage is focused on part of Looker related to access control. +Coverage is focused on the part of Looker related to access control. ## Example Provider Configuration From fcd16539bea08f52efe2de7ccadc5d1c15a01162 Mon Sep 17 00:00:00 2001 From: Adam Boscarino Date: Fri, 11 Jun 2021 00:21:24 +0000 Subject: [PATCH 2/3] add acceptance tests --- Makefile | 18 +- examples/resources/looker_role/resource.tf | 2 +- .../resources/looker_role_groups/resource.tf | 4 +- go.mod | 7 +- go.sum | 191 +----------------- pkg/looker/helpers_test.go | 10 + pkg/looker/provider.go | 25 ++- pkg/looker/provider_test.go | 36 ++++ pkg/looker/resource_group.go | 2 +- pkg/looker/resource_group_test.go | 47 +++++ pkg/looker/resource_model_set.go | 3 +- pkg/looker/resource_model_set_test.go | 50 +++++ pkg/looker/resource_permission_set_test.go | 50 +++++ pkg/looker/resource_role.go | 42 ++-- pkg/looker/resource_role_groups.go | 21 +- pkg/looker/resource_role_groups_test.go | 57 ++++++ pkg/looker/resource_role_test.go | 50 +++++ pkg/looker/resource_user_roles.go | 21 +- pkg/looker/resource_user_roles_test.go | 60 ++++++ pkg/looker/resource_user_test.go | 54 +++++ 20 files changed, 520 insertions(+), 230 deletions(-) create mode 100644 pkg/looker/helpers_test.go create mode 100644 pkg/looker/provider_test.go create mode 100644 pkg/looker/resource_group_test.go create mode 100644 pkg/looker/resource_model_set_test.go create mode 100644 pkg/looker/resource_permission_set_test.go create mode 100644 pkg/looker/resource_role_groups_test.go create mode 100644 pkg/looker/resource_role_test.go create mode 100644 pkg/looker/resource_user_roles_test.go create mode 100644 pkg/looker/resource_user_test.go diff --git a/Makefile b/Makefile index 1233f29..86c3d9f 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ help: .PHONY: vendor vendor: go.sum ## vendor dependencies - GO111MODULE=on go mod vendor - GO111MODULE=on go mod tidy + @GO111MODULE=on go mod vendor + @GO111MODULE=on go mod tidy .PHONY: lint lint: ## run linter @@ -18,19 +18,23 @@ lint: ## run linter test: ## run tests @go test -v -cover -race $(shell go list ./... | grep -v vendor) +.PHONY: test-acceptance +test-acceptance: ## runs all tests, including the acceptance tests + @TF_ACC=1 $(go_test) go test -v -cover $(shell go list ./... | grep -v vendor) + .PHONY: build build: ## build binary - go build -o build/$(BASE_BINARY_NAME) . + @go build -o build/$(BASE_BINARY_NAME) . .PHONY: docs docs: ## generate docs - go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs + @go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs .PHONY: check-docs check-docs: docs ## check that docs have been generated - git diff --exit-code -- docs + @git diff --exit-code -- docs .PHONY: check-mod check-mod: ## check go.mod is up-to-date - go mod tidy - git diff --exit-code -- go.mod go.sum + @go mod tidy + @git diff --exit-code -- go.mod go.sum diff --git a/examples/resources/looker_role/resource.tf b/examples/resources/looker_role/resource.tf index 5700adf..f4d0dbf 100644 --- a/examples/resources/looker_role/resource.tf +++ b/examples/resources/looker_role/resource.tf @@ -1,5 +1,5 @@ resource "looker_role" "role" { name = "Role" - permission_set_id = looker_permission_set.embed_permission_set.id + permission_set_id = looker_permission_set.permission_set.id model_set_id = looker_model_set.model_set.id } diff --git a/examples/resources/looker_role_groups/resource.tf b/examples/resources/looker_role_groups/resource.tf index 3a95142..b40e70b 100644 --- a/examples/resources/looker_role_groups/resource.tf +++ b/examples/resources/looker_role_groups/resource.tf @@ -1,4 +1,4 @@ resource "looker_role_groups" "role_groups" { - role_id = looker_role.embed_role.id - group_ids = ["${looker_group.embed_group.id}"] + role_id = looker_role.role.id + group_ids = [looker_group.group.id] } diff --git a/go.mod b/go.mod index 552af07..f9a4106 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,12 @@ module github.com/DevotedHealth/terraform-provider-looker go 1.15 require ( - github.com/billtrust/looker-go-sdk v0.0.0-20190925193822-162d0cd95cb7 - github.com/go-openapi/runtime v0.19.28 // indirect - github.com/go-openapi/strfmt v0.20.1 // indirect + github.com/aws/aws-sdk-go v1.34.28 // indirect github.com/hashicorp/terraform-plugin-docs v0.4.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.4 github.com/looker-open-source/sdk-codegen/go v0.0.1 + github.com/mitchellh/mapstructure v1.3.3 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect + golang.org/x/text v0.3.5 // indirect + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect ) diff --git a/go.sum b/go.sum index 337bd9b..fde766d 100644 --- a/go.sum +++ b/go.sum @@ -40,11 +40,6 @@ github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3Q github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -54,6 +49,7 @@ github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/g github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U= github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= @@ -66,12 +62,6 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26 github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= -github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPIk= @@ -80,8 +70,6 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/billtrust/looker-go-sdk v0.0.0-20190925193822-162d0cd95cb7 h1:1eMn6zbC1M5qKQwYufEnO4TQegVXsQRKqVRgHl4ehNQ= -github.com/billtrust/looker-go-sdk v0.0.0-20190925193822-162d0cd95cb7/go.mod h1:pL97VUNzILI3wd2Cmb8EXJTlnrdfFKFrTuHoTxo8TdQ= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -93,8 +81,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -107,8 +93,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjr github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= @@ -120,101 +104,9 @@ github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJA github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= -github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= -github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= -github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= -github.com/go-openapi/analysis v0.19.10 h1:5BHISBAXOc/aJK25irLZnx2D3s6WyYaY9D4gmuz9fdE= -github.com/go-openapi/analysis v0.19.10/go.mod h1:qmhS3VNFxBlquFJ0RGoDtylO9y4pgTAUNE9AEEMdlJQ= -github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= -github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= -github.com/go-openapi/errors v0.19.6/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.19.8 h1:doM+tQdZbUm9gydV9yR+iQNmztbjj7I3sW4sIcAwIzc= -github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= -github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= -github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI= -github.com/go-openapi/loads v0.19.5 h1:jZVYWawIQiA1NBnHla28ktg6hrcfTHsCE+3QLVRBIls= -github.com/go-openapi/loads v0.19.5/go.mod h1:dswLCAdonkRufe/gSUC3gN8nTSaB9uaS2es0x5/IbjY= -github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= -github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= -github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= -github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= -github.com/go-openapi/runtime v0.19.28 h1:9lYu6axek8LJrVkMVViVirRcpoaCxXX7+sSvmizGVnA= -github.com/go-openapi/runtime v0.19.28/go.mod h1:BvrQtn6iVb2QmiVXRsFAm6ZCAZBpbVKFfN6QWCp582M= -github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= -github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/spec v0.19.6/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= -github.com/go-openapi/spec v0.19.8 h1:qAdZLh1r6QF/hI/gTq+TJTvsQUodZsM7KLqkAJdiJNg= -github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= -github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= -github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= -github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= -github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= -github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= -github.com/go-openapi/strfmt v0.20.1 h1:1VgxvehFne1mbChGeCmZ5pc0LxUf6yaACVSIYAR91Xc= -github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk= -github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= -github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE= -github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= -github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= -github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= -github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= -github.com/go-openapi/validate v0.19.10 h1:tG3SZ5DC5KF4cyt7nqLVcQXGj5A7mpaYkAcNPlDK+Yk= -github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -264,8 +156,6 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -306,6 +196,7 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= +github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.12.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= github.com/hashicorp/terraform-exec v0.13.0 h1:1Pth+pdWJAufJuWWjaVOVNEkoRTOjGn3hQpAqj4aPdg= @@ -327,7 +218,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -339,26 +229,18 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -367,14 +249,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/looker-open-source/sdk-codegen/go v0.0.1 h1:4urA2OZ3Z9YRwINNJ2wjaZqMHwD5114RJQT5tWX0gvw= github.com/looker-open-source/sdk-codegen/go v0.0.1/go.mod h1:JxOlImdS7EdABZUGACwR1U0GBA/QolfXAqTPoo7fPfs= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8= -github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= @@ -402,28 +276,18 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -432,34 +296,23 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -470,12 +323,6 @@ github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+ github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -484,29 +331,17 @@ github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q github.com/zclconf/go-cty v1.7.1 h1:AvsC01GMhMLFL8CgEYdHGM+yLnnDOwhPAYcgTkeF0Gw= github.com/zclconf/go-cty v1.7.1/go.mod h1:VDR4+I79ubFBGm1uJac1226K5yANQFHeauxPBoP54+o= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= -go.mongodb.org/mongo-driver v1.3.4/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= -go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2azI= -go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -548,20 +383,16 @@ golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -573,7 +404,6 @@ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -587,29 +417,21 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -641,23 +463,16 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -779,14 +594,12 @@ gopkg.in/ini.v1 v1.61.0 h1:LBCdW4FmFYL4s/vDZD1RQYX7oAR6IjujCYgMdbHBR10= gopkg.in/ini.v1 v1.61.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pkg/looker/helpers_test.go b/pkg/looker/helpers_test.go new file mode 100644 index 0000000..8397bca --- /dev/null +++ b/pkg/looker/helpers_test.go @@ -0,0 +1,10 @@ +package looker + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func providers() map[string]*schema.Provider { + p := Provider() + return map[string]*schema.Provider{ + "looker": p, + } +} diff --git a/pkg/looker/provider.go b/pkg/looker/provider.go index b46bb00..528b547 100644 --- a/pkg/looker/provider.go +++ b/pkg/looker/provider.go @@ -6,6 +6,10 @@ import ( apiclient "github.com/looker-open-source/sdk-codegen/go/sdk/v4" ) +const ( + defaultAPIVersion = "4.0" +) + func Provider() *schema.Provider { return &schema.Provider{ Schema: map[string]*schema.Schema{ @@ -27,6 +31,21 @@ func Provider() *schema.Provider { DefaultFunc: schema.EnvDefaultFunc("LOOKER_API_BASE_URL", nil), Description: "Looker API Base URL", }, + "api_version": { + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("LOOKER_API_VERSION", defaultAPIVersion), + }, + "verify_ssl": { + Type: schema.TypeBool, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("LOOKER_VERIFY_SSL", true), + }, + "timeout": { + Type: schema.TypeInt, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("LOOKER_TIMEOUT", nil), + }, }, ResourcesMap: map[string]*schema.Resource{ "looker_user": resourceUser(), @@ -47,12 +66,16 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { baseUrl := d.Get("base_url").(string) clientID := d.Get("client_id").(string) clientSecret := d.Get("client_secret").(string) + apiVersion := d.Get("api_version").(string) + timeout := d.Get("timeout").(int) apiSettings := rtl.ApiSettings{ BaseUrl: baseUrl, ClientId: clientID, ClientSecret: clientSecret, - ApiVersion: "4.0", + ApiVersion: apiVersion, + VerifySsl: d.Get("verify_ssl").(bool), + Timeout: int32(timeout), } authSession := rtl.NewAuthSession(apiSettings) client := apiclient.NewLookerSDK(authSession) diff --git a/pkg/looker/provider_test.go b/pkg/looker/provider_test.go new file mode 100644 index 0000000..2b12f91 --- /dev/null +++ b/pkg/looker/provider_test.go @@ -0,0 +1,36 @@ +package looker + +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +var testAccProviders map[string]*schema.Provider +var testAccProvider *schema.Provider + +func init() { + testAccProvider = Provider() + testAccProviders = map[string]*schema.Provider{ + "looker": testAccProvider, + } +} + +func TestProvider(t *testing.T) { + if err := Provider().InternalValidate(); err != nil { + t.Fatalf("err: %s", err) + } +} + +func testAccPreCheck(t *testing.T) { + if err := os.Getenv("LOOKER_API_BASE_URL"); err == "" { + t.Fatal("LOOKER_API_BASE_URL must be set for acceptance tests") + } + if err := os.Getenv("LOOKER_API_CLIENT_ID"); err == "" { + t.Fatal("LOOKER_API_CLIENT_ID must be set for acceptance tests") + } + if err := os.Getenv("LOOKER_API_CLIENT_SECRET"); err == "" { + t.Fatal("LOOKER_API_CLIENT_SECRET must be set for acceptance tests") + } +} diff --git a/pkg/looker/resource_group.go b/pkg/looker/resource_group.go index 6a970f5..d26d28d 100644 --- a/pkg/looker/resource_group.go +++ b/pkg/looker/resource_group.go @@ -58,7 +58,7 @@ func resourceGroupRead(d *schema.ResourceData, m interface{}) error { return err } - if err = d.Set("group", group.Name); err != nil { + if err = d.Set("name", group.Name); err != nil { return err } diff --git a/pkg/looker/resource_group_test.go b/pkg/looker/resource_group_test.go new file mode 100644 index 0000000..b669dba --- /dev/null +++ b/pkg/looker/resource_group_test.go @@ -0,0 +1,47 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_Group(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + name2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: groupConfig(name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_group.test", "name", name1), + ), + }, + { + Config: groupConfig(name2), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_group.test", "name", name2), + ), + }, + { + ResourceName: "looker_group.test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func groupConfig(name string) string { + return fmt.Sprintf(` + resource "looker_group" "test" { + name = "%s" + } + `, name) +} diff --git a/pkg/looker/resource_model_set.go b/pkg/looker/resource_model_set.go index 970386d..2f1ba5d 100644 --- a/pkg/looker/resource_model_set.go +++ b/pkg/looker/resource_model_set.go @@ -87,7 +87,6 @@ func resourceModelSetUpdate(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - modelSetName := d.Get("name").(string) var modelNames []string for _, modelName := range d.Get("models").(*schema.Set).List() { @@ -102,7 +101,7 @@ func resourceModelSetUpdate(d *schema.ResourceData, m interface{}) error { return err } - return resourceModelSetCreate(d, m) + return resourceModelSetRead(d, m) } func resourceModelSetDelete(d *schema.ResourceData, m interface{}) error { diff --git a/pkg/looker/resource_model_set_test.go b/pkg/looker/resource_model_set_test.go new file mode 100644 index 0000000..51270b8 --- /dev/null +++ b/pkg/looker/resource_model_set_test.go @@ -0,0 +1,50 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_ModelSet(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + name2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: modelSetConfig(name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_model_set.test", "name", name1), + resource.TestCheckResourceAttr("looker_model_set.test", "models.#", "1"), + ), + }, + { + Config: modelSetConfig(name2), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_model_set.test", "name", name2), + resource.TestCheckResourceAttr("looker_model_set.test", "models.#", "1"), + ), + }, + { + ResourceName: "looker_model_set.test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func modelSetConfig(name string) string { + return fmt.Sprintf(` + resource "looker_model_set" "test" { + name = "%s" + models = ["test"] + } + `, name) +} diff --git a/pkg/looker/resource_permission_set_test.go b/pkg/looker/resource_permission_set_test.go new file mode 100644 index 0000000..2cf5eee --- /dev/null +++ b/pkg/looker/resource_permission_set_test.go @@ -0,0 +1,50 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_PermissionSet(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + name2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: permissionSetConfig(name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_permission_set.test", "name", name1), + resource.TestCheckResourceAttr("looker_permission_set.test", "permissions.#", "1"), + ), + }, + { + Config: permissionSetConfig(name2), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_permission_set.test", "name", name2), + resource.TestCheckResourceAttr("looker_permission_set.test", "permissions.#", "1"), + ), + }, + { + ResourceName: "looker_permission_set.test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func permissionSetConfig(name string) string { + return fmt.Sprintf(` + resource "looker_permission_set" "test" { + name = "%s" + permissions = ["test"] + } + `, name) +} diff --git a/pkg/looker/resource_role.go b/pkg/looker/resource_role.go index ff1a4c9..0023913 100644 --- a/pkg/looker/resource_role.go +++ b/pkg/looker/resource_role.go @@ -23,11 +23,11 @@ func resourceRole() *schema.Resource { Required: true, }, "permission_set_id": { - Type: schema.TypeInt, + Type: schema.TypeString, Required: true, }, "model_set_id": { - Type: schema.TypeInt, + Type: schema.TypeString, Required: true, }, }, @@ -38,13 +38,21 @@ func resourceRoleCreate(d *schema.ResourceData, m interface{}) error { client := m.(*apiclient.LookerSDK) roleName := d.Get("name").(string) - permissionSetID := d.Get("permission_set_id").(int64) - modelSetID := d.Get("model_set_id").(int64) + permissionSetID := d.Get("permission_set_id").(string) + modelSetID := d.Get("model_set_id").(string) + pSetID, err := strconv.ParseInt(permissionSetID, 10, 64) + if err != nil { + return err + } + mSetID, err := strconv.ParseInt(modelSetID, 10, 64) + if err != nil { + return err + } writeRole := apiclient.WriteRole{ Name: &roleName, - PermissionSetId: &permissionSetID, - ModelSetId: &modelSetID, + PermissionSetId: &pSetID, + ModelSetId: &mSetID, } role, err := client.CreateRole(writeRole, nil) @@ -74,10 +82,12 @@ func resourceRoleRead(d *schema.ResourceData, m interface{}) error { if err = d.Set("name", role.Name); err != nil { return err } - if err = d.Set("permission_set_id", role.PermissionSetId); err != nil { + pSetID := strconv.Itoa(int(*role.PermissionSet.Id)) + if err = d.Set("permission_set_id", pSetID); err != nil { return err } - if err = d.Set("model_set_id", role.ModelSetId); err != nil { + mSetID := strconv.Itoa(int(*role.ModelSet.Id)) + if err = d.Set("model_set_id", mSetID); err != nil { return err } @@ -93,12 +103,20 @@ func resourceRoleUpdate(d *schema.ResourceData, m interface{}) error { } roleName := d.Get("name").(string) - permissionSetID := d.Get("permission_set_id").(int64) - modelSetID := d.Get("model_set_id").(int64) + permissionSetID := d.Get("permission_set_id").(string) + modelSetID := d.Get("model_set_id").(string) + pSetID, err := strconv.ParseInt(permissionSetID, 10, 64) + if err != nil { + return err + } + mSetID, err := strconv.ParseInt(modelSetID, 10, 64) + if err != nil { + return err + } writeRole := apiclient.WriteRole{ Name: &roleName, - PermissionSetId: &permissionSetID, - ModelSetId: &modelSetID, + PermissionSetId: &pSetID, + ModelSetId: &mSetID, } _, err = client.UpdateRole(roleID, writeRole, nil) if err != nil { diff --git a/pkg/looker/resource_role_groups.go b/pkg/looker/resource_role_groups.go index 77be01b..e201a72 100644 --- a/pkg/looker/resource_role_groups.go +++ b/pkg/looker/resource_role_groups.go @@ -25,7 +25,7 @@ func resourceRoleGroups() *schema.Resource { "group_ids": { Type: schema.TypeSet, Required: true, - Elem: &schema.Schema{Type: schema.TypeInt}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, } @@ -43,7 +43,11 @@ func resourceRoleGroupsCreate(d *schema.ResourceData, m interface{}) error { var groupIDs []int64 for _, groupID := range d.Get("group_ids").(*schema.Set).List() { - groupIDs = append(groupIDs, groupID.(int64)) + gID, err := strconv.ParseInt(groupID.(string), 10, 64) + if err != nil { + return err + } + groupIDs = append(groupIDs, gID) } _, err = client.SetRoleGroups(roleID, groupIDs, nil) @@ -69,12 +73,13 @@ func resourceRoleGroupsRead(d *schema.ResourceData, m interface{}) error { return err } - var groupIDs []int64 + var groupIDs []string for _, group := range groups { - groupIDs = append(groupIDs, *group.Id) + gID := strconv.Itoa(int(*group.Id)) + groupIDs = append(groupIDs, gID) } - if err = d.Set("role_id", roleID); err != nil { + if err = d.Set("role_id", strconv.Itoa(int(roleID))); err != nil { return err } @@ -95,7 +100,11 @@ func resourceRoleGroupsUpdate(d *schema.ResourceData, m interface{}) error { var groupIDs []int64 for _, groupID := range d.Get("group_ids").(*schema.Set).List() { - groupIDs = append(groupIDs, groupID.(int64)) + gID, err := strconv.ParseInt(groupID.(string), 10, 64) + if err != nil { + return err + } + groupIDs = append(groupIDs, gID) } _, err = client.SetRoleGroups(roleID, groupIDs, nil) diff --git a/pkg/looker/resource_role_groups_test.go b/pkg/looker/resource_role_groups_test.go new file mode 100644 index 0000000..61bb9ce --- /dev/null +++ b/pkg/looker/resource_role_groups_test.go @@ -0,0 +1,57 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_RoleGroups(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: roleGroupsConfig(name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_role_groups.test", "group_ids.#", "1"), + ), + }, + { + ResourceName: "looker_role_groups.test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func roleGroupsConfig(name string) string { + return fmt.Sprintf(` + resource "looker_group" "test" { + name = "%s" + } + resource "looker_model_set" "test" { + name = "%s" + models = ["test"] + } + resource "looker_permission_set" "test" { + name = "%s" + permissions = ["test"] + } + resource "looker_role" "test" { + name = "%s" + permission_set_id = looker_permission_set.test.id + model_set_id = looker_model_set.test.id + } + resource "looker_role_groups" "test" { + role_id = looker_role.test.id + group_ids = [looker_group.test.id] + } + `, name, name, name, name) +} diff --git a/pkg/looker/resource_role_test.go b/pkg/looker/resource_role_test.go new file mode 100644 index 0000000..e15aff1 --- /dev/null +++ b/pkg/looker/resource_role_test.go @@ -0,0 +1,50 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_Role(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: roleConfig(name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_role.role_test", "name", name1), + ), + }, + { + ResourceName: "looker_role.role_test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func roleConfig(name string) string { + return fmt.Sprintf(` + resource "looker_model_set" "role_test" { + name = "%s" + models = ["test"] + } + resource "looker_permission_set" "role_test" { + name = "%s" + permissions = ["test"] + } + resource "looker_role" "role_test" { + name = "%s" + permission_set_id = looker_permission_set.role_test.id + model_set_id = looker_model_set.role_test.id + } + `, name, name, name) +} diff --git a/pkg/looker/resource_user_roles.go b/pkg/looker/resource_user_roles.go index 7a035fb..b1b59a9 100644 --- a/pkg/looker/resource_user_roles.go +++ b/pkg/looker/resource_user_roles.go @@ -25,7 +25,7 @@ func resourceUserRoles() *schema.Resource { "role_ids": { Type: schema.TypeSet, Required: true, - Elem: &schema.Schema{Type: schema.TypeInt}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, } @@ -43,7 +43,11 @@ func resourceUserRolesCreate(d *schema.ResourceData, m interface{}) error { var roleIDs []int64 for _, roleID := range d.Get("role_ids").(*schema.Set).List() { - roleIDs = append(roleIDs, roleID.(int64)) + rID, err := strconv.ParseInt(roleID.(string), 10, 64) + if err != nil { + return err + } + roleIDs = append(roleIDs, rID) } _, err = client.SetUserRoles(userID, roleIDs, "", nil) @@ -71,12 +75,13 @@ func resourceUserRolesRead(d *schema.ResourceData, m interface{}) error { return err } - var roleIDs []int64 + var roleIDs []string for _, role := range userRoles { - roleIDs = append(roleIDs, *role.Id) + rID := strconv.Itoa(int(*role.Id)) + roleIDs = append(roleIDs, rID) } - if err = d.Set("user_id", userID); err != nil { + if err = d.Set("user_id", d.Id()); err != nil { return err } @@ -97,7 +102,11 @@ func resourceUserRolesUpdate(d *schema.ResourceData, m interface{}) error { var roleIDs []int64 for _, roleID := range d.Get("role_ids").(*schema.Set).List() { - roleIDs = append(roleIDs, roleID.(int64)) + rID, err := strconv.ParseInt(roleID.(string), 10, 64) + if err != nil { + return err + } + roleIDs = append(roleIDs, rID) } _, err = client.SetUserRoles(userID, roleIDs, "", nil) diff --git a/pkg/looker/resource_user_roles_test.go b/pkg/looker/resource_user_roles_test.go new file mode 100644 index 0000000..dbf166a --- /dev/null +++ b/pkg/looker/resource_user_roles_test.go @@ -0,0 +1,60 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_UserRoles(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + email := "test@example.com" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: userRolesConfig(name1, email), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_user_roles.user_role_test", "role_ids.#", "1"), + ), + }, + { + ResourceName: "looker_user_roles.user_role_test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func userRolesConfig(name, email string) string { + return fmt.Sprintf(` + resource "looker_user" "user_role_test" { + first_name = "%s" + last_name = "%s" + email = "%s" + } + resource "looker_model_set" "user_role_test" { + name = "%s" + models = ["test"] + } + resource "looker_permission_set" "user_role_test" { + name = "%s" + permissions = ["test"] + } + resource "looker_role" "user_role_test" { + name = "%s" + permission_set_id = looker_permission_set.user_role_test.id + model_set_id = looker_model_set.user_role_test.id + } + resource "looker_user_roles" "user_role_test" { + user_id = looker_user.user_role_test.id + role_ids = [looker_role.user_role_test.id] + } + `, name, name, email, name, name, name) +} diff --git a/pkg/looker/resource_user_test.go b/pkg/looker/resource_user_test.go new file mode 100644 index 0000000..c56b3b9 --- /dev/null +++ b/pkg/looker/resource_user_test.go @@ -0,0 +1,54 @@ +package looker + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAcc_User(t *testing.T) { + name1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + name2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + email := "test2@example.com" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: providers(), + Steps: []resource.TestStep{ + { + Config: userConfig(name1, name1, email), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_user.test", "first_name", name1), + resource.TestCheckResourceAttr("looker_user.test", "last_name", name1), + resource.TestCheckResourceAttr("looker_user.test", "email", email), + ), + }, + { + Config: userConfig(name2, name2, email), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("looker_user.test", "first_name", name2), + resource.TestCheckResourceAttr("looker_user.test", "last_name", name2), + resource.TestCheckResourceAttr("looker_user.test", "email", email), + ), + }, + { + ResourceName: "looker_user.test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func userConfig(firstName, lastName, email string) string { + return fmt.Sprintf(` + resource "looker_user" "test" { + first_name = "%s" + last_name = "%s" + email = "%s" + } + `, firstName, lastName, email) +} From 68b48103f58658b74c767f821a4d8a4b5e995b6f Mon Sep 17 00:00:00 2001 From: Adam Boscarino Date: Fri, 11 Jun 2021 00:22:17 +0000 Subject: [PATCH 3/3] update docs --- docs/resources/role.md | 6 +++--- docs/resources/role_groups.md | 4 ++-- docs/resources/user_roles.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/resources/role.md b/docs/resources/role.md index f35008d..ce81086 100644 --- a/docs/resources/role.md +++ b/docs/resources/role.md @@ -15,7 +15,7 @@ description: |- ```terraform resource "looker_role" "role" { name = "Role" - permission_set_id = looker_permission_set.embed_permission_set.id + permission_set_id = looker_permission_set.permission_set.id model_set_id = looker_model_set.model_set.id } ``` @@ -25,9 +25,9 @@ resource "looker_role" "role" { ### Required -- **model_set_id** (Number) +- **model_set_id** (String) - **name** (String) -- **permission_set_id** (Number) +- **permission_set_id** (String) ### Optional diff --git a/docs/resources/role_groups.md b/docs/resources/role_groups.md index 3e232f6..179e440 100644 --- a/docs/resources/role_groups.md +++ b/docs/resources/role_groups.md @@ -14,8 +14,8 @@ description: |- ```terraform resource "looker_role_groups" "role_groups" { - role_id = looker_role.embed_role.id - group_ids = ["${looker_group.embed_group.id}"] + role_id = looker_role.role.id + group_ids = [looker_group.group.id] } ``` diff --git a/docs/resources/user_roles.md b/docs/resources/user_roles.md index 99e08ba..ad70f99 100644 --- a/docs/resources/user_roles.md +++ b/docs/resources/user_roles.md @@ -24,7 +24,7 @@ resource "looker_user_roles" "user_roles" { ### Required -- **role_ids** (Set of Number) +- **role_ids** (Set of String) - **user_id** (String) ### Optional