From 94128d683c621a2d73a59bfddad371ff7d2bf3d3 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 10 Mar 2022 19:59:24 -0600 Subject: [PATCH] Add consts for targets and treat empty as prod --- internal/codespaces/api/api.go | 7 +++++++ pkg/cmd/codespace/list.go | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/codespaces/api/api.go b/internal/codespaces/api/api.go index 2a859f3ac..790ad0ee4 100644 --- a/internal/codespaces/api/api.go +++ b/internal/codespaces/api/api.go @@ -52,6 +52,13 @@ const ( vscsAPI = "https://online.visualstudio.com" ) +const ( + VSCSTargetLocal = "local" + VSCSTargetDevelopment = "development" + VSCSTargetPPE = "ppe" + VSCSTargetProduction = "production" +) + // API is the interface to the codespace service. type API struct { client httpClient diff --git a/pkg/cmd/codespace/list.go b/pkg/cmd/codespace/list.go index 987ed00af..17c7b6414 100644 --- a/pkg/cmd/codespace/list.go +++ b/pkg/cmd/codespace/list.go @@ -45,8 +45,9 @@ func (a *App) List(ctx context.Context, limit int, exporter cmdutil.Exporter) er hasNonProdVSCSTarget := false for _, apiCodespace := range codespaces { - if apiCodespace.VSCSTarget != "prod" { + if apiCodespace.VSCSTarget != "" && apiCodespace.VSCSTarget != api.VSCSTargetProduction { hasNonProdVSCSTarget = true + break } } @@ -114,11 +115,11 @@ func (a *App) List(ctx context.Context, limit int, exporter cmdutil.Exporter) er } func formatNameForVSCSTarget(name, vscsTarget string) string { - if vscsTarget == "dev" || vscsTarget == "local" { + if vscsTarget == api.VSCSTargetDevelopment || vscsTarget == api.VSCSTargetLocal { return fmt.Sprintf("%s 🚧", name) } - if vscsTarget == "ppe" { + if vscsTarget == api.VSCSTargetPPE { return fmt.Sprintf("%s ✨", name) }