Commit e4d8582a authored by Christopher Harm's avatar Christopher Harm

Starting to prompt for docker login

parent 693dc37f
Pipeline #32209 passed with stage
in 38 seconds
......@@ -33,6 +33,9 @@ var buildCmd = &cobra.Command{
Use: "build",
Short: "build the application",
Run: func(cmd *cobra.Command, args []string) {
environment.DockerLogin()
os.Exit(1)
prereqsInstalled := checkLocalSetup()
if !prereqsInstalled {
color.Red("Please install the required applications and try again.\n")
......
......@@ -66,6 +66,13 @@ func init() {
// 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")
rootCmd.PersistentFlags().StringP("docker-host", "d", "", "Specify docker host to login to")
viper.SetDefault("build.docker.host", "nexus.ci.psu.edu:5000")
err := viper.BindPFlag("build.docker.host", rootCmd.PersistentFlags().Lookup("docker-host"))
if err != nil {
panic("invalid arg")
}
}
// initConfig reads in config file and ENV variables if set.
......
......@@ -6,6 +6,8 @@ import (
"regexp"
"strings"
"github.com/spf13/viper"
"github.com/fatih/color"
)
......@@ -23,6 +25,15 @@ func EvalDockerEnv() {
}
}
func DockerLogin() {
dockerHost := viper.GetString("build.docker.host")
err := Run(true, "docker", "login", dockerHost)
if err != nil {
color.New(color.FgRed).Printf("Command Failed with '%s'\n", err)
}
}
func Run(viewOutput bool, name string, args ...string) error {
cmd := exec.Command(name, args...)
......
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