Add consts for targets and treat empty as prod

This commit is contained in:
GitHub Action 2022-03-10 19:59:24 -06:00
parent 5e62a417d8
commit 94128d683c
2 changed files with 11 additions and 3 deletions

View file

@ -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

View file

@ -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)
}