diff --git a/.changelog/63.txt b/.changelog/63.txt new file mode 100644 index 00000000..4d044882 --- /dev/null +++ b/.changelog/63.txt @@ -0,0 +1,3 @@ +```release-note:improvement +A better error message is now returned if a user attempts to read a Waypoint TFC Config when one has not been set +``` diff --git a/internal/commands/waypoint/tfcconfig/tfc_config_read.go b/internal/commands/waypoint/tfcconfig/tfc_config_read.go index 939532e8..d36fbf1e 100644 --- a/internal/commands/waypoint/tfcconfig/tfc_config_read.go +++ b/internal/commands/waypoint/tfcconfig/tfc_config_read.go @@ -5,6 +5,7 @@ package tfcconfig import ( "context" + "fmt" "github.com/hashicorp/hcp-sdk-go/clients/cloud-waypoint-service/preview/2023-08-18/client/waypoint_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-waypoint-service/preview/2023-08-18/models" @@ -67,6 +68,11 @@ func readRun(opts *TFCConfigReadOpts) error { if err != nil { return errors.Wrapf(err, "%s failed to get TFC Config", opts.IO.ColorScheme().FailureIcon()) } + if resp.Payload.TfcConfig == nil { + fmt.Fprintf(opts.IO.Out(), "%s No TFC Config found for this project\n", + opts.IO.ColorScheme().FailureIcon()) + return nil + } d := newDisplayer(format.Pretty, resp.Payload.TfcConfig) return opts.Output.Display(d) }