forked from grafana/tanka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: render kustomize into jsonnet (grafana#422)
* feat: render kustomize into jsonnet * refactor: move ListAsMap * docs: add TANKA_KUSTOMIZE_PATH to env-vars
- Loading branch information
Showing
10 changed files
with
307 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package kustomize | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"os" | ||
|
||
"github.com/grafana/tanka/pkg/kubernetes/manifest" | ||
"github.com/pkg/errors" | ||
yaml "gopkg.in/yaml.v3" | ||
) | ||
|
||
// Build expands a Kustomize into a regular manifest.List using the `kustomize | ||
// build` command | ||
func (k ExecKustomize) Build(path string) (manifest.List, error) { | ||
cmd := k.cmd("build", path) | ||
var buf bytes.Buffer | ||
cmd.Stdout = &buf | ||
cmd.Stderr = os.Stderr | ||
|
||
if err := cmd.Run(); err != nil { | ||
return nil, errors.Wrap(err, "Expanding Kustomize") | ||
} | ||
|
||
var list manifest.List | ||
d := yaml.NewDecoder(&buf) | ||
for { | ||
var m manifest.Manifest | ||
if err := d.Decode(&m); err != nil { | ||
if err == io.EOF { | ||
break | ||
} | ||
return nil, errors.Wrap(err, "Parsing Kustomize output") | ||
} | ||
|
||
list = append(list, m) | ||
} | ||
|
||
return list, nil | ||
} |
Oops, something went wrong.