Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update telemetry flag name #1074

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ cluster provisioning process spinning up the services, and validates the livenes
// todo remove this dependency from create.go
hostedZoneName := viper.GetString("aws.hostedzonename")

if !globalFlags.UseTelemetry {
if globalFlags.DisableTelemetry == true {
informUser("Telemetry Disabled", globalFlags.SilentMode)
} else {
pkg.InformUser("Sending installation telemetry", globalFlags.SilentMode)
}

if globalFlags.UseTelemetry {
if err := wrappers.SendSegmentIoTelemetry(hostedZoneName, pkg.MetricMgmtClusterInstallStarted); err != nil {
log.Warn().Msgf("%s", err)
}
Expand Down Expand Up @@ -194,7 +191,7 @@ cluster provisioning process spinning up the services, and validates the livenes

log.Debug().Msg("sending mgmt cluster install completed metric")

if globalFlags.UseTelemetry {
if globalFlags.DisableTelemetry == false {
if err := wrappers.SendSegmentIoTelemetry(hostedZoneName, pkg.MetricMgmtClusterInstallCompleted); err != nil {
log.Warn().Msgf("%s", err)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,15 @@ validated and configured.`,
log.Info().Msg("sending init started metric")

var telemetryHandler handlers.TelemetryHandler
viper.Set("use-telemetry", globalFlags.UseTelemetry)
viper.Set("disable-telemetry", globalFlags.DisableTelemetry)

if !globalFlags.UseTelemetry {
if globalFlags.DisableTelemetry == true {
informUser("Telemetry Disabled", globalFlags.SilentMode)
} else {
pkg.InformUser("Sending installation telemetry", globalFlags.SilentMode)
}
if globalFlags.UseTelemetry {

if globalFlags.DisableTelemetry == false {

// Instantiates a SegmentIO client to use send messages to the segment API.
segmentIOClient := analytics.New(pkg.SegmentIOWriteKey)
Expand Down Expand Up @@ -269,7 +270,7 @@ validated and configured.`,

log.Info().Msg("sending init completed metric")

if globalFlags.UseTelemetry {
if globalFlags.DisableTelemetry == false {
telemetryInitCompleted, err := domain.NewTelemetry(
pkg.MetricInitCompleted,
awsFlags.HostedZoneName,
Expand Down
30 changes: 15 additions & 15 deletions cmd/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ import (
)

var (
useTelemetry bool
dryRun bool
silentMode bool
enableConsole bool
skipMetaphor bool
gitOpsBranch string
gitOpsRepo string
gitOpsOrg string
metaphorBranch string
adminEmail string
templateTag string
logLevel string
disableTelemetry bool
dryRun bool
silentMode bool
enableConsole bool
skipMetaphor bool
gitOpsBranch string
gitOpsRepo string
gitOpsOrg string
metaphorBranch string
adminEmail string
templateTag string
logLevel string
)

func NewCommand() *cobra.Command {
Expand All @@ -53,7 +53,7 @@ func NewCommand() *cobra.Command {
PostRunE: runPostLocal,
}

localCmd.Flags().BoolVar(&useTelemetry, "use-telemetry", true, "installer won't send telemetry data if --use-telemetry=false is set")
localCmd.Flags().BoolVar(&disableTelemetry, "disable-telemetry", false, "installer won't send telemetry data if --disable-telemetry is set")
localCmd.Flags().BoolVar(&dryRun, "dry-run", false, "set to dry-run mode, no changes done on cloud provider selected")
localCmd.Flags().BoolVar(&silentMode, "silent", false, "enable silentMode mode will make the UI return less content to the screen")
localCmd.Flags().BoolVar(&enableConsole, "enable-console", true, "If hand-off screen will be presented on a browser UI")
Expand Down Expand Up @@ -93,7 +93,7 @@ func runLocal(cmd *cobra.Command, args []string) error {
progressPrinter.AddTracker("step-github", "Setup gitops on github", 3)
progressPrinter.AddTracker("step-base", "Setup base cluster", 2)
progressPrinter.AddTracker("step-apps", "Install apps to cluster", 4)
if useTelemetry {
if disableTelemetry == false {
if err := wrappers.SendSegmentIoTelemetry("", pkg.MetricMgmtClusterInstallStarted); err != nil {
log.Error().Err(err).Msg("")
}
Expand Down Expand Up @@ -441,7 +441,7 @@ func runLocal(cmd *cobra.Command, args []string) error {
wg.Wait()

log.Info().Msg("sending mgmt cluster install completed metric")
if useTelemetry {
if disableTelemetry == false {
if err = wrappers.SendSegmentIoTelemetry("", pkg.MetricMgmtClusterInstallCompleted); err != nil {
log.Error().Err(err).Msg("")
}
Expand Down
9 changes: 4 additions & 5 deletions cmd/local/prerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func validateLocal(cmd *cobra.Command, args []string) error {

log.Info().Msg("sending init started metric")

if useTelemetry {
if disableTelemetry == false {
pkg.InformUser("Sending installation telemetry", silentMode)
if err := wrappers.SendSegmentIoTelemetry("", pkg.MetricInitStarted); err != nil {
log.Error().Err(err).Msg("")
Expand Down Expand Up @@ -76,7 +76,7 @@ func validateLocal(cmd *cobra.Command, args []string) error {

viper.Set("argocd.local.service", pkg.ArgoCDLocalURL)
viper.Set("vault.local.service", pkg.VaultLocalURLTLS)
viper.Set("use-telemetry", useTelemetry)
viper.Set("disable-telemetry", disableTelemetry)
err = viper.WriteConfig()
if err != nil {
return err
Expand Down Expand Up @@ -231,11 +231,10 @@ func validateLocal(cmd *cobra.Command, args []string) error {

progressPrinter.IncrementTracker("step-gitops", 1)

log.Info().Msg("sending init completed metric")

pkg.InformUser("initialization step is done!", silentMode)

if useTelemetry {
if disableTelemetry == false {
log.Info().Msg("sending init completed metric")
if err = wrappers.SendSegmentIoTelemetry("", pkg.MetricInitCompleted); err != nil {
log.Error().Err(err).Msg("")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/postInstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var postInstallCmd = &cobra.Command{
//if err != nil {
// return err
//}
globalFlags := flagset.GlobalFlags{DryRun: false, SilentMode: false, UseTelemetry: true}
globalFlags := flagset.GlobalFlags{DryRun: false, SilentMode: false, DisableTelemetry: true}

createFlags, err := flagset.ProcessCreateFlags(cmd)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions docs/tooling/kubefirst-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Flags:
--template-tag string Fallback tag used on Git clone.
Details: If "gitops-branch" is provided, branch("gitops-branch") has precedence and the installer will attempt to clone the branch("gitops-branch") first,
if it fails, then it will attempt to clone the tag provided at "template-tag" flag (default "1.8.6").
--use-telemetry Installer won't send telemetry data if --use-telemetry=false is set (default true).
--disable-telemetry Installer won't send telemetry data if --disable-telemetry is set.
```

### cluster create
Expand Down Expand Up @@ -126,9 +126,9 @@ Usage:
kubefirst restoreSSL [flags]

Flags:
--dry-run Set to dry-run mode, no changes done on cloud provider selected.
-h, --help Help for restoreSSL.
--use-telemetry Installer won't send telemetry data if --use-telemetry=false is set (default true).
--dry-run Set to dry-run mode, no changes done on cloud provider selected.
-h, --help Help for restoreSSL.
--disable-telemetry Installer won't send telemetry data if --disable-telemetry=false is set.
```

### state
Expand Down
2 changes: 1 addition & 1 deletion internal/flagset/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func DefineCIFlags(currentCommand *cobra.Command) {
currentCommand.Flags().String("ci-kubefirst-branch", "", "version/branch used on git clone for kubefirst setup instruction")
}

// ProcessCIFlags - process global flags shared between commands like silent, dry-run and use-telemetry
// ProcessCIFlags - process global flags shared between commands like silent, dry-run and disable-telemetry
func ProcessCIFlags(cmd *cobra.Command) (CIFlags, error) {
flags := CIFlags{}

Expand Down
2 changes: 1 addition & 1 deletion internal/flagset/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func DefineDestroyFlags(currentCommand *cobra.Command) {
currentCommand.Flags().Bool("hosted-zone-keep-base", false, "keeps base DNS records (NS, SOA and liveness TXT), and delete all other DNS records. Use it in combination with --hosted-zone-delete")
}

// ProcessDestroyFlags - process global flags shared between commands like silent, dry-run and use-telemetry
// ProcessDestroyFlags - process global flags shared between commands like silent, dry-run and disable-telemetry
func ProcessDestroyFlags(cmd *cobra.Command) (DestroyFlags, error) {
flags := DestroyFlags{}

Expand Down
20 changes: 10 additions & 10 deletions internal/flagset/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import (

// GlobalFlags - Global flags
type GlobalFlags struct {
DryRun bool
UseTelemetry bool
SilentMode bool
ConfigFile string
DryRun bool
DisableTelemetry bool
SilentMode bool
ConfigFile string
}

// DefineGlobalFlags - Define global flags
func DefineGlobalFlags(currentCommand *cobra.Command) {
currentCommand.Flags().Bool("use-telemetry", true, "installer won't send telemetry data if --use-telemetry=false is set")
currentCommand.Flags().Bool("disable-telemetry", false, "installer won't send telemetry data if --disable-telemetry is set")
currentCommand.Flags().Bool("dry-run", false, "set to dry-run mode, no changes done on cloud provider selected")
currentCommand.Flags().Bool("silent", false, "enable silent mode will make the UI return less content to the screen")
currentCommand.Flags().StringP("config", "c", "", "File to be imported to bootstrap configs")
viper.BindPFlag("config.file", currentCommand.Flags().Lookup("config-load"))
}

// ProcessGlobalFlags - process global flags shared between commands like silent, dry-run and use-telemetry
// ProcessGlobalFlags - process global flags shared between commands like silent, dry-run and disable-telemetry
func ProcessGlobalFlags(cmd *cobra.Command) (GlobalFlags, error) {
flags := GlobalFlags{}
config, err := ReadConfigString(cmd, "config")
Expand All @@ -44,16 +44,16 @@ func ProcessGlobalFlags(cmd *cobra.Command) (GlobalFlags, error) {
}
flags.DryRun = dryRun

useTelemetry, err := ReadConfigBool(cmd, "use-telemetry")
disableTelemetry, err := ReadConfigBool(cmd, "disable-telemetry")
if err != nil {
log.Warn().Msgf("Error Processing - use-telemetry flag, error: %v", err)
log.Warn().Msgf("Error Processing - disable-telemetry flag, error: %v", err)
return flags, err
}
flags.UseTelemetry = useTelemetry
flags.DisableTelemetry = disableTelemetry

silentMode, err := ReadConfigBool(cmd, "silent")
if err != nil {
log.Warn().Msgf("Error Processing - use-telemetry flag, error: %v", err)
log.Warn().Msgf("Error Processing - silent flag, error: %v", err)
return flags, err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func DetokenizeDirectory(path string, fi os.FileInfo, err error) error {
githubRepoOwner := strings.ToLower(viper.GetString("github.owner"))
githubOrg := viper.GetString("github.owner")
githubUser := strings.ToLower(viper.GetString("github.user"))
useTelemetry := viper.GetString("use-telemetry")
disableTelemetry := viper.GetString("disable-telemetry")
machineId := viper.GetString("machineid")

ngrokURL, err := url.Parse(viper.GetString("ngrok.url"))
Expand Down Expand Up @@ -252,7 +252,7 @@ func DetokenizeDirectory(path string, fi os.FileInfo, err error) error {
newContents = strings.Replace(newContents, "<GITHUB_OWNER>", githubRepoOwner, -1)
newContents = strings.Replace(newContents, "<GITHUB_USER>", githubUser, -1)
newContents = strings.Replace(newContents, "<GITHUB_TOKEN>", githubToken, -1)
newContents = strings.Replace(newContents, "<USE_TELEMETRY>", useTelemetry, -1)
newContents = strings.Replace(newContents, "<USE_TELEMETRY>", disableTelemetry, -1)
newContents = strings.Replace(newContents, "<MACHINE_ID>", machineId, -1)

newContents = strings.Replace(newContents, "<REPO_GITOPS>", "gitops", -1)
Expand Down