Skip to content

Commit

Permalink
Merge pull request #36 from apptio/unprune
Browse files Browse the repository at this point in the history
Unprune cluster parameters
  • Loading branch information
cspargo authored May 8, 2020
2 parents 05c33f2 + efb607c commit a393dcc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var paramsCmd = &cobra.Command{
log.Fatal("Please specify a --cluster name and/or --clusterparams")
}

j := renderClusterParams(cmd, clusterName, componentName, clusterParams)
j := renderClusterParams(cmd, clusterName, componentName, clusterParams, true)

if paramPath != "" {
value := gjson.Get(j, paramPath)
Expand Down
4 changes: 2 additions & 2 deletions cmd/directories.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func getClusterParams(basePath string, targetPath string) []string {

}

func renderClusterParams(cmd *cobra.Command, clusterName string, componentName string, clusterParams string) string {
func renderClusterParams(cmd *cobra.Command, clusterName string, componentName string, clusterParams string, prune bool) string {
if clusterName == "" && clusterParams == "" {
log.Fatal("Please specify a --cluster name and/or --clusterparams")
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func renderClusterParams(cmd *cobra.Command, clusterName string, componentName s
}
componentDefaultsMerged = componentDefaultsMerged + "}"

compParams = renderJsonnet(cmd, params, "", false, componentDefaultsMerged)
compParams = renderJsonnet(cmd, params, "", prune, componentDefaultsMerged)

return compParams
}
2 changes: 1 addition & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var getparamsCmd = &cobra.Command{

fmt.Println(componentName)

j := renderClusterParams(cmd, clusterName, componentName, clusterParams)
j := renderClusterParams(cmd, clusterName, componentName, clusterParams, true)

if paramPath != "" {
value := gjson.Get(j, paramPath)
Expand Down
5 changes: 2 additions & 3 deletions cmd/jsonnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,19 @@ var jsonnetrenderCmd = &cobra.Command{
log.Fatal("Please specify a --cluster name and/or --clusterparams")
}

config := renderClusterParams(cmd, clusterName, componentName, clusterParams)
config := renderClusterParams(cmd, clusterName, componentName, clusterParams, false)

// VM
vm, _ := JsonnetVM(cmd)

var input string
// pass component, _cluster and _components as extvars

vm.ExtCode("kr8_cluster", "std.prune("+config+"._cluster)")
vm.ExtCode("kr8_components", "std.prune("+config+"._components)")
vm.ExtCode("kr8", "std.prune("+config+"."+componentName+")")
vm.ExtCode("kr8_unpruned", config+"."+componentName)

log.Debug("Unpruned")

if pruneFlag {
input = "std.prune(import '" + args[0] + "')"
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var renderjsonnetCmd = &cobra.Command{
log.Fatal("Please specify a --cluster name and/or --clusterparams")
}

config := renderClusterParams(cmd, clusterName, componentName, clusterParams)
config := renderClusterParams(cmd, clusterName, componentName, clusterParams, false)

// VM
vm, _ := JsonnetVM(cmd)
Expand Down

0 comments on commit a393dcc

Please sign in to comment.