Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit dbd6768

Browse files
committed
Retain -analytics tag to avoid breakage, but warn on use
1 parent 710780e commit dbd6768

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

cmd/update-operator/main.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"fmt"
66
"os"
7+
"strconv"
78

89
"github.com/coreos/pkg/flagutil"
910
"github.com/golang/glog"
@@ -20,13 +21,15 @@ var (
2021
autoLabelContainerLinux = flag.Bool("auto-label-container-linux", false, "Auto-label Container Linux nodes with agent=true (convenience)")
2122
printVersion = flag.Bool("version", false, "Print version and exit")
2223
// deprecated
23-
manageAgent = flag.Bool("manage-agent", false, "Manage the associated update-agent")
24-
agentImageRepo = flag.String("agent-image-repo", "quay.io/coreos/container-linux-update-operator", "The image to use for the managed agent, without version tag")
24+
analyticsEnabled optValue
25+
manageAgent = flag.Bool("manage-agent", false, "Manage the associated update-agent")
26+
agentImageRepo = flag.String("agent-image-repo", "quay.io/coreos/container-linux-update-operator", "The image to use for the managed agent, without version tag")
2527
)
2628

2729
func main() {
2830
flag.Var(&beforeRebootAnnotations, "before-reboot-annotations", "List of comma-separated Kubernetes node annotations that must be set to 'true' before a reboot is allowed")
2931
flag.Var(&afterRebootAnnotations, "after-reboot-annotations", "List of comma-separated Kubernetes node annotations that must be set to 'true' before a node is marked schedulable and the operator lock is released")
32+
flag.Var(&analyticsEnabled, "analytics", "Send analytics to Google Analytics")
3033

3134
flag.Set("logtostderr", "true")
3235
flag.Parse()
@@ -35,6 +38,10 @@ func main() {
3538
glog.Fatalf("Failed to parse environment variables: %v", err)
3639
}
3740

41+
if analyticsEnabled.present {
42+
glog.Warning("Use of -analytics is deprecated and will be removed. Google Analytics will not be enabled.")
43+
}
44+
3845
// respect KUBECONFIG without the prefix as well
3946
if *kubeconfig == "" {
4047
*kubeconfig = os.Getenv("KUBECONFIG")
@@ -78,3 +85,20 @@ func main() {
7885
glog.Fatalf("Error while running %s: %v", os.Args[0], err)
7986
}
8087
}
88+
89+
// optValue is a flag.Value that detects whether a user passed a flag directly.
90+
type optValue struct {
91+
value bool
92+
present bool
93+
}
94+
95+
func (o *optValue) Set(s string) error {
96+
v, err := strconv.ParseBool(s)
97+
o.value = v
98+
o.present = true
99+
return err
100+
}
101+
102+
func (o *optValue) String() string {
103+
return strconv.FormatBool(o.value)
104+
}

0 commit comments

Comments
 (0)