From 3ea52c7598811a4d1a8a509d4065b1bce7d966fd Mon Sep 17 00:00:00 2001 From: thibauult Date: Wed, 1 Nov 2023 13:54:07 +0100 Subject: [PATCH 1/2] Moved local config to ~/.openhue folder --- cmd/setup.go | 19 ++++++++++--------- openhue/config.go | 8 ++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/setup.go b/cmd/setup.go index d60ed80..4c08e4f 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -10,24 +10,25 @@ var setupCmd = &cobra.Command{ Use: "setup", GroupID: "init", Short: "Configure your local Philips HUE environment", - Long: `The setup command must be run as a prerequisite. It allows to store your Philips HUE Bridge IP and -application key in the configuration file`, + Long: `The setup command must be run as a prerequisite for all resource related commands (controlling lights, rooms, scenes, etc.) + +It allows to store your Philips Hue Bridge IP and application key in the configuration file (~/.openhue/config.yaml).`, Run: Setup, } func Setup(cmd *cobra.Command, args []string) { - err := viper.SafeWriteConfig() + err := viper.WriteConfig() cobra.CheckErr(err) } func init() { rootCmd.AddCommand(setupCmd) - setupCmd.PersistentFlags().StringP("ip", "i", "192.168.1.68", "The local IP of your Philips HUE Bridge") - _ = setupCmd.MarkPersistentFlagRequired("ip") - _ = viper.BindPFlag("ip", setupCmd.PersistentFlags().Lookup("ip")) + setupCmd.Flags().StringP("bridge", "b", "", "The local IP of your Philips Hue Bridge (example '192.168.1.68')") + _ = setupCmd.MarkFlagRequired("ip") + _ = viper.BindPFlag("ip", setupCmd.Flags().Lookup("ip")) - setupCmd.PersistentFlags().StringP("key", "k", "####", "Your HUE application key") - _ = setupCmd.MarkPersistentFlagRequired("key") - _ = viper.BindPFlag("key", setupCmd.PersistentFlags().Lookup("key")) + setupCmd.Flags().StringP("key", "k", "", "Your Hue Application Key") + _ = setupCmd.MarkFlagRequired("key") + _ = viper.BindPFlag("key", setupCmd.Flags().Lookup("key")) } diff --git a/openhue/config.go b/openhue/config.go index 7b83fea..3e3c19e 100644 --- a/openhue/config.go +++ b/openhue/config.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/viper" "net/http" "os" + "path/filepath" "slices" ) @@ -32,9 +33,12 @@ func Load() *Config { home, err := os.UserHomeDir() cobra.CheckErr(err) + var configPath = filepath.Join(home, "/.openhue") + _ = os.MkdirAll(configPath, os.ModePerm) + // Search config in home directory with name ".openhue" (without an extension). - viper.AddConfigPath(home) - viper.SetConfigName(".openhue") + viper.AddConfigPath(configPath) + viper.SetConfigName("config") viper.SetConfigType("yaml") // List of commands that does not require configuration From 1e9372ae4b520762b9d2d02e7a2090f58b2cd108 Mon Sep 17 00:00:00 2001 From: thibauult Date: Wed, 1 Nov 2023 13:54:32 +0100 Subject: [PATCH 2/2] Publish Docker Image with tag --- .goreleaser.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index f3ac09a..caa830c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,8 +1,3 @@ -# The lines bellow are called `modelines`. See `:help modeline` -# Feel free to remove those if you don't want/need to use them. -# yaml-language-server: $schema=https://goreleaser.com/static/schema.json -# vim: set ts=2 sw=2 tw=0 fo=cnqoj - project_name: openhue before: @@ -29,7 +24,8 @@ builds: dockers: - id: openhue image_templates: - - openhue/cli + - openhue/cli:latest + - openhue/cli:{{ .Tag }} build_flag_templates: - "--pull" - "--label=org.opencontainers.image.created={{.Date}}"