Skip to content

Commit

Permalink
remove arch specific implementations for files where unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Cane committed Sep 22, 2019
1 parent a710ec5 commit fda6b2c
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 344 deletions.
23 changes: 5 additions & 18 deletions cmd/remove_linux.go → cmd/remove.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build linux

/*
Copyright © 2019 Zee Ahmed <zee@simplyzee.dev>
Expand All @@ -15,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
Expand All @@ -25,7 +24,6 @@ import (
"github.com/spf13/cobra"
)

// removeCmd represents the remove command
var removeCmd = &cobra.Command{
Use: "remove",
Short: "Remove a kubectl version from machine",
Expand All @@ -39,36 +37,25 @@ var removeCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(removeCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// removeCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// removeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// RemoveKubectlVersion - removes specific kubectl version from machine
func RemoveKubectlVersion(version string) error {
// Get user home directory path
homeDir, err := os.UserHomeDir()
if err != nil {
log.Fatal(err)
}

kubectlVersion := homeDir + "/.kubemngr/kubectl-" + version

// Check if version exists to remove it
// Check if version to be removed exists
_, err = os.Stat(kubectlVersion)
if err == nil {
fmt.Printf("Removing kubectl %s", version)
os.Remove(kubectlVersion)
return nil
} else {
fmt.Printf("kubectl version %s doesn't exist", version)
return nil
}

fmt.Printf("kubectl %s is not installed", version)
return nil
}
74 changes: 0 additions & 74 deletions cmd/remove_darwin.go

This file was deleted.

21 changes: 1 addition & 20 deletions cmd/root_linux.go → cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build linux

/*
Copyright © 2019 Zee Ahmed <zee@simplyzee.dev>
Expand All @@ -15,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
Expand All @@ -30,15 +29,11 @@ import (
var cfgFile string
var clientVersion string

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "kubemngr",
Short: "A tool manage different kubectl versions inside a workspace.",
Long: `This tool is to help developers run different versions of kubectl within their workspace and to support working
with different versions of Kubernetes clusters.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -54,32 +49,18 @@ func Execute(version string) {

func init() {
cobra.OnInitialize(initConfig)

// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

//rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.kubemngr.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// Search config in home directory with name ".kubemngr" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".kubemngr")
}
Expand Down
97 changes: 0 additions & 97 deletions cmd/root_darwin.go

This file was deleted.

14 changes: 1 addition & 13 deletions cmd/use_darwin.go → cmd/use.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build linux

/*
Copyright © 2019 Zee Ahmed <zee@simplyzee.dev>
Expand All @@ -15,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
Expand All @@ -25,7 +24,6 @@ import (
"github.com/spf13/cobra"
)

// useCmd represents the use command
var useCmd = &cobra.Command{
Use: "use",
Short: "Use a specific version of one of the downloaded kubectl binaries",
Expand All @@ -39,16 +37,6 @@ var useCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(useCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// useCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// useCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// UseKubectlBinary - sets kubectl to the version specified
Expand Down
Loading

0 comments on commit fda6b2c

Please sign in to comment.