Skip to content

Commit df49808

Browse files
committed
refactor: fix issues according to golangci-lint
1 parent e52bdd3 commit df49808

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

cmd/argocd/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ type Plugin string
1616
// Install implements the installation of ArgoCD.
1717
func (p Plugin) Install(options *map[string]interface{}) {
1818
argocd.Install(options)
19-
log.Println("argocd install finished")
19+
log.Printf("%s install finished", NAME)
2020
}
2121

2222
// Reinstall implements the reinstallation of ArgoCD.
2323
func (p Plugin) Reinstall(options *map[string]interface{}) {
24-
log.Println("mock: argocd reinstall finished")
24+
log.Printf("mock: %s reinstall finished", NAME)
2525
}
2626

2727
// Uninstall implements the uninstallation of ArgoCD.
2828
func (p Plugin) Uninstall(options *map[string]interface{}) {
29-
log.Println("mock: argocd uninstall finished")
29+
log.Printf("mock: %s uninstall finished", NAME)
3030
}
3131

3232
// DevStreamPlugin is the exported variable used by the DevStream core.
3333
var DevStreamPlugin Plugin
3434

3535
func main() {
36-
fmt.Println("This is a plugin for DevStream. Use it with DevStream.")
36+
fmt.Printf("%T: %s is a plugin for DevStream. Use it with DevStream.\n", NAME, DevStreamPlugin)
3737
}

cmd/argocdapp/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ type Plugin string
1616
// Install implements the installation of an ArgoCD app.
1717
func (p Plugin) Install(options *map[string]interface{}) {
1818
argocdapp.Install(options)
19-
log.Println("argocdapps install finished")
19+
log.Printf("%s install finished", NAME)
2020
}
2121

2222
// Reinstall implements the installation of an ArgoCD app.
2323
func (p Plugin) Reinstall(options *map[string]interface{}) {
24-
log.Println("mock: argocdapps reinstall finished")
24+
log.Printf("mock: %s reinstall finished", NAME)
2525
}
2626

2727
// Uninstall Uninstall the installation of an ArgoCD app.
2828
func (p Plugin) Uninstall(options *map[string]interface{}) {
29-
log.Println("mock: argocdapps uninstall finished")
29+
log.Printf("mock: %s uninstall finished", NAME)
3030
}
3131

3232
// DevStreamPlugin is the exported variable used by the DevStream core.
3333
var DevStreamPlugin Plugin
3434

3535
func main() {
36-
fmt.Println("This is a plugin for DevStream. Use it with DevStream.")
36+
fmt.Printf("%T: %s is a plugin for DevStream. Use it with DevStream.\n", NAME, DevStreamPlugin)
3737
}

cmd/devstream/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"log"
5+
46
"github.com/spf13/cobra"
57
)
68

@@ -14,11 +16,6 @@ var (
1416
}
1517
)
1618

17-
// Execute runs the rootCMD's Execute func.
18-
func Execute() error {
19-
return rootCMD.Execute()
20-
}
21-
2219
func init() {
2320
rootCMD.PersistentFlags().StringVarP(&configFile, "config-file", "f", "config.yaml", "config file")
2421

@@ -27,5 +24,8 @@ func init() {
2724
}
2825

2926
func main() {
30-
rootCMD.Execute()
27+
err := rootCMD.Execute()
28+
if err != nil {
29+
log.Fatal(err)
30+
}
3131
}

cmd/githubactions/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ type Plugin string
1616
// Install implements the installation of some GitHub Actions workflows.
1717
func (p Plugin) Install(options *map[string]interface{}) {
1818
githubactions.Install(options)
19-
log.Println("github actions install finished")
19+
log.Printf("%s install finished", NAME)
2020
}
2121

2222
// Reinstall implements the installation of some GitHub Actions workflows.
2323
func (p Plugin) Reinstall(options *map[string]interface{}) {
24-
log.Println("mock: github actions reinstall finished")
24+
log.Printf("mock: %s reinstall finished", NAME)
2525
}
2626

2727
// Uninstall implements the installation of some GitHub Actions workflows.
2828
func (p Plugin) Uninstall(options *map[string]interface{}) {
29-
log.Println("mock: github actions uninstall finished")
29+
log.Printf("mock: %s uninstall finished", NAME)
3030
}
3131

3232
// DevStreamPlugin is the exported variable used by the DevStream core.
3333
var DevStreamPlugin Plugin
3434

3535
func main() {
36-
fmt.Println("This is a plugin for DevStream. Use it with DevStream.")
36+
fmt.Printf("%T: %s is a plugin for DevStream. Use it with DevStream.\n", NAME, DevStreamPlugin)
3737
}

internal/pkg/githubactions/githubactions.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ func generateGitHubWorkflowFileByName(f string) string {
1515
}
1616

1717
func getGitHubToken() string {
18-
viper.BindEnv("github_token")
19-
token, ok := viper.Get("github_token").(string)
18+
err := viper.BindEnv("github_token")
19+
if err != nil {
20+
log.Fatalf("ENV var GITHUB_TOKEN is needed")
21+
}
2022

23+
token, ok := viper.Get("github_token").(string)
2124
if !ok {
2225
log.Fatalf("ENV var GITHUB_TOKEN is needed")
2326
}
27+
2428
return token
2529
}
2630

0 commit comments

Comments
 (0)