summaryrefslogtreecommitdiffstats
path: root/clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go
diff options
context:
space:
mode:
authorearrage <eddie.arrage@huawei.com>2018-11-05 11:49:36 -0800
committerearrage <eddie.arrage@huawei.com>2018-11-05 16:24:29 -0800
commit265bdb46e6875cb5c75e6db8e98a38775da69391 (patch)
tree526c69d2af7ca2538a0bb6ca86b0fdd062d844a2 /clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go
parentad43226c30daec6b5d4a1379650994427361a3f8 (diff)
Add ability to read controller nodeport IP from file
- Formalize use of cloverctl config file using viper - Default name of config file is '.cloverctl.yaml' - Look for file in home directory or relative to cloverctl executable - Single value in config is for 'ControllerIP: <IP Address>' - Still try and retrieve port value of clover-controller nodeport automatically - Still try and retrieve IP address of clover-controller LB if GKE environment is being used and override config file value if found in current kube context - Improve error messaging if controller connect fails - Clean up the CLI help output - Modify jmeter 'get testresult' command to avoid the use of flags and use arguments instead Change-Id: Id95d1b3d1079ac84996681db62da1f9b6b8a88b5 Signed-off-by: earrage <eddie.arrage@huawei.com>
Diffstat (limited to 'clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go')
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go b/clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go
index 77045f6..37e8aeb 100644
--- a/clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go
+++ b/clover/cloverctl/src/cloverctl/cmd/create_docker_registry.go
@@ -10,7 +10,7 @@ package cmd
import (
"fmt"
"io/ioutil"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
@@ -28,21 +28,24 @@ var dockerregistryCmd = &cobra.Command{
func init() {
providercreateCmd.AddCommand(dockerregistryCmd)
- dockerregistryCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file to add kubernetes provider")
+ dockerregistryCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file to add docker registry")
dockerregistryCmd.MarkFlagRequired("file")
}
func createDockerRegistry() {
+ checkControllerIP()
url := controllerIP + "/halyard/addregistry"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
- fmt.Println("Please specify a valid rule definition yaml file")
- return
+ fmt.Println("Please specify a valid yaml file")
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
@@ -50,7 +53,8 @@ func createDockerRegistry() {
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)