From 9d94ef2c8a242a94dc6bdfd8501133d6d5a7cbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Mon, 30 Mar 2020 14:49:24 -0500 Subject: [PATCH] Fix error preventing to create a workspace (#18) Fixes a bug preventing to create a new workspace. Drive-by: * Displays a message when deleting a workspace successfully. Fixes rgreinho/tfe-cli#17 --- CHANGELOG.md | 5 +++++ cmd/workspace.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b83d264..f417695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Ability to detect HCL variables from a varfile. [#14] * Ability to delete workspaces. [#15] +### Fixed + +- Fix problem preventing to create a workspace. [#18] + ## [1.0.0] - 2020-03-25 Initial version with support for managing: @@ -25,3 +29,4 @@ Initial version with support for managing: [//]: # (Issue/PR links) [#14]: https://github.com/rgreinho/tfe-cli/pull/14 [#15]: https://github.com/rgreinho/tfe-cli/pull/15 +[#18]: https://github.com/rgreinho/tfe-cli/pull/18 diff --git a/cmd/workspace.go b/cmd/workspace.go index eb8ae9b..b4fe705 100644 --- a/cmd/workspace.go +++ b/cmd/workspace.go @@ -43,7 +43,9 @@ var workspaceCreateCmd = &cobra.Command{ // Check whether the workspace exists. w, err := readWorkspace(client, organization, name) if err != nil { - log.Fatalf("Cannot retrieve workspace %q: %s.", name, err) + if !strings.Contains(err.Error(), "resource not found") { + log.Fatalf("Cannot retrieve workspace %q: %s.", name, err) + } } // Update the workspace if needed. @@ -121,6 +123,8 @@ var workspaceDeleteCmd = &cobra.Command{ if err := deleteWorkspace(client, organization, name); err != nil { log.Fatalf("Cannot delete workspace %q: %s.", name, err) } + + log.Infof("Workspace %q deleted successfully.", name) }, }