-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from markfuller/helm
Helm action with example
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
"github.com/lyraproj/servicesdk/lang/go/lyra" | ||
) | ||
|
||
type helmIn struct { | ||
Name string | ||
Chart string | ||
Overrides []string | ||
Namespace *string | ||
} | ||
|
||
type helmOut struct { | ||
Output string | ||
} | ||
|
||
func helmInstall(in helmIn) helmOut { | ||
log := hclog.Default() | ||
namespace := "default" | ||
if in.Namespace != nil { | ||
namespace = *in.Namespace | ||
} | ||
args := []string{ | ||
"upgrade", | ||
"--install", | ||
in.Name, | ||
in.Chart, | ||
"--namespace", | ||
namespace, | ||
} | ||
if len(in.Overrides) > 0 { | ||
args = append(args, "--set") | ||
x := strings.Join(in.Overrides, ",") | ||
args = append(args, x) | ||
} | ||
cmd := exec.Command("helm", args...) | ||
|
||
log.Debug("about to run command", "cmd", cmd) | ||
|
||
out, err := cmd.CombinedOutput() | ||
output := fmt.Sprintf("%s", out) | ||
if err != nil { | ||
panic(fmt.Errorf("error running helm cmd %v \n error is %v \n output is %v", cmd, err, output)) | ||
} | ||
|
||
return helmOut{Output: output} | ||
} | ||
|
||
func main() { | ||
lyra.Serve(`helm_go`, nil, &lyra.Action{Do: helmInstall}) | ||
} |
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,11 @@ | ||
returns: [helm_output] | ||
steps: | ||
helm: | ||
parameters: | ||
name: {value: "wordpress"} | ||
chart: {value: "stable/wordpress"} | ||
namespace: {value: null} | ||
overrides: {value: ["wordpressUsername=somebody", "wordpressPassword=Anything", "wordpressBlogName=The Blog", "externalDatabase.Host=myserver"]} | ||
returns: | ||
helm_output: output | ||
call: helm_go |
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,4 @@ | ||
executable: go | ||
arguments: | ||
- run | ||
- 'examples/go-samples/helm_go/helm_go.go' |