mirror of https://github.com/kubernetes/kops.git
Merge pull request #2052 from reactiveops/fix_gh_1953
Feedback for kops create -f when operation succeeds
This commit is contained in:
commit
e50f6c661a
|
@ -84,6 +84,10 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
|
|||
|
||||
codec := codecs.UniversalDecoder(kopsapi.SchemeGroupVersion)
|
||||
|
||||
var clusterName = ""
|
||||
//var cSpec = false
|
||||
var sb bytes.Buffer
|
||||
fmt.Fprintf(&sb, "\n")
|
||||
for _, f := range c.Filenames {
|
||||
contents, err := vfs.Context.ReadFile(f)
|
||||
if err != nil {
|
||||
|
@ -91,7 +95,6 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
|
|||
}
|
||||
|
||||
sections := bytes.Split(contents, []byte("\n---\n"))
|
||||
|
||||
for _, section := range sections {
|
||||
defaults := &schema.GroupVersionKind{
|
||||
Group: v1alpha1.SchemeGroupVersion.Group,
|
||||
|
@ -111,6 +114,7 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
|
|||
}
|
||||
return fmt.Errorf("error creating federation: %v", err)
|
||||
}
|
||||
fmt.Fprintf(&sb, "Created federation/%q\n", v.ObjectMeta.Name)
|
||||
|
||||
case *kopsapi.Cluster:
|
||||
// Adding a PerformAssignments() call here as the user might be trying to use
|
||||
|
@ -125,10 +129,13 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
|
|||
return fmt.Errorf("cluster %q already exists", v.ObjectMeta.Name)
|
||||
}
|
||||
return fmt.Errorf("error creating cluster: %v", err)
|
||||
} else {
|
||||
fmt.Fprintf(&sb, "Created cluster/%s\n", v.ObjectMeta.Name)
|
||||
//cSpec = true
|
||||
}
|
||||
|
||||
case *kopsapi.InstanceGroup:
|
||||
clusterName := v.ObjectMeta.Labels[kopsapi.LabelClusterName]
|
||||
clusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName]
|
||||
if clusterName == "" {
|
||||
return fmt.Errorf("must specify %q label with cluster name to create instanceGroup", kopsapi.LabelClusterName)
|
||||
}
|
||||
|
@ -138,15 +145,29 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
|
|||
return fmt.Errorf("instanceGroup %q already exists", v.ObjectMeta.Name)
|
||||
}
|
||||
return fmt.Errorf("error creating instanceGroup: %v", err)
|
||||
} else {
|
||||
fmt.Fprintf(&sb, "Created instancegroup/%s\n", v.ObjectMeta.Name)
|
||||
}
|
||||
|
||||
default:
|
||||
glog.V(2).Infof("Type of object was %T", v)
|
||||
return fmt.Errorf("Unhandled kind %q in %q", gvk, f)
|
||||
return fmt.Errorf("Unhandled kind %q in %s", gvk, f)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
// If there is a value in this sb, this should mean that we have something to deploy
|
||||
// so let's advise the user how to engage the cloud provider and deploy
|
||||
if sb.String() != "" {
|
||||
fmt.Fprintf(&sb, "\n")
|
||||
fmt.Fprintf(&sb, "To deploy these resources, run: kops update cluster %s --yes\n", clusterName)
|
||||
fmt.Fprintf(&sb, "\n")
|
||||
}
|
||||
_, err := out.Write(sb.Bytes())
|
||||
if err != nil {
|
||||
return fmt.Errorf("error writing to output: %v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue