Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFaucherre committed Aug 1, 2023
1 parent 3261245 commit 25c6676
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func newCompletionCommand(config *settings.Config) *cobra.Command {
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
telemetryClient := create_telemetry.CreateTelemetry(config)
defer telemetryClient.Close()
telemetryClient.Track(telemetry.CreateCompletionCommand(create_telemetry.GetCommandInformation(cmd, false)))
_ = telemetryClient.Track(telemetry.CreateCompletionCommand(create_telemetry.GetCommandInformation(cmd, false)))
},
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Help()
Expand Down
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func newConfigCommand(globalConfig *settings.Config) *cobra.Command {
IgnoreDeprecatedImages: ignoreDeprecatedImages,
VerboseOutput: verboseOutput,
})
telemetryClient.Track(telemetry.CreateConfigEvent(create_telemetry.GetCommandInformation(cmd, true), err))
_ = telemetryClient.Track(telemetry.CreateConfigEvent(create_telemetry.GetCommandInformation(cmd, true), err))

return err
},
Expand Down Expand Up @@ -131,7 +131,7 @@ func newConfigCommand(globalConfig *settings.Config) *cobra.Command {
PipelineParamsFilePath: pipelineParamsFilePath,
VerboseOutput: verboseOutput,
})
telemetryClient.Track(telemetry.CreateConfigEvent(create_telemetry.GetCommandInformation(cmd, true), err))
_ = telemetryClient.Track(telemetry.CreateConfigEvent(create_telemetry.GetCommandInformation(cmd, true), err))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func newDiagnosticCommand(config *settings.Config) *cobra.Command {
defer telemetryClient.Close()

err := diagnostic(opts)
telemetryClient.Track(telemetry.CreateDiagnosticEvent(err))
_ = telemetryClient.Track(telemetry.CreateDiagnosticEvent(err))

return err
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/follow.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func followProjectCommand(config *settings.Config) *cobra.Command {
defer telemetryClient.Close()

err := followProject(opts)
telemetryClient.Track(telemetry.CreateFollowEvent(err))
_ = telemetryClient.Track(telemetry.CreateFollowEvent(err))

return err
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = Describe("Namespace integration tests", func() {

tempSettings.TestServer.AppendHandlers(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusOK)
res.Write([]byte(`{"data":{"organization":{"name":"test-org","id":"bb604b45-b6b0-4b81-ad80-796f15eddf87"}}}`))
_, _ = res.Write([]byte(`{"data":{"organization":{"name":"test-org","id":"bb604b45-b6b0-4b81-ad80-796f15eddf87"}}}`))
})

session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expand Down
2 changes: 1 addition & 1 deletion cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Please note that at this time all orbs created in the registry are world-readabl

telemetryClient := create_telemetry.CreateTelemetry(config)
defer telemetryClient.Close()
telemetryClient.Track(telemetry.CreateOrbEvent(create_telemetry.GetCommandInformation(cmd, true)))
_ = telemetryClient.Track(telemetry.CreateOrbEvent(create_telemetry.GetCommandInformation(cmd, true)))

// PersistentPreRunE overwrites the inherited persistent hook from rootCmd
// So we explicitly call it here to retain that behavior.
Expand Down
2 changes: 1 addition & 1 deletion cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var _ = Describe("Orb telemetry", func() {

tempSettings.TestServer.AppendHandlers(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusOK)
res.Write([]byte(`{"orbConfig": {"sourceYaml": "{}", "valid": true, "errors": []} }`))
_, _ = res.Write([]byte(`{"orbConfig": {"sourceYaml": "{}", "valid": true, "errors": []} }`))
})

session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expand Down
2 changes: 1 addition & 1 deletion cmd/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewCommand(globalConfig *settings.Config, preRunE validator.Validator) *cob
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
telemetryClient := create_telemetry.CreateTelemetry(globalConfig)
defer telemetryClient.Close()
telemetryClient.Track(telemetry.CreatePolicyEvent(create_telemetry.GetCommandInformation(cmd, true)))
_ = telemetryClient.Track(telemetry.CreatePolicyEvent(create_telemetry.GetCommandInformation(cmd, true)))

if preRunE != nil {
return preRunE(cmd, args)
Expand Down
2 changes: 1 addition & 1 deletion cmd/runner/resource_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func newResourceClassCommand(o *runnerOpts, preRunE validator.Validator) *cobra.
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
telemetryClient := o.createTelemetry()
defer telemetryClient.Close()
telemetryClient.Track(telemetry.CreateRunnerResourceClassEvent(create_telemetry.GetCommandInformation(cmd, true)))
_ = telemetryClient.Track(telemetry.CreateRunnerResourceClassEvent(create_telemetry.GetCommandInformation(cmd, true)))
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/runner/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func newTokenCommand(o *runnerOpts, preRunE validator.Validator) *cobra.Command
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
telemetryClient := o.createTelemetry()
defer telemetryClient.Close()
telemetryClient.Track(telemetry.CreateRunnerResourceClassEvent(create_telemetry.GetCommandInformation(cmd, true)))
_ = telemetryClient.Track(telemetry.CreateRunnerResourceClassEvent(create_telemetry.GetCommandInformation(cmd, true)))
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newUpdateCommand(config *settings.Config) *cobra.Command {
opts.cfg.SkipUpdateCheck = true
telemetryClient := create_telemetry.CreateTelemetry(config)
defer telemetryClient.Close()
telemetryClient.Track(telemetry.CreateUpdateEvent(create_telemetry.GetCommandInformation(cmd, cmd.Name() != "update")))
_ = telemetryClient.Track(telemetry.CreateUpdateEvent(create_telemetry.GetCommandInformation(cmd, cmd.Name() != "update")))
},
PreRun: func(cmd *cobra.Command, args []string) {
opts.args = args
Expand Down
20 changes: 19 additions & 1 deletion cmd/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,29 @@ var _ = Describe("Update", func() {

Describe("telemetry", func() {
It("should send telemetry event when calling parent command", func() {
command = exec.Command(pathCLI,
updateCLI, err := gexec.Build("github.com/CircleCI-Public/circleci-cli")
Expect(err).ShouldNot(HaveOccurred())

command = exec.Command(updateCLI,
"update",
"--github-api", tempSettings.TestServer.URL(),
"--mock-telemetry", tempSettings.TelemetryDestPath,
)

assetBytes := golden.Get(GinkgoT(), filepath.FromSlash("update/foo.zip"))
assetResponse := string(assetBytes)

tempSettings.TestServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodGet, "/repos/CircleCI-Public/circleci-cli/releases"),
ghttp.RespondWith(http.StatusOK, response),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodGet, "/repos/CircleCI-Public/circleci-cli/releases/assets/1"),
ghttp.RespondWith(http.StatusOK, assetResponse),
),
)

session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
// Overwrite this function for tests
CreateActiveTelemetry = newSegmentClient

SegmentEndpoint = "localhost"
SegmentEndpoint = "http://localhost"
SegmentKey = ""
)

Expand Down

0 comments on commit 25c6676

Please sign in to comment.