Commit 83183f14 authored by CRAIG BENNER's avatar CRAIG BENNER

remove this as concept already exists

parent cd9a99f9
Pipeline #86656 passed with stages
in 28 seconds
// Copyright © 2019 NAME HERE <EMAIL ADDRESS>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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 (
"git.psu.edu/k8s/devtool/config"
"github.com/fatih/color"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// localEnvCmd represents the build command
var localEnvCmd = &cobra.Command{
Use: "localEnv",
Short: "localEnv setup/teardown the application",
Run: func(cmd *cobra.Command, args []string) {
conf, err := config.New(configFile)
if err != nil {
color.New(color.FgRed).Printf("Error reading configuration file: %s\n", configFile)
return
}
checkEnvVars(conf)
},
}
func init() {
rootCmd.AddCommand(localEnvCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// buildCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// buildCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
localEnvCmd.Flags().Bool("setup", false, "Put all ConfigMaps Into local Environment variables")
viper.SetDefault("setup", false)
err := viper.BindPFlag("setup", buildCmd.Flags().Lookup("localEnv-setup"))
if err != nil {
panic("invalid arg")
}
localEnvCmd.Flags().Bool("teardown", false, "Remove all ConfigMaps Into local Environment variables")
viper.SetDefault("teardown", false)
err = viper.BindPFlag("teardown", buildCmd.Flags().Lookup("localEnv-teardown"))
if err != nil {
panic("invalid arg")
}
}
func localEnv(config config.Config) error {
dep, err := promptForLocalEnv(config)
if err != nil {
return err
}
if viper.GetBool("setup") {
color.Blue("LocalEnv Setup.")
setupEnvVars(dep)
} else if viper.GetBool("teardown") {
color.Blue("LocalEnv Teardown.")
teardownEnvVars(dep)
} else {
color.Yellow("Missing Argument")
panic("invalid arg")
}
return nil
}
func promptForLocalEnv(conf config.Config) (*config.Deployable, error) {
var promptItems []string
for _, deployable := range conf.Deployables {
promptItems = append(promptItems, deployable.Name)
}
promptSelect := promptui.Select{
Label: "Which Deployable?",
Items: promptItems,
}
response, responseString, err := promptSelect.Run()
if err != nil {
return nil, err
}
color.Blue("You choose :: " + responseString)
return &conf.Deployables[response], nil
}
func setupEnvVars(*config.Deployable) {
}
func teardownEnvVars(*config.Deployable) {}
func getEnvVarsFromConfig() {}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment