From 957ff1c086805393634e3345e38168cf934a58c9 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Wed, 8 Jan 2020 12:27:54 +0100 Subject: [PATCH 01/19] Add CONTRIBUTORS.md --- CONTRIBUTORS.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CONTRIBUTORS.md diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..e95f84c0 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +* Benjamin Kircher +* Ibrahim Takouna From 80236bcafa696e1849a739fc6288009e08ef9667 Mon Sep 17 00:00:00 2001 From: Felix Kronlage-Dammers Date: Wed, 8 Jan 2020 12:54:17 +0100 Subject: [PATCH 02/19] explain how to contribute --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..1832650d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing to gscloud + +As an open source project, we encourage and appreciate any kind of contributions like comments, +enhancement requests, bug reports, or code contributions! + +## Development workflow + +* Development is done on the `develop` branch. +* Releases are cut from the `master` branch. +* For anything larger than single commits, please use feature/bugfix branches. + +## Reporting Bugs or Enhancement Requests + +Please submit bugs or enhancement requests through the public bug tracker within the +GitHub project. + +## Submitting Patches + +The gscloud source code is managed using the git distributed source control +management tool . Please submit patches +accordingly. + From cf50fab71f8a95d2c77e34f756516b1d3b21aaa7 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Wed, 8 Jan 2020 13:44:54 +0100 Subject: [PATCH 03/19] Rewrite comment in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d537a6cb..b6ce8718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,4 @@ FEATURES: * Support make-config for creating a new configuration file -* Support kubernetes cluster sub-commands: save-kubeconfig and exec-credential for managing authentication for cluster +* Support kubernetes cluster sub-commands: save-kubeconfig and exec-credential for managing a cluster's authentication From f978a98a6e41aefac4a0023a2576ef7cc29b9525 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Thu, 9 Jan 2020 11:06:43 +0100 Subject: [PATCH 04/19] Save the real path of gscloud into kubeconfig file --- cmd/cliconfig.go | 6 +++--- go.mod | 1 + go.sum | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index d1b2cb3a..c123f96b 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -4,8 +4,8 @@ import ( "fmt" "net/http" "os" - "path/filepath" + "github.com/kardianos/osext" "github.com/spf13/viper" ) @@ -20,11 +20,11 @@ type cliConfig struct { } func cliPath() string { - dir, err := filepath.Abs(filepath.Dir(os.Args[0])) + filePath, err := osext.Executable() if err != nil { fmt.Fprintln(os.Stderr, err) } - return filepath.Join(dir, os.Args[0]) + return filePath } func newCliClient(account string) *gsclient { diff --git a/go.mod b/go.mod index 62e1de7b..d6f5fd5f 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( github.com/imdario/mergo v0.3.7 // indirect + github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v0.0.5 diff --git a/go.sum b/go.sum index 7606d2b7..4e1677b5 100644 --- a/go.sum +++ b/go.sum @@ -143,6 +143,8 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU= github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f/go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= From 6d105e381265de5c96c8ac58ec1bb96549d3f840 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Thu, 9 Jan 2020 11:07:27 +0100 Subject: [PATCH 05/19] Add DS_Store to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6d18c4f5..4de565aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ gscloud +.DS_Store From 3a6a951d391cb1de508b82412e321e55191101b6 Mon Sep 17 00:00:00 2001 From: Marc Harriss <34962529+MarcHarriss@users.noreply.github.com> Date: Fri, 10 Jan 2020 17:35:26 +0100 Subject: [PATCH 06/19] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 537e3814..71508c45 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gscloud: The Command Line Interface for the gridcsale cloud +# gscloud: The Command Line Interface for the gridscale cloud ## Supported Services From 28d941963fe0aef82093803ff905f320fc816302 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 11:08:19 +0100 Subject: [PATCH 07/19] Use the standard Cache location to store gscloud cache --- cmd/cliconfig.go | 4 ++-- cmd/kubernetes.go | 4 ++-- cmd/root.go | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index c123f96b..7c817c30 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -29,13 +29,13 @@ func cliPath() string { func newCliClient(account string) *gsclient { var ac accountEntry - + cliConf := &cliConfig{} err := viper.Unmarshal(cliConf) if err != nil { fmt.Fprintln(os.Stderr, err) } - + for _, a := range cliConf.Accounts { if account == a.Name { ac = a diff --git a/cmd/kubernetes.go b/cmd/kubernetes.go index 81a2eca6..55299fad 100644 --- a/cmd/kubernetes.go +++ b/cmd/kubernetes.go @@ -10,6 +10,7 @@ import ( "path/filepath" "time" + "github.com/kirsle/configdir" "github.com/spf13/cobra" "gopkg.in/yaml.v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -253,8 +254,7 @@ func fetchKubeConfigFromProvider(id string) *kubeConfig { } func kubeConfigCachePath() string { - dir, _ := filepath.Abs(filepath.Dir(cfgFile)) - return filepath.Join(dir, "cache", "exec-credential") + return filepath.Join(configdir.LocalCache("gscloud"), "exec-credential") } func cachedKubeConfigPath(id string) string { diff --git a/cmd/root.go b/cmd/root.go index 35ce6ba3..4c3bd3fb 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -47,7 +47,7 @@ func init() { // - on macOS: $HOME/Library/Application Support // - on Windows: %APPDATA% or "C:\\Users\\%USER%\\AppData\\Roaming" func configPath() string { - return configdir.LocalConfig("gridscale") + return configdir.LocalConfig("gscloud") } // initConfig reads in config file and ENV variables if set. @@ -74,10 +74,11 @@ func initConfig() { os.Exit(1) } } - + if account == "" { account = "default" } + client = newCliClient(account) if client == nil { os.Exit(1) From 9681e5d7fa4d615e6b5da4d4721845218266b9d4 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 11:22:45 +0100 Subject: [PATCH 08/19] Add cliConfigPath function to cliconfig --- cmd/cliconfig.go | 10 ++++++++++ cmd/kubernetes.go | 1 - cmd/makeConfig.go | 6 +----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index 7c817c30..ef32cd88 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -5,6 +5,7 @@ import ( "net/http" "os" + "github.com/kirsle/configdir" "github.com/kardianos/osext" "github.com/spf13/viper" ) @@ -27,6 +28,15 @@ func cliPath() string { return filePath } +func cliConfigPath() string { + path := viper.ConfigFileUsed() + if path == "" { + path = configPath() + "/config.yaml" + viper.SetConfigFile(path) + } + return path +} + func newCliClient(account string) *gsclient { var ac accountEntry diff --git a/cmd/kubernetes.go b/cmd/kubernetes.go index 55299fad..a64d5e0d 100644 --- a/cmd/kubernetes.go +++ b/cmd/kubernetes.go @@ -10,7 +10,6 @@ import ( "path/filepath" "time" - "github.com/kirsle/configdir" "github.com/spf13/cobra" "gopkg.in/yaml.v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/cmd/makeConfig.go b/cmd/makeConfig.go index 36c1cf3d..3d5e9236 100644 --- a/cmd/makeConfig.go +++ b/cmd/makeConfig.go @@ -31,11 +31,7 @@ Create a new configuration file at a specified path: `, configPath()), RunE: func(cmd *cobra.Command, args []string) error { - path := viper.ConfigFileUsed() - if path == "" { - path = configPath() + "/config.yaml" - viper.SetConfigFile(path) - } + path := cliConfigPath() err := os.MkdirAll(configPath(), 0755) if err != nil { From 3a5a9cba60390251b770ba2cc4881c3fd2288ac9 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 11:27:27 +0100 Subject: [PATCH 09/19] Move ConfigPath to cliconfig --- cmd/cliconfig.go | 7 ++++++- cmd/root.go | 10 +--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index ef32cd88..3b33680d 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "os" + "path/filepath" "github.com/kirsle/configdir" "github.com/kardianos/osext" @@ -28,10 +29,14 @@ func cliPath() string { return filePath } +// configPath construct platform specific path to the configuration file. +// - on Linux: $XDG_CONFIG_HOME or $HOME/.config +// - on macOS: $HOME/Library/Application Support +// - on Windows: %APPDATA% or "C:\\Users\\%USER%\\AppData\\Roaming" func cliConfigPath() string { path := viper.ConfigFileUsed() if path == "" { - path = configPath() + "/config.yaml" + path = filepath.Join(configdir.LocalConfig("gscloud"), "config.yaml") viper.SetConfigFile(path) } return path diff --git a/cmd/root.go b/cmd/root.go index 4c3bd3fb..2c5bdb23 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -42,14 +42,6 @@ func init() { } -// configPath construct platform specific path to the configuration file. -// - on Linux: $XDG_CONFIG_HOME or $HOME/.config -// - on macOS: $HOME/Library/Application Support -// - on Windows: %APPDATA% or "C:\\Users\\%USER%\\AppData\\Roaming" -func configPath() string { - return configdir.LocalConfig("gscloud") -} - // initConfig reads in config file and ENV variables if set. func initConfig() { if cfgFile != "" { @@ -59,7 +51,7 @@ func initConfig() { // Use default paths. viper.SetConfigName("config") viper.SetConfigType("yaml") - viper.AddConfigPath(configPath()) + viper.AddConfigPath(cliConfigPath()) viper.AddConfigPath(".") } viper.AutomaticEnv() // read in environment variables that match From 4bb30e6397b3275bd40b0cb14e55348371abd021 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 11:28:00 +0100 Subject: [PATCH 10/19] Add cliCachePath function to cliconfig --- cmd/cliconfig.go | 4 ++++ cmd/kubernetes.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index 3b33680d..0353d649 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -42,6 +42,10 @@ func cliConfigPath() string { return path } +func cliCachePath() string { + return configdir.LocalCache("gscloud") +} + func newCliClient(account string) *gsclient { var ac accountEntry diff --git a/cmd/kubernetes.go b/cmd/kubernetes.go index a64d5e0d..bc8f1538 100644 --- a/cmd/kubernetes.go +++ b/cmd/kubernetes.go @@ -253,7 +253,7 @@ func fetchKubeConfigFromProvider(id string) *kubeConfig { } func kubeConfigCachePath() string { - return filepath.Join(configdir.LocalCache("gscloud"), "exec-credential") + return filepath.Join(cliCachePath(), "exec-credential") } func cachedKubeConfigPath(id string) string { From 11bdab7f0163e4b3d22e097c6f226a6ef19c20c3 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 11:36:02 +0100 Subject: [PATCH 11/19] Use cliConfigPath instead of configPath --- cmd/cliconfig.go | 2 +- cmd/kubernetes.go | 2 +- cmd/makeConfig.go | 6 ++---- cmd/root.go | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index 0353d649..0427a737 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -6,8 +6,8 @@ import ( "os" "path/filepath" - "github.com/kirsle/configdir" "github.com/kardianos/osext" + "github.com/kirsle/configdir" "github.com/spf13/viper" ) diff --git a/cmd/kubernetes.go b/cmd/kubernetes.go index bc8f1538..8e4d2752 100644 --- a/cmd/kubernetes.go +++ b/cmd/kubernetes.go @@ -93,7 +93,7 @@ var saveKubeconfigCmd = &cobra.Command{ Command: cliPath(), Args: []string{ "--config", - cfgFile, + cliConfigPath(), "--account", account, "kubernetes", diff --git a/cmd/makeConfig.go b/cmd/makeConfig.go index 3d5e9236..02efd42c 100644 --- a/cmd/makeConfig.go +++ b/cmd/makeConfig.go @@ -6,7 +6,6 @@ import ( "os" "github.com/spf13/cobra" - "github.com/spf13/viper" "gopkg.in/yaml.v2" ) @@ -29,11 +28,10 @@ Create a new configuration file at a specified path: gscloud --config ~/myconfig.yaml make-config -`, configPath()), +`, cliConfigPath()), RunE: func(cmd *cobra.Command, args []string) error { path := cliConfigPath() - - err := os.MkdirAll(configPath(), 0755) + err := os.MkdirAll(path, 0755) if err != nil { return err } diff --git a/cmd/root.go b/cmd/root.go index 2c5bdb23..d36fff17 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,7 +4,6 @@ import ( "fmt" "os" - "github.com/kirsle/configdir" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -33,7 +32,7 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", fmt.Sprintf("configuration file, default %s/config.yaml", configPath())) + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", fmt.Sprintf("configuration file, default %s/config.yaml", cliConfigPath())) rootCmd.PersistentFlags().StringVar(&account, "account", "", "the account used, 'default' if none given") rootCmd.AddCommand(kubernetesCmd) From 7067a71b6f9c8ba9302447e80a6007b207a71749 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 12:32:29 +0100 Subject: [PATCH 12/19] Avoid overwriting existing cli config file --- cmd/cliconfig.go | 3 +-- cmd/makeConfig.go | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index 0427a737..0806577a 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -4,7 +4,6 @@ import ( "fmt" "net/http" "os" - "path/filepath" "github.com/kardianos/osext" "github.com/kirsle/configdir" @@ -36,7 +35,7 @@ func cliPath() string { func cliConfigPath() string { path := viper.ConfigFileUsed() if path == "" { - path = filepath.Join(configdir.LocalConfig("gscloud"), "config.yaml") + path = configdir.LocalConfig("gscloud") viper.SetConfigFile(path) } return path diff --git a/cmd/makeConfig.go b/cmd/makeConfig.go index 02efd42c..72ce4958 100644 --- a/cmd/makeConfig.go +++ b/cmd/makeConfig.go @@ -30,18 +30,22 @@ Create a new configuration file at a specified path: `, cliConfigPath()), RunE: func(cmd *cobra.Command, args []string) error { - path := cliConfigPath() - err := os.MkdirAll(path, 0755) - if err != nil { - return err - } + dirPath := cliConfigPath() + filePath := dirPath + "/config.yaml" - err = ioutil.WriteFile(path, emptyConfig(), 0644) - if err != nil { - return err - } + _, err := os.Stat(filePath) + if os.IsNotExist(err) { + err = os.MkdirAll(dirPath, os.FileMode(0700)) + if err != nil { + return err + } - fmt.Println(path) + err = ioutil.WriteFile(filePath, emptyConfig(), 0644) + if err != nil { + return err + } + } + fmt.Println(filePath) return nil }, } From 7fe58c608e83d8de8992fb5c28ea31eb173a2456 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 12:42:17 +0100 Subject: [PATCH 13/19] Move fileExists function to cliconfig --- cmd/cliconfig.go | 10 +++++++++- cmd/kubernetes.go | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/cliconfig.go b/cmd/cliconfig.go index 0806577a..d244e2c6 100644 --- a/cmd/cliconfig.go +++ b/cmd/cliconfig.go @@ -35,7 +35,7 @@ func cliPath() string { func cliConfigPath() string { path := viper.ConfigFileUsed() if path == "" { - path = configdir.LocalConfig("gscloud") + path = configdir.LocalConfig("gscloud") + "/config.yaml" viper.SetConfigFile(path) } return path @@ -70,3 +70,11 @@ func newCliClient(account string) *gsclient { } return newClient(clientConf) } + +func fileExists(filename string) bool { + info, err := os.Stat(filename) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} diff --git a/cmd/kubernetes.go b/cmd/kubernetes.go index 8e4d2752..2b83d07b 100644 --- a/cmd/kubernetes.go +++ b/cmd/kubernetes.go @@ -307,11 +307,3 @@ func loadCachedKubeConfig(id string) (*clientauth.ExecCredential, error) { return execCredential, nil } - -func fileExists(filename string) bool { - info, err := os.Stat(filename) - if os.IsNotExist(err) { - return false - } - return !info.IsDir() -} From b0199c5ed47cf421baaea8e4fa234bc1fce7ea43 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 12:43:41 +0100 Subject: [PATCH 14/19] Use fileExists function to check whether cliconfig exists --- cmd/makeConfig.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/makeConfig.go b/cmd/makeConfig.go index 72ce4958..bf3a2638 100644 --- a/cmd/makeConfig.go +++ b/cmd/makeConfig.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "github.com/spf13/cobra" "gopkg.in/yaml.v2" @@ -30,12 +31,10 @@ Create a new configuration file at a specified path: `, cliConfigPath()), RunE: func(cmd *cobra.Command, args []string) error { - dirPath := cliConfigPath() - filePath := dirPath + "/config.yaml" + filePath := cliConfigPath() - _, err := os.Stat(filePath) - if os.IsNotExist(err) { - err = os.MkdirAll(dirPath, os.FileMode(0700)) + if !fileExists(filePath) { + err := os.MkdirAll(filepath.Dir(filePath), os.FileMode(0700)) if err != nil { return err } From 3ed47c02ada37572c0bed2005753aacc96a1214a Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 14 Jan 2020 12:47:40 +0100 Subject: [PATCH 15/19] Add Env attribute to ExecConfig --- cmd/kubernetes.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/kubernetes.go b/cmd/kubernetes.go index 2b83d07b..6b0d6f45 100644 --- a/cmd/kubernetes.go +++ b/cmd/kubernetes.go @@ -102,6 +102,7 @@ var saveKubeconfigCmd = &cobra.Command{ "--cluster", clusterID, }, + Env: []clientcmdapi.ExecEnvVar{}, }, } } else { From 6dccd25755929dc0810589d40fdf2f32a6aeb213 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Tue, 10 Mar 2020 16:45:24 +0100 Subject: [PATCH 16/19] Add Makefile to help in building binary --- .gitignore | 1 + Makefile | 26 ++++++++++++++++++++++++++ VERSION | 1 + 3 files changed, 28 insertions(+) create mode 100644 Makefile create mode 100644 VERSION diff --git a/.gitignore b/.gitignore index 4de565aa..b21204c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ gscloud .DS_Store +build diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..aa1afc1d --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +PLATFORMS=windows linux darwin +ARCHES=amd64 +BUILDDIR=build +VERSION=$$(cat VERSION) +EXECUTABLE_NAME=gscloud_$(VERSION) + +buildall: clean build zip + +build: + $(foreach platform,$(PLATFORMS), \ + $(foreach arch,$(ARCHES), \ + mkdir -p $(BUILDDIR); GOOS=$(platform) GOARCH=$(arch) go build -o $(BUILDDIR)/$(EXECUTABLE_NAME)_$(platform)_$(arch);)) + @echo "Renaming Windows file" + @if [ -f $(BUILDDIR)/$(EXECUTABLE_NAME)_windows_$(ARCHES) ]; then mv $(BUILDDIR)/$(EXECUTABLE_NAME)_windows_$(ARCHES) $(BUILDDIR)/$(EXECUTABLE_NAME)_windows_$(ARCHES).exe; fi + +zip: + $(foreach file,$(wildcard $(BUILDDIR)/*),\ + zip -j $(file).zip $(file);) + @if [ -f $(BUILDDIR)/$(EXECUTABLE_NAME)_windows_$(ARCHES).exe.zip ]; then mv $(BUILDDIR)/$(EXECUTABLE_NAME)_windows_$(ARCHES).exe.zip $(BUILDDIR)/$(EXECUTABLE_NAME)_windows_$(ARCHES).zip; fi + +clean: + $(foreach platform,$(PLATFORMS), \ + $(foreach arch,$(ARCHES), \ + rm -f $(BUILDDIR)/$(EXECUTABLE_NAME)*;)) + +.PHONY: buildall build clean zip diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..ac77e33e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0-beta \ No newline at end of file From fb46c1e69bbd14d7d229ae50a13c98650a28191b Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Wed, 11 Mar 2020 08:37:57 +0100 Subject: [PATCH 17/19] Update README with right paths --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71508c45..b50fb192 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Available Commands: Flags: --account string the account used, 'default' if none given - --config string configuration file, default /home/bk/.config/gridscale/config.yaml + --config string configuration file, default /home/bk/.config/gscloud/config.yaml -h, --help help for gscloud Use "gscloud [command] --help" for more information about a command. @@ -69,7 +69,7 @@ users: command: $HOME/gscloud args: - "--config" - - "$HOME/.gscloud/config.yaml" + - "$HOME/.config/gscloud/config.yaml" - "--account" - "test" - "kubernetes" From 92fd6662ad0696a8dc912faf4f445f5a35645d1d Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Wed, 11 Mar 2020 09:04:38 +0100 Subject: [PATCH 18/19] Update VERSION and CHANGELOG --- CHANGELOG.md | 5 +++++ VERSION | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6ce8718..3980f5cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## v0.2.0-beta (March 11, 2020) + +FEATURES: +* Use standard user-level cache directory https://github.com/gridscale/gscloud/issues/11 + ## v0.1.0-beta (January 8, 2020) - Initial release of gscloud diff --git a/VERSION b/VERSION index ac77e33e..f2a05766 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0-beta \ No newline at end of file +0.2.0-beta From f304b1237454015927dbaac5b9145c5f6d0c62b3 Mon Sep 17 00:00:00 2001 From: Ibrahim Takouna Date: Wed, 11 Mar 2020 08:36:51 +0100 Subject: [PATCH 19/19] Remove config.yaml from path LocalConfig loads the right path --- Makefile | 2 +- cmd/root.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index aa1afc1d..0cf70a24 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,6 @@ zip: clean: $(foreach platform,$(PLATFORMS), \ $(foreach arch,$(ARCHES), \ - rm -f $(BUILDDIR)/$(EXECUTABLE_NAME)*;)) + rm -f $(BUILDDIR)/gscloud_*;)) .PHONY: buildall build clean zip diff --git a/cmd/root.go b/cmd/root.go index d36fff17..5cc50bad 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -32,7 +32,7 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", fmt.Sprintf("configuration file, default %s/config.yaml", cliConfigPath())) + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", fmt.Sprintf("configuration file, default %s", cliConfigPath())) rootCmd.PersistentFlags().StringVar(&account, "account", "", "the account used, 'default' if none given") rootCmd.AddCommand(kubernetesCmd)