Merge "Add utility function to be get current context target-path"
This commit is contained in:
commit
93a4449696
@ -675,6 +675,15 @@ func (c *Config) CurrentContextEntryPoint(phase string) (string, error) {
|
||||
phase), nil
|
||||
}
|
||||
|
||||
// CurrentContextTargetPath returns target path from current context's manifest
|
||||
func (c *Config) CurrentContextTargetPath() (string, error) {
|
||||
ccm, err := c.CurrentContextManifest()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return ccm.TargetPath, nil
|
||||
}
|
||||
|
||||
func (c *Config) CurrentContextClusterType() (string, error) {
|
||||
context, err := c.GetCurrentContext()
|
||||
if err != nil {
|
||||
|
@ -486,6 +486,25 @@ func TestCurrentContextManifest(t *testing.T) {
|
||||
assert.Equal(t, conf.Manifests[defaultString], manifest)
|
||||
}
|
||||
|
||||
func TestCurrentTargetPath(t *testing.T) {
|
||||
conf, cleanup := testutil.InitConfig(t)
|
||||
defer cleanup(t)
|
||||
|
||||
clusterName := "def"
|
||||
|
||||
manifest, err := conf.CurrentContextManifest()
|
||||
require.Error(t, err)
|
||||
assert.Nil(t, manifest)
|
||||
|
||||
conf.CurrentContext = currentContextName
|
||||
conf.Contexts[currentContextName].Manifest = defaultString
|
||||
conf.Contexts[currentContextName].KubeContext().Cluster = clusterName
|
||||
|
||||
targetPath, err := conf.CurrentContextTargetPath()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, conf.Manifests[defaultString].TargetPath, targetPath)
|
||||
}
|
||||
|
||||
func TestCurrentContextEntryPoint(t *testing.T) {
|
||||
conf, cleanup := testutil.InitConfig(t)
|
||||
defer cleanup(t)
|
||||
|
Loading…
x
Reference in New Issue
Block a user