From b0b83ed125df1474b180207c0ae480dd3995dde7 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 11 Jul 2021 22:07:02 -0700 Subject: [PATCH 1/5] Clean up "kops edit" --- cmd/kops/edit.go | 27 ++------------------------- docs/cli/kops_edit.md | 20 -------------------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/cmd/kops/edit.go b/cmd/kops/edit.go index 0dd434af0d990..50076454b6179 100644 --- a/cmd/kops/edit.go +++ b/cmd/kops/edit.go @@ -22,35 +22,12 @@ import ( "github.com/spf13/cobra" "k8s.io/kops/cmd/kops/util" "k8s.io/kubectl/pkg/util/i18n" - "k8s.io/kubectl/pkg/util/templates" -) - -var ( - editLong = templates.LongDesc(i18n.T(`Edit a resource configuration. - This command changes the desired configuration in the registry. - - To set your preferred editor, you can define the EDITOR environment variable. - When you have done this, kOps will use the editor that you have set. - - kops edit does not update the cloud resources, to apply the changes use "kops update cluster". - `)) - - editExample = templates.Examples(i18n.T(` - # Edit a cluster configuration. - kops edit cluster k8s-cluster.example.com --state=s3://my-state-store - - # Edit a instance group configuration. - kops edit ig --name k8s-cluster.example.com \ - --state=s3://my-state-store nodes - `)) ) func NewCmdEdit(f *util.Factory, out io.Writer) *cobra.Command { cmd := &cobra.Command{ - Use: "edit", - Short: i18n.T("Edit clusters and other resources."), - Long: editLong, - Example: editExample, + Use: "edit", + Short: i18n.T("Edit clusters and other resources."), } // create subcommands diff --git a/docs/cli/kops_edit.md b/docs/cli/kops_edit.md index b9922c7e77764..6136b2555f6bb 100644 --- a/docs/cli/kops_edit.md +++ b/docs/cli/kops_edit.md @@ -5,26 +5,6 @@ Edit clusters and other resources. -### Synopsis - -Edit a resource configuration. This command changes the desired configuration in the registry. - - To set your preferred editor, you can define the EDITOR environment variable. - When you have done this, kOps will use the editor that you have set. - - kops edit does not update the cloud resources, to apply the changes use "kops update cluster". - -### Examples - -``` - # Edit a cluster configuration. - kops edit cluster k8s-cluster.example.com --state=s3://my-state-store - - # Edit a instance group configuration. - kops edit ig --name k8s-cluster.example.com \ - --state=s3://my-state-store nodes -``` - ### Options ``` From ea9678573e01b98b88abb3ae5e51548b783e1003 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 11 Jul 2021 22:10:43 -0700 Subject: [PATCH 2/5] Implement completion for "kops edit cluster" --- cmd/kops/edit_cluster.go | 47 ++++++++++++++++------------------- docs/cli/kops_edit_cluster.md | 9 +++---- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/cmd/kops/edit_cluster.go b/cmd/kops/edit_cluster.go index cf5846c9d4d96..b05e617ccd99c 100644 --- a/cmd/kops/edit_cluster.go +++ b/cmd/kops/edit_cluster.go @@ -32,8 +32,10 @@ import ( "k8s.io/kops/pkg/apis/kops/validation" "k8s.io/kops/pkg/assets" "k8s.io/kops/pkg/commands" + "k8s.io/kops/pkg/commands/commandutils" "k8s.io/kops/pkg/edit" "k8s.io/kops/pkg/kopscodecs" + "k8s.io/kops/pkg/pretty" "k8s.io/kops/pkg/try" "k8s.io/kops/upup/pkg/fi/cloudup" util_editor "k8s.io/kubectl/pkg/cmd/util/editor" @@ -42,6 +44,7 @@ import ( ) type EditClusterOptions struct { + ClusterName string } var ( @@ -49,14 +52,14 @@ var ( This command changes the desired cluster configuration in the registry. - To set your preferred editor, you can define the EDITOR environment variable. - When you have done this, kOps will use the editor that you have set. + To set your preferred editor, you can define the EDITOR environment variable. + When you have done this, kOps will use the editor that you have set. - kops edit does not update the cloud resources, to apply the changes use "kops update cluster".`)) + kops edit does not update the cloud resources, to apply the changes use ` + pretty.Bash("kops update cluster") + `.`)) editClusterExample = templates.Examples(i18n.T(` - # Edit a cluster configuration in AWS. - kops edit cluster k8s.cluster.site --state=s3://my-state-store + # Edit a cluster configuration in AWS. + kops edit cluster k8s.cluster.site --state=s3://my-state-store `)) ) @@ -64,30 +67,22 @@ func NewCmdEditCluster(f *util.Factory, out io.Writer) *cobra.Command { options := &EditClusterOptions{} cmd := &cobra.Command{ - Use: "cluster", - Short: i18n.T("Edit cluster."), - Long: editClusterLong, - Example: editClusterExample, - Run: func(cmd *cobra.Command, args []string) { - ctx := context.TODO() - - err := RunEditCluster(ctx, f, cmd, args, out, options) - if err != nil { - exitWithError(err) - } + Use: "cluster [CLUSTER]", + Short: i18n.T("Edit cluster."), + Long: editClusterLong, + Example: editClusterExample, + Args: rootCommand.clusterNameArgs(&options.ClusterName), + ValidArgsFunction: commandutils.CompleteClusterName(&rootCommand, true), + RunE: func(cmd *cobra.Command, args []string) error { + return RunEditCluster(context.TODO(), f, out, options) }, } return cmd } -func RunEditCluster(ctx context.Context, f *util.Factory, cmd *cobra.Command, args []string, out io.Writer, options *EditClusterOptions) error { - err := rootCommand.ProcessArgs(args) - if err != nil { - return err - } - - oldCluster, err := rootCommand.Cluster(ctx) +func RunEditCluster(ctx context.Context, f *util.Factory, out io.Writer, options *EditClusterOptions) error { + oldCluster, err := GetCluster(ctx, f, options.ClusterName) if err != nil { return err } @@ -145,7 +140,7 @@ func RunEditCluster(ctx context.Context, f *util.Factory, cmd *cobra.Command, ar if containsError { if bytes.Equal(stripComments(editedDiff), stripComments(edited)) { - return preservedFile(fmt.Errorf("%s", "Edit cancelled, no valid changes were saved."), file, out) + return preservedFile(fmt.Errorf("%s", "Edit cancelled: no valid changes were saved."), file, out) } } @@ -155,7 +150,7 @@ func RunEditCluster(ctx context.Context, f *util.Factory, cmd *cobra.Command, ar if bytes.Equal(stripComments(raw), stripComments(edited)) { try.RemoveFile(file) - fmt.Fprintln(out, "Edit cancelled, no changes made.") + fmt.Fprintln(out, "Edit cancelled: no changes made.") return nil } @@ -165,7 +160,7 @@ func RunEditCluster(ctx context.Context, f *util.Factory, cmd *cobra.Command, ar } if !lines { try.RemoveFile(file) - fmt.Fprintln(out, "Edit cancelled, saved file was empty.") + fmt.Fprintln(out, "Edit cancelled: saved file was empty.") return nil } diff --git a/docs/cli/kops_edit_cluster.md b/docs/cli/kops_edit_cluster.md index 2734cdcb2c5ca..45d1fae539168 100644 --- a/docs/cli/kops_edit_cluster.md +++ b/docs/cli/kops_edit_cluster.md @@ -11,13 +11,12 @@ Edit a cluster configuration. This command changes the desired cluster configuration in the registry. - To set your preferred editor, you can define the EDITOR environment variable. - When you have done this, kOps will use the editor that you have set. - - kops edit does not update the cloud resources, to apply the changes use "kops update cluster". + To set your preferred editor, you can define the EDITOR environment variable. When you have done this, kOps will use the editor that you have set. + + kops edit does not update the cloud resources, to apply the changes usekops update cluster . ``` -kops edit cluster [flags] +kops edit cluster [CLUSTER] [flags] ``` ### Examples From 6eda65d9f77fa6b7374bf8a52e1e2077389c4015 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 11 Jul 2021 22:38:07 -0700 Subject: [PATCH 3/5] Implement completion for "kops edit instancegroup" --- cmd/kops/delete_instancegroup.go | 4 +-- cmd/kops/edit_instancegroup.go | 56 ++++++++++++++++------------- docs/cli/kops_edit_instancegroup.md | 9 +++-- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/cmd/kops/delete_instancegroup.go b/cmd/kops/delete_instancegroup.go index d3a6e8fda3941..c2a3f02403560 100644 --- a/cmd/kops/delete_instancegroup.go +++ b/cmd/kops/delete_instancegroup.go @@ -75,13 +75,13 @@ func NewCmdDeleteInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command { } if len(args) == 0 { - return fmt.Errorf("must specify the name of instance group to delete") + return fmt.Errorf("must specify the name of the instance group to delete") } options.GroupName = args[0] if len(args) != 1 { - return fmt.Errorf("can only edit one instance group at a time") + return fmt.Errorf("can only delete one instance group at a time") } return nil diff --git a/cmd/kops/edit_instancegroup.go b/cmd/kops/edit_instancegroup.go index ec95b8d6b3273..2e2b268a59618 100644 --- a/cmd/kops/edit_instancegroup.go +++ b/cmd/kops/edit_instancegroup.go @@ -44,55 +44,65 @@ var ( This command changes the instancegroup desired configuration in the registry. - To set your preferred editor, you can define the EDITOR environment variable. - When you have done this, kOps will use the editor that you have set. + To set your preferred editor, you can define the EDITOR environment variable. + When you have done this, kOps will use the editor that you have set. kops edit does not update the cloud resources, to apply the changes use "kops update cluster".`)) editInstancegroupExample = templates.Examples(i18n.T(` # Edit an instancegroup desired configuration. - kops edit ig --name k8s-cluster.example.com nodes --state=s3://my-state-store + kops edit instancegroup --name k8s-cluster.example.com nodes --state=s3://my-state-store `)) editInstancegroupShort = i18n.T(`Edit instancegroup.`) ) type EditInstanceGroupOptions struct { + ClusterName string + GroupName string } func NewCmdEditInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command { options := &EditInstanceGroupOptions{} cmd := &cobra.Command{ - Use: "instancegroup", + Use: "instancegroup INSTANCE_GROUP", Aliases: []string{"instancegroups", "ig"}, Short: editInstancegroupShort, Long: editInstancegroupLong, Example: editInstancegroupExample, - Run: func(cmd *cobra.Command, args []string) { - ctx := context.TODO() + Args: func(cmd *cobra.Command, args []string) error { + options.ClusterName = rootCommand.ClusterName(true) - err := RunEditInstanceGroup(ctx, f, cmd, args, os.Stdout, options) - if err != nil { - exitWithError(err) + if options.ClusterName == "" { + return fmt.Errorf("--name is required") } + + if len(args) == 0 { + return fmt.Errorf("must specify the name of the instance group to edit") + } + + options.GroupName = args[0] + + if len(args) != 1 { + return fmt.Errorf("can only edit one instance group at a time") + } + + return nil + }, + ValidArgsFunction: completeInstanceGroup(nil, nil), + RunE: func(cmd *cobra.Command, args []string) error { + return RunEditInstanceGroup(context.TODO(), f, out, options) }, } return cmd } -func RunEditInstanceGroup(ctx context.Context, f *util.Factory, cmd *cobra.Command, args []string, out io.Writer, options *EditInstanceGroupOptions) error { - if len(args) == 0 { - return fmt.Errorf("Specify name of instance group to edit") - } - if len(args) != 1 { - return fmt.Errorf("Can only edit one instance group at a time") - } - - groupName := args[0] +func RunEditInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, options *EditInstanceGroupOptions) error { + groupName := options.GroupName - cluster, err := rootCommand.Cluster(ctx) + cluster, err := GetCluster(ctx, f, options.ClusterName) if err != nil { return err } @@ -102,15 +112,11 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, cmd *cobra.Comma klog.Warningf("%v", err) } - clientset, err := rootCommand.Clientset() + clientset, err := f.Clientset() if err != nil { return err } - if groupName == "" { - return fmt.Errorf("name is required") - } - oldGroup, err := clientset.InstanceGroupsFor(cluster).Get(ctx, groupName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("error reading InstanceGroup %q: %v", groupName, err) @@ -141,7 +147,7 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, cmd *cobra.Comma } if bytes.Equal(edited, raw) { - fmt.Fprintln(os.Stderr, "Edit cancelled, no changes made.") + fmt.Fprintln(out, "Edit cancelled: no changes made.") return nil } diff --git a/docs/cli/kops_edit_instancegroup.md b/docs/cli/kops_edit_instancegroup.md index f37ccfb7bc23e..285d3078f0f3f 100644 --- a/docs/cli/kops_edit_instancegroup.md +++ b/docs/cli/kops_edit_instancegroup.md @@ -11,20 +11,19 @@ Edit a cluster configuration. This command changes the instancegroup desired configuration in the registry. - To set your preferred editor, you can define the EDITOR environment variable. - When you have done this, kOps will use the editor that you have set. - + To set your preferred editor, you can define the EDITOR environment variable. When you have done this, kOps will use the editor that you have set. + kops edit does not update the cloud resources, to apply the changes use "kops update cluster". ``` -kops edit instancegroup [flags] +kops edit instancegroup INSTANCE_GROUP [flags] ``` ### Examples ``` # Edit an instancegroup desired configuration. - kops edit ig --name k8s-cluster.example.com nodes --state=s3://my-state-store + kops edit instancegroup --name k8s-cluster.example.com nodes --state=s3://my-state-store ``` ### Options From 23478734ae4bb67c6354d78566fcb78c04403fbd Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 11 Jul 2021 23:00:08 -0700 Subject: [PATCH 4/5] Give "edit instancegroup" parity with "edit cluster" --- cmd/kops/edit_instancegroup.go | 180 ++++++++++++++++++++++++--------- 1 file changed, 130 insertions(+), 50 deletions(-) diff --git a/cmd/kops/edit_instancegroup.go b/cmd/kops/edit_instancegroup.go index 2e2b268a59618..44c58a3fee6cf 100644 --- a/cmd/kops/edit_instancegroup.go +++ b/cmd/kops/edit_instancegroup.go @@ -23,6 +23,7 @@ import ( "io" "os" "path/filepath" + "strings" "github.com/spf13/cobra" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -31,6 +32,7 @@ import ( api "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/kops/validation" "k8s.io/kops/pkg/assets" + "k8s.io/kops/pkg/edit" "k8s.io/kops/pkg/kopscodecs" "k8s.io/kops/pkg/try" "k8s.io/kops/upup/pkg/fi/cloudup" @@ -126,7 +128,7 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, o } var ( - edit = editor.NewDefaultEditor(editorEnvs) + editor = editor.NewDefaultEditor(editorEnvs) ) ext := "yaml" @@ -135,64 +137,142 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, o return err } - // launch the editor - edited, file, err := edit.LaunchTempFile(fmt.Sprintf("%s-edit-", filepath.Base(os.Args[0])), ext, bytes.NewReader(raw)) - defer func() { - if file != "" { + var ( + results = editResults{} + edited = []byte{} + file string + ) + + containsError := false + + for { + buf := &bytes.Buffer{} + results.header.writeTo(buf) + results.header.flush() + + if !containsError { + buf.Write(raw) + } else { + buf.Write(stripComments(edited)) + } + + // launch the editor + editedDiff := edited + edited, file, err = editor.LaunchTempFile(fmt.Sprintf("%s-edit-", filepath.Base(os.Args[0])), ext, buf) + if err != nil { + return preservedFile(fmt.Errorf("error launching editor: %v", err), results.file, out) + } + + if containsError { + if bytes.Equal(stripComments(editedDiff), stripComments(edited)) { + return preservedFile(fmt.Errorf("%s", "Edit cancelled: no valid changes were saved."), file, out) + } + } + + if len(results.file) > 0 { + try.RemoveFile(results.file) + } + + if bytes.Equal(stripComments(raw), stripComments(edited)) { try.RemoveFile(file) + fmt.Fprintln(out, "Edit cancelled: no changes made.") + return nil } - }() - if err != nil { - return fmt.Errorf("error launching editor: %v", err) - } - if bytes.Equal(edited, raw) { - fmt.Fprintln(out, "Edit cancelled: no changes made.") - return nil - } + lines, err := hasLines(bytes.NewBuffer(edited)) + if err != nil { + return preservedFile(err, file, out) + } + if !lines { + try.RemoveFile(file) + fmt.Fprintln(out, "Edit cancelled: saved file was empty.") + return nil + } - newObj, _, err := kopscodecs.Decode(edited, nil) - if err != nil { - return fmt.Errorf("error parsing InstanceGroup: %v", err) - } + newObj, _, err := kopscodecs.Decode(edited, nil) + if err != nil { + return preservedFile(fmt.Errorf("error parsing InstanceGroup: %v", err), file, out) + } - newGroup, ok := newObj.(*api.InstanceGroup) - if !ok { - return fmt.Errorf("object was not of expected type: %T", newObj) - } + newGroup, ok := newObj.(*api.InstanceGroup) + if !ok { + results = editResults{ + file: file, + } + results.header.addError(fmt.Sprintf("object was not of expected type: %T", newObj)) + containsError = true + continue + } - cloud, err := cloudup.BuildCloud(cluster) - if err != nil { - return err - } - fullGroup, err := cloudup.PopulateInstanceGroupSpec(cluster, newGroup, cloud, channel) - if err != nil { - return err - } + extraFields, err := edit.HasExtraFields(string(edited), newObj) + if err != nil { + results = editResults{ + file: file, + } + results.header.addError(fmt.Sprintf("error checking for extra fields: %v", err)) + containsError = true + continue + } + if extraFields != "" { + results = editResults{ + file: file, + } + lines := strings.Split(extraFields, "\n") + for _, line := range lines { + results.header.addExtraFields(line) + } + containsError = true + continue + } - // We need the full cluster spec to perform deep validation - // Note that we don't write it back though - err = cloudup.PerformAssignments(cluster, cloud) - if err != nil { - return fmt.Errorf("error populating configuration: %v", err) - } + cloud, err := cloudup.BuildCloud(cluster) + if err != nil { + return err + } + fullGroup, err := cloudup.PopulateInstanceGroupSpec(cluster, newGroup, cloud, channel) + if err != nil { + results = editResults{ + file: file, + } + results.header.addError(fmt.Sprintf("error populating instance group spec: %s", err)) + containsError = true + continue + } - assetBuilder := assets.NewAssetBuilder(cluster, false) - fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, cloud, assetBuilder) - if err != nil { - return err - } + // We need the full cluster spec to perform deep validation + // Note that we don't write it back though + err = cloudup.PerformAssignments(cluster, cloud) + if err != nil { + return preservedFile(fmt.Errorf("error populating configuration: %v", err), file, out) + } - err = validation.CrossValidateInstanceGroup(fullGroup, fullCluster, cloud).ToAggregate() - if err != nil { - return err - } + assetBuilder := assets.NewAssetBuilder(cluster, false) + fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, cloud, assetBuilder) + if err != nil { + results = editResults{ + file: file, + } + results.header.addError(fmt.Sprintf("error populating cluster spec: %s", err)) + containsError = true + continue + } - // Note we perform as much validation as we can, before writing a bad config - _, err = clientset.InstanceGroupsFor(cluster).Update(ctx, fullGroup, metav1.UpdateOptions{}) - if err != nil { - return err - } + err = validation.CrossValidateInstanceGroup(fullGroup, fullCluster, cloud).ToAggregate() + if err != nil { + results = editResults{ + file: file, + } + results.header.addError(fmt.Sprintf("validation failed: %s", err)) + containsError = true + continue + } - return nil + // Note we perform as much validation as we can, before writing a bad config + _, err = clientset.InstanceGroupsFor(cluster).Update(ctx, fullGroup, metav1.UpdateOptions{}) + if err != nil { + return preservedFile(err, file, out) + } + + return nil + } } From be30a61983217b2e6032f70b4ceb48821bafd465 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sun, 11 Jul 2021 23:05:06 -0700 Subject: [PATCH 5/5] Move EditorEnvs to pkg --- cmd/kops/BUILD.bazel | 1 - cmd/kops/create_instancegroup.go | 2 +- cmd/kops/edit_cluster.go | 2 +- cmd/kops/edit_instancegroup.go | 3 ++- pkg/commands/commandutils/BUILD.bazel | 1 + {cmd/kops => pkg/commands/commandutils}/editor.go | 4 ++-- 6 files changed, 7 insertions(+), 6 deletions(-) rename {cmd/kops => pkg/commands/commandutils}/editor.go (88%) diff --git a/cmd/kops/BUILD.bazel b/cmd/kops/BUILD.bazel index 6125400d59203..68b4c99ad066c 100644 --- a/cmd/kops/BUILD.bazel +++ b/cmd/kops/BUILD.bazel @@ -25,7 +25,6 @@ go_library( "edit.go", "edit_cluster.go", "edit_instancegroup.go", - "editor.go", "export.go", "export_kubecfg.go", "gen_help_docs.go", diff --git a/cmd/kops/create_instancegroup.go b/cmd/kops/create_instancegroup.go index 1ad3bd7d84d78..44eb3e89ad3e7 100644 --- a/cmd/kops/create_instancegroup.go +++ b/cmd/kops/create_instancegroup.go @@ -232,7 +232,7 @@ func RunCreateInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, if options.Edit { var ( - edit = editor.NewDefaultEditor(editorEnvs) + edit = editor.NewDefaultEditor(commandutils.EditorEnvs) ) raw, err := kopscodecs.ToVersionedYaml(ig) diff --git a/cmd/kops/edit_cluster.go b/cmd/kops/edit_cluster.go index b05e617ccd99c..cb3953a5eb964 100644 --- a/cmd/kops/edit_cluster.go +++ b/cmd/kops/edit_cluster.go @@ -103,7 +103,7 @@ func RunEditCluster(ctx context.Context, f *util.Factory, out io.Writer, options } var ( - editor = util_editor.NewDefaultEditor(editorEnvs) + editor = util_editor.NewDefaultEditor(commandutils.EditorEnvs) ) ext := "yaml" diff --git a/cmd/kops/edit_instancegroup.go b/cmd/kops/edit_instancegroup.go index 44c58a3fee6cf..ad17fe6cdf177 100644 --- a/cmd/kops/edit_instancegroup.go +++ b/cmd/kops/edit_instancegroup.go @@ -32,6 +32,7 @@ import ( api "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/kops/validation" "k8s.io/kops/pkg/assets" + "k8s.io/kops/pkg/commands/commandutils" "k8s.io/kops/pkg/edit" "k8s.io/kops/pkg/kopscodecs" "k8s.io/kops/pkg/try" @@ -128,7 +129,7 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, o } var ( - editor = editor.NewDefaultEditor(editorEnvs) + editor = editor.NewDefaultEditor(commandutils.EditorEnvs) ) ext := "yaml" diff --git a/pkg/commands/commandutils/BUILD.bazel b/pkg/commands/commandutils/BUILD.bazel index 28cdd63ba5d6c..69d91cac2bf8a 100644 --- a/pkg/commands/commandutils/BUILD.bazel +++ b/pkg/commands/commandutils/BUILD.bazel @@ -4,6 +4,7 @@ go_library( name = "go_default_library", srcs = [ "cluster.go", + "editor.go", "error.go", "exit.go", "factory.go", diff --git a/cmd/kops/editor.go b/pkg/commands/commandutils/editor.go similarity index 88% rename from cmd/kops/editor.go rename to pkg/commands/commandutils/editor.go index e7972f6d63458..895bcacd5f0d6 100644 --- a/cmd/kops/editor.go +++ b/pkg/commands/commandutils/editor.go @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package commandutils -var editorEnvs = []string{"KUBE_EDITOR", "EDITOR"} +var EditorEnvs = []string{"KUBE_EDITOR", "EDITOR"}