forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
49 lines (41 loc) · 1.05 KB
/
Copy pathconfig.go
File metadata and controls
49 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package controller
import (
"context"
"fmt"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/ui"
)
func (c *Controller) GetProjectConfigs(ctx context.Context) (*entity.ProjectConfig, error) {
if c.cfg.RailwayProductionToken != "" {
// Get project config from api
projectToken, err := c.gtwy.GetProjectToken(ctx)
if err != nil {
return nil, err
}
if projectToken != nil {
return &entity.ProjectConfig{
Project: projectToken.ProjectId,
Environment: projectToken.EnvironmentId,
LockedEnvsNames: map[string]bool{},
}, nil
}
}
return c.cfg.GetProjectConfigs()
}
func (c *Controller) PromptIfProtectedEnvironment(ctx context.Context) error {
projectCfg, err := c.GetProjectConfigs(ctx)
if err != nil {
return err
}
if val, ok := projectCfg.LockedEnvsNames[projectCfg.Environment]; ok && val {
fmt.Println(ui.Bold(ui.RedText("Protected Environment Detected!").String()))
confirm, err := ui.PromptYesNo("Continue?")
if err != nil {
return err
}
if !confirm {
return nil
}
}
return nil
}