Skip to content

Commit 4ada96b

Browse files
CR-10077 (#301)
* bump * init * bump * supporting the flag in upgrade as well * codegen * setting to noop analytics reporter in case of reporting error * commented out
1 parent 63ec9c6 commit 4ada96b

File tree

8 files changed

+42
-26
lines changed

8 files changed

+42
-26
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.275
1+
VERSION=v0.0.276
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/runtime.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type (
8989
InstallDemoResources bool
9090
SkipClusterChecks bool
9191
DisableRollback bool
92+
DisableTelemetry bool
9293
Version *semver.Version
9394
GsCloneOpts *git.CloneOptions
9495
InsCloneOpts *git.CloneOptions
@@ -100,21 +101,23 @@ type (
100101
kubeContext string
101102
}
102103
RuntimeUninstallOptions struct {
103-
RuntimeName string
104-
Timeout time.Duration
105-
CloneOpts *git.CloneOptions
106-
KubeFactory kube.Factory
107-
SkipChecks bool
108-
Force bool
109-
FastExit bool
110-
kubeContext string
104+
RuntimeName string
105+
Timeout time.Duration
106+
CloneOpts *git.CloneOptions
107+
KubeFactory kube.Factory
108+
SkipChecks bool
109+
Force bool
110+
FastExit bool
111+
DisableTelemetry bool
112+
kubeContext string
111113
}
112114

113115
RuntimeUpgradeOptions struct {
114-
RuntimeName string
115-
Version *semver.Version
116-
CloneOpts *git.CloneOptions
117-
CommonConfig *runtime.CommonConfig
116+
RuntimeName string
117+
Version *semver.Version
118+
CloneOpts *git.CloneOptions
119+
CommonConfig *runtime.CommonConfig
120+
DisableTelemetry bool
118121
}
119122

120123
gvr struct {
@@ -214,7 +217,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
214217
installationOpts.RuntimeName = args[0]
215218
}
216219

217-
createAnalyticsReporter(cmd.Context(), reporter.InstallFlow)
220+
createAnalyticsReporter(cmd.Context(), reporter.InstallFlow, installationOpts.DisableTelemetry)
218221

219222
err := runtimeInstallCommandPreRunHandler(cmd, &installationOpts)
220223
handleCliStep(reporter.InstallPhasePreCheckFinish, "Finished pre installation checks", err, true, false)
@@ -260,6 +263,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
260263
cmd.Flags().StringVar(&gitIntegrationCreationOpts.APIURL, "provider-api-url", "", "Git provider API url")
261264
cmd.Flags().BoolVar(&store.Get().SkipIngress, "skip-ingress", false, "Skips the creation of ingress resources")
262265
cmd.Flags().BoolVar(&store.Get().BypassIngressClassCheck, "bypass-ingress-class-check", false, "Disables the ingress class check during pre-installation")
266+
cmd.Flags().BoolVar(&installationOpts.DisableTelemetry, "disable-telemetry", false, "If true, will disable the analytics reporting for the installation process")
263267

264268
installationOpts.InsCloneOpts = apu.AddCloneFlags(cmd, &apu.CloneFlagsOptions{
265269
CreateIfNotExist: true,
@@ -1346,7 +1350,7 @@ func NewRuntimeUninstallCommand() *cobra.Command {
13461350
uninstallationOpts.RuntimeName = args[0]
13471351
}
13481352

1349-
createAnalyticsReporter(ctx, reporter.UninstallFlow)
1353+
createAnalyticsReporter(ctx, reporter.UninstallFlow, uninstallationOpts.DisableTelemetry)
13501354

13511355
err := runtimeUninstallCommandPreRunHandler(cmd, args, &uninstallationOpts)
13521356
handleCliStep(reporter.UninstallPhasePreCheckFinish, "Finished pre run checks", err, true, false)
@@ -1393,6 +1397,7 @@ func NewRuntimeUninstallCommand() *cobra.Command {
13931397
cmd.Flags().DurationVar(&store.Get().WaitTimeout, "wait-timeout", store.Get().WaitTimeout, "How long to wait for the runtime components to be deleted")
13941398
cmd.Flags().BoolVar(&uninstallationOpts.Force, "force", false, "If true, will guarantee the runtime is removed from the platform, even in case of errors while cleaning the repo and the cluster")
13951399
cmd.Flags().BoolVar(&uninstallationOpts.FastExit, "fast-exit", false, "If true, will not wait for deletion of cluster resources. This means that full resource deletion will not be verified")
1400+
cmd.Flags().BoolVar(&uninstallationOpts.DisableTelemetry, "disable-telemetry", false, "If true, will disable the analytics reporting for the uninstall process")
13961401

13971402
uninstallationOpts.CloneOpts = apu.AddCloneFlags(cmd, &apu.CloneFlagsOptions{CloneForWrite: true})
13981403
uninstallationOpts.KubeFactory = kube.AddFlags(cmd.Flags())
@@ -1617,7 +1622,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
16171622
PreRunE: func(cmd *cobra.Command, args []string) error {
16181623
ctx := cmd.Context()
16191624

1620-
createAnalyticsReporter(ctx, reporter.UpgradeFlow)
1625+
createAnalyticsReporter(ctx, reporter.UpgradeFlow, opts.DisableTelemetry)
16211626

16221627
err := runtimeUpgradeCommandPreRunHandler(cmd, args, &opts)
16231628
handleCliStep(reporter.UpgradePhasePreCheckFinish, "Finished pre run checks", err, true, false)
@@ -1668,6 +1673,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
16681673
}
16691674

16701675
cmd.Flags().StringVar(&versionStr, "version", "", "The runtime version to upgrade to, defaults to latest")
1676+
cmd.Flags().BoolVar(&opts.DisableTelemetry, "disable-telemetry", false, "If true, will disable analytics reporting for the upgrade process")
16711677
opts.CloneOpts = apu.AddCloneFlags(cmd, &apu.CloneFlagsOptions{CloneForWrite: true})
16721678

16731679
return cmd
@@ -2310,7 +2316,12 @@ func printSummaryToUser() {
23102316
summaryArr = []summaryLog{}
23112317
}
23122318

2313-
func createAnalyticsReporter(ctx context.Context, flow reporter.FlowType) {
2319+
func createAnalyticsReporter(ctx context.Context, flow reporter.FlowType, disableTelemetry bool) {
2320+
if disableTelemetry {
2321+
log.G().Debug("Analytics Reporter disabled by the --disable-telemetry flag.")
2322+
return
2323+
}
2324+
23142325
user, err := cfConfig.GetCurrentContext().GetUser(ctx)
23152326
// If error, it will default to noop reporter
23162327
if err != nil {

docs/commands/cli-v2_runtime_install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ cli-v2 runtime install [runtime_name] [flags]
3131
--context string The name of the kubeconfig context to use
3232
--demo-resources Installs demo resources (default: true) (default true)
3333
--disable-rollback If true, will not perform installation rollback after a failed installation
34+
--disable-telemetry If true, will disable the analytics reporting for the installation process
3435
-t, --git-token string Your git provider api token [GIT_TOKEN]
3536
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
3637
-h, --help help for install

docs/commands/cli-v2_runtime_uninstall.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cli-v2 runtime uninstall [RUNTIME_NAME] [flags]
2929

3030
```
3131
--context string The name of the kubeconfig context to use
32+
--disable-telemetry If true, will disable the analytics reporting for the uninstall process
3233
--fast-exit If true, will not wait for deletion of cluster resources. This means that full resource deletion will not be verified
3334
--force If true, will guarantee the runtime is removed from the platform, even in case of errors while cleaning the repo and the cluster
3435
-t, --git-token string Your git provider api token [GIT_TOKEN]

docs/commands/cli-v2_runtime_upgrade.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ cli-v2 runtime upgrade [RUNTIME_NAME] [flags]
2828
### Options
2929

3030
```
31-
-t, --git-token string Your git provider api token [GIT_TOKEN]
32-
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
33-
-h, --help help for upgrade
34-
--repo string Repository URL [GIT_REPO]
35-
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
36-
--version string The runtime version to upgrade to, defaults to latest
31+
--disable-telemetry If true, will disable analytics reporting for the upgrade process
32+
-t, --git-token string Your git provider api token [GIT_TOKEN]
33+
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
34+
-h, --help help for upgrade
35+
--repo string Repository URL [GIT_REPO]
36+
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
37+
--version string The runtime version to upgrade to, defaults to latest
3738
```
3839

3940
### Options inherited from parent commands

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.275/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.276/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.275/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.276/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.1
8-
version: 0.0.275
8+
version: 0.0.276
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/reporter/reporter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ func (r *segmentAnalyticsReporter) ReportStep(data CliStepData) {
187187

188188
if err != nil {
189189
log.G().Debugf("Failed reporting to segment: %w", err)
190+
r.Close(data.Status, err)
191+
ar = &noopAnalyticsReporter{}
190192
}
191193
}
192194

0 commit comments

Comments
 (0)