Skip to content

Commit

Permalink
feat: enable watching status on resources (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockopp authored Feb 17, 2020
1 parent 590ed39 commit 58b82fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/vela-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func main() {
Usage: "maximum duration to watch status on kubernetes resources",
Value: 5 * time.Minute,
},
cli.BoolTFlag{
EnvVar: "PARAMETER_WATCH,STATUS_WATCH",
Name: "status.watch",
Usage: "enables watching the status until the rollout completes",
},
}

err := app.Run(os.Args)
Expand Down Expand Up @@ -163,6 +168,7 @@ func run(c *cli.Context) error {
Status: &Status{
Resources: c.StringSlice("status.resources"),
Timeout: c.Duration("status.timeout"),
Watch: c.BoolT("status.watch"),
},
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/vela-kubernetes/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Status struct {
Resources []string
// total time allowed to watch Kubernetes resources
Timeout time.Duration
// enables watching the status until the rollout completes
Watch bool
}

// Command formats and outputs the Status command from the
Expand Down Expand Up @@ -56,7 +58,7 @@ func (s *Status) Command(c *Config, resource string) *exec.Cmd {
}

// add flag for watching status of rollout until it finishes
flags = append(flags, "--watch=true")
flags = append(flags, fmt.Sprintf("--watch=%v", s.Watch))

return exec.Command(kubectlBin, flags...)
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/vela-kubernetes/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestKubernetes_Status_Command(t *testing.T) {
s := &Status{
Resources: []string{"resources"},
Timeout: 5 * time.Minute,
Watch: true,
}

for _, resource := range s.Resources {
Expand Down Expand Up @@ -56,6 +57,7 @@ func TestKubernetes_Status_Exec_Error(t *testing.T) {
s := &Status{
Resources: []string{"resources"},
Timeout: 5 * time.Minute,
Watch: true,
}

err := s.Exec(c)
Expand All @@ -69,6 +71,7 @@ func TestKubernetes_Status_Validate(t *testing.T) {
s := &Status{
Resources: []string{"resources"},
Timeout: 5 * time.Minute,
Watch: true,
}

err := s.Validate()
Expand All @@ -81,6 +84,7 @@ func TestKubernetes_Status_Validate_NoResources(t *testing.T) {
// setup types
s := &Status{
Timeout: 5 * time.Minute,
Watch: true,
}

err := s.Validate()
Expand All @@ -93,6 +97,7 @@ func TestKubernetes_Status_Validate_NoTimeout(t *testing.T) {
// setup types
s := &Status{
Resources: []string{"resources"},
Watch: true,
}

err := s.Validate()
Expand Down

0 comments on commit 58b82fc

Please sign in to comment.