From 4509a351fd63aaca800d675094a572c61136bb20 Mon Sep 17 00:00:00 2001
From: Alex Clemmer <clemmer.alexander@gmail.com>
Date: Wed, 20 Sep 2017 21:57:33 -0700
Subject: [PATCH] Fix improper elision of -J flags

Currently if we use a command like `apply default -f
components/whatever.yaml`, kubecfg will fail to emit flags that add
ksonnet-lib to the -J paths. This means that, while a command like
`apply default` will correctly linke against (e.g.) `k.libsonnet`,
adding the `-f` flag will not.

This commit will correct this problem for all commands of this form.
---
 cmd/root.go | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/cmd/root.go b/cmd/root.go
index 775c4795..6c6f167d 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -357,7 +357,7 @@ func expandEnvCmdObjs(cmd *cobra.Command, envSpec *envSpec, cwd metadata.AbsPath
 	}
 
 	fileNames := envSpec.files
-	if envPresent && !filesPresent {
+	if envPresent {
 		manager, err := metadata.Find(cwd)
 		if err != nil {
 			return nil, err
@@ -366,10 +366,13 @@ func expandEnvCmdObjs(cmd *cobra.Command, envSpec *envSpec, cwd metadata.AbsPath
 		libPath, envLibPath := manager.LibPaths(*envSpec.env)
 		expander.FlagJpath = append([]string{string(libPath), string(envLibPath)}, expander.FlagJpath...)
 
-		fileNames, err = manager.ComponentPaths()
-		if err != nil {
-			return nil, err
+		if !filesPresent {
+			fileNames, err = manager.ComponentPaths()
+			if err != nil {
+				return nil, err
+			}
 		}
+
 	}
 
 	//
-- 
GitLab