Skip to content

Commit f3b56f4

Browse files
authored
Merge pull request #244 from shalb/disable-stack
stack disabled, message about usage stats moved to INFO log level
2 parents c2f0fb5 + 14810df commit f3b56f4

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

pkg/cmd/cdev/apply.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package cdev
22

33
import (
4+
"github.com/apex/log"
45
"github.com/shalb/cluster.dev/pkg/config"
56
"github.com/shalb/cluster.dev/pkg/project"
7+
"github.com/shalb/cluster.dev/pkg/utils"
68
"github.com/spf13/cobra"
79
)
810

@@ -14,7 +16,9 @@ var applyCmd = &cobra.Command{
1416
Short: "Deploys or updates infrastructure according to project configuration",
1517
RunE: func(cmd *cobra.Command, args []string) error {
1618
project, err := project.LoadProjectFull()
17-
19+
if utils.GetEnv("CDEV_COLLECT_USAGE_STATS", "false") == "true" {
20+
log.Infof("Sending usage statistic. To disable statistics collection, export the CDEV_COLLECT_USAGE_STATS=false environment variable")
21+
}
1822
if err != nil {
1923
return NewCmdErr(project, "apply", err)
2024
}

pkg/project/stack.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func (p *Project) readStacks() error {
4343
return err
4444
}
4545
}
46+
if len(p.Stacks) == 0 {
47+
return fmt.Errorf("no stacks found, at least one needed")
48+
}
4649
return nil
4750
}
4851

@@ -51,6 +54,17 @@ func (p *Project) readStackObj(stackSpec ObjectData) error {
5154
if !ok {
5255
return fmt.Errorf("stack object must contain field 'name'")
5356
}
57+
disabledInt := stackSpec.data["disabled"]
58+
if disabledInt != nil {
59+
disabled, ok := disabledInt.(bool)
60+
if !ok {
61+
return fmt.Errorf("stack option 'disabled' should be bool, not %T", disabledInt)
62+
}
63+
if disabled {
64+
log.Debugf("stack '%v' is disabled, ignore", name)
65+
return nil
66+
}
67+
}
5468
// Check if stack with this name is already exists in project.
5569
if _, ok = p.Stacks[name]; ok {
5670
return fmt.Errorf("duplicate stack name '%s'", name)

pkg/utils/stats_collector.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func (e *StatsExporter) PushStats(stats interface{}) error {
4646
client := http.Client{
4747
Timeout: 3 * time.Second,
4848
}
49-
log.Warnf("Sending usage statistic. To disable statistics collection, export the CDEV_COLLECT_USAGE_STATS=false environment variable")
5049
log.Debugf("Usage stats:\n%v", string(jsonBody))
5150
res, err := client.Do(req)
5251
if err != nil {

tests/test-project/local.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: cdev-tests-local
22
template: ./local-tmpl/
33
kind: Stack
4+
disabled: false
45
backend: aws-backend
56
variables:
67
data: {{ remoteState "cdev-tests.create-bucket.test" }}

0 commit comments

Comments
 (0)