Skip to content

Commit

Permalink
Merge pull request #286 from markfuller/helm
Browse files Browse the repository at this point in the history
Helm action with example
  • Loading branch information
thallgren authored May 20, 2019
2 parents daf2c34 + 077b612 commit 683e678
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
57 changes: 57 additions & 0 deletions examples/go-samples/helm_go/helm_go.go
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})
}
11 changes: 11 additions & 0 deletions workflows/helm.yaml
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
4 changes: 4 additions & 0 deletions workflows/helm_go.ll
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'

0 comments on commit 683e678

Please sign in to comment.