From 9616cd07569ba13b7584faa613330ea139d72de4 Mon Sep 17 00:00:00 2001 From: Ruslan Aliev Date: Tue, 19 May 2020 00:46:59 -0500 Subject: [PATCH] Remove EnsureComplete config object validation from GetCurrentContext It's redundant and contradictory to call EnsureComplete method from GetCurrentContext function since this method is called twice during config load and we perform this check inside of appropriate action function (like phase apply or cluster init). Change-Id: Idb9ab7e7665dcc6d199bc96c21ae1dc6d059ac2e Signed-off-by: Ruslan Aliev --- pkg/config/config.go | 3 --- pkg/config/config_test.go | 15 --------------- 2 files changed, 18 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6ce0a7e6b..3f595a64f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -610,9 +610,6 @@ func (c *Config) ModifyContext(context *Context, theContext *ContextOptions) { // Manifest is the default manifest to be use with this context // Purpose for this method is simplifying the current context information func (c *Config) GetCurrentContext() (*Context, error) { - if err := c.EnsureComplete(); err != nil { - return nil, err - } currentContext, err := c.GetContext(c.CurrentContext) if err != nil { // this should not happen since Ensure Complete checks for this diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e58e9742b..4d6be2025 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -420,21 +420,6 @@ func TestGetCurrentContext(t *testing.T) { require.NoError(t, err) assert.Equal(t, conf.Contexts[currentContextName], context) }) - - t.Run("getCurrentContextIncomplete", func(t *testing.T) { - conf, cleanup := testutil.InitConfig(t) - defer cleanup(t) - - context, err := conf.GetCurrentContext() - require.Error(t, err) - assert.Nil(t, context) - - conf.CurrentContext = currentContextName - - context, err = conf.GetCurrentContext() - assert.Error(t, err) - assert.Nil(t, context) - }) } func TestCurrentContextCluster(t *testing.T) {