You've already forked docker-hub-description-updater
feat: use goreleaser
This commit is contained in:
16
cmd/root.go
16
cmd/root.go
@ -19,7 +19,7 @@ var (
|
||||
)
|
||||
|
||||
// Execute a
|
||||
func Execute(version string) {
|
||||
func Execute(version string) error {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "dhdu",
|
||||
Short: "docker hub description updater (dhdu)",
|
||||
@ -31,7 +31,7 @@ func Execute(version string) {
|
||||
rootCmd.Flags().StringVarP(&dockerHubPassword, "password", "p", "", "Docker Hub Password")
|
||||
rootCmd.Flags().StringVarP(&dockerHubRepository, "repository", "r", "", "Docker Hub Repository")
|
||||
rootCmd.Flags().StringVarP(&dockerHubUser, "username", "u", "", "Docker Hub Username")
|
||||
rootCmd.Execute()
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func runE(cmd *cobra.Command, args []string) error {
|
||||
@ -39,29 +39,29 @@ func runE(cmd *cobra.Command, args []string) error {
|
||||
file := args[0]
|
||||
|
||||
if len(dockerHubUser) <= 0 {
|
||||
return fmt.Errorf("No user defined over flags")
|
||||
return fmt.Errorf("no user defined over flags")
|
||||
}
|
||||
|
||||
if len(dockerHubPassword) <= 0 {
|
||||
return fmt.Errorf("No password defined over flags")
|
||||
return fmt.Errorf("no password defined over flags")
|
||||
}
|
||||
|
||||
if len(dockerHubNamespace) <= 0 {
|
||||
log.Printf("No namespace defined over flags: Use docker username %v instead", dockerHubUser)
|
||||
log.Printf("no namespace defined over flags: Use docker username %v instead", dockerHubUser)
|
||||
dockerHubNamespace = dockerHubUser
|
||||
}
|
||||
|
||||
if len(dockerHubRepository) <= 0 {
|
||||
return fmt.Errorf("No repository defined over flags")
|
||||
return fmt.Errorf("nNo repository defined over flags")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(file); os.IsNotExist(err) && len(file) <= 0 {
|
||||
return fmt.Errorf("Can not find file: %v", file)
|
||||
return fmt.Errorf("can not find file: %v", file)
|
||||
}
|
||||
|
||||
f, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Can not read file %v: %v", file, err)
|
||||
return fmt.Errorf("can not read file %v: %v", file, err)
|
||||
}
|
||||
fullDescription := string(f)
|
||||
|
||||
|
Reference in New Issue
Block a user