Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(actions,glide,helm): download canonical generate_params.toml #111

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions actions/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"log"
"os"
"path/filepath"
"text/template"

"github.com/deis/deisrel/git"
)
Expand Down Expand Up @@ -36,12 +35,6 @@ const (
generateParamsFileName = "generate_params.toml"
)

type helmChart struct {
Name string
Template *template.Template
Files []string
}

type releaseName struct {
Full string
Short string
Expand All @@ -66,40 +59,6 @@ var (
Short: os.Getenv("WORKFLOW_RELEASE_SHORT"),
}
defaultStagingPath = getFullPath("staging")

// RouterChart represents the router chart and its files needing updating
// for a release
RouterChart = helmChart{
Name: "router-dev",
Template: generateParamsRouterTpl,
Files: []string{
"README.md",
"Chart.yaml",
},
}

// WorkflowChart represents the workflow chart and its files needing updating
// for a release
WorkflowChart = helmChart{
Name: "workflow-dev",
Template: generateParamsTpl,
Files: []string{
"README.md",
"Chart.yaml",
},
}

// WorkflowE2EChart represents the workflow e2e chart and its files needing updating
// for a release
WorkflowE2EChart = helmChart{
Name: "workflow-dev-e2e",
Template: generateParamsE2ETpl,
Files: []string{
"README.md",
"Chart.yaml",
filepath.Join("tpl", "generate_params.toml"),
},
}
)

func getFullPath(dirName string) string {
Expand Down
138 changes: 0 additions & 138 deletions actions/generate_params.go

This file was deleted.

18 changes: 0 additions & 18 deletions actions/generate_params_e2e.go

This file was deleted.

19 changes: 0 additions & 19 deletions actions/generate_params_router.go

This file was deleted.

17 changes: 11 additions & 6 deletions actions/helm_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"log"
"os"
"path/filepath"
"text/template"

"github.com/arschles/sys"
"github.com/deis/deisrel/git"
"github.com/deis/deisrel/helm"
"github.com/google/go-github/github"
)

Expand All @@ -26,25 +26,30 @@ func NopWriteCloser(w io.Writer) io.WriteCloser {
return nopWriteCloser{w}
}

func generateParams(fs sys.FS, whereTo string, paramsComponentMap genParamsComponentMap, helmChart helmChart) error {
func generateParams(fs sys.FS, whereTo string, paramsComponentMap helm.GenParamsComponentMap, helmChart helm.Chart) error {
executeTo, err := executeToStaging(fs, filepath.Join(whereTo, "tpl"))
if err != nil {
log.Fatalf("Error creating staging file (%s)", err)
}
defer executeTo.Close()

return helmChart.Template.Execute(executeTo, paramsComponentMap)
return helmChart.RenderGenerateParamsTpl(executeTo, paramsComponentMap)
}

func executeToStaging(fs sys.FS, stagingSubDir string) (io.WriteCloser, error) {
fs.MkdirAll(stagingSubDir, os.ModePerm)
return fs.Create(filepath.Join(stagingSubDir, generateParamsFileName))
}

func getParamsComponentMap(ghClient *github.Client, defaultParamsComponentAttrs genParamsComponentAttrs, template *template.Template, ref string) genParamsComponentMap {
paramsComponentMap := createParamsComponentMap()
func getParamsComponentMap(
ghClient *github.Client,
defaultParamsComponentAttrs helm.GenParamsComponentAttrs,
chart helm.Chart,
ref string,
) helm.GenParamsComponentMap {
paramsComponentMap := helm.CreateGenParamsComponentMap()

if template == generateParamsE2ETpl {
if chart.Name == "workflow-dev-e2e" {
repoNames = []string{"workflow-e2e"}
componentNames = []string{"WorkflowE2E"}
}
Expand Down
14 changes: 10 additions & 4 deletions actions/helm_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/arschles/sys"
"github.com/codegangsta/cli"
"github.com/deis/deisrel/git"
"github.com/deis/deisrel/helm"
"github.com/google/go-github/github"
)

Expand All @@ -17,7 +18,7 @@ var (
ourFP = sys.RealFP()
)

func helmStage(ghClient *github.Client, c *cli.Context, helmChart helmChart) {
func helmStage(ghClient *github.Client, c *cli.Context, helmChart helm.Chart) {
var opt github.RepositoryContentGetOptions
opt.Ref = c.GlobalString(RefFlag)
org := c.GlobalString(GHOrgFlag)
Expand All @@ -33,12 +34,17 @@ func helmStage(ghClient *github.Client, c *cli.Context, helmChart helmChart) {
}

// stage 'tpl/generate_params.toml' with latest git shas for each component
defaultParamsComponentAttrs := genParamsComponentAttrs{
defaultParamsComponentAttrs := helm.GenParamsComponentAttrs{
Org: c.GlobalString(OrgFlag),
PullPolicy: c.GlobalString(PullPolicyFlag),
Tag: c.GlobalString(TagFlag),
}
paramsComponentMap := getParamsComponentMap(ghClient, defaultParamsComponentAttrs, helmChart.Template, c.GlobalString(RefFlag))
paramsComponentMap := getParamsComponentMap(
ghClient,
defaultParamsComponentAttrs,
helmChart,
c.GlobalString(RefFlag),
)
generateParams(ourFS, stagingDir, paramsComponentMap, helmChart)

// gather helmChart.Files from GitHub needing release string updates
Expand Down Expand Up @@ -70,7 +76,7 @@ func downloadFiles(
org,
repo string,
opt *github.RepositoryContentGetOptions,
helmChart helmChart) ([]git.File, error) {
helmChart helm.Chart) ([]git.File, error) {

ret := make([]git.File, 0, len(helmChart.Files))
for _, fileName := range helmChart.Files {
Expand Down
7 changes: 6 additions & 1 deletion actions/helm_stage_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ package actions

import (
"github.com/codegangsta/cli"
"github.com/deis/deisrel/helm"
"github.com/google/go-github/github"
)

// HelmStageE2E is the cli handler for generating a release helm chart for deis-e2e
func HelmStageE2E(ghClient *github.Client) func(*cli.Context) error {
return func(c *cli.Context) error {
helmStage(ghClient, c, WorkflowE2EChart)
e2eChart, err := helm.GetWorkflowE2EChart(ghClient)
if err != nil {
return err
}
helmStage(ghClient, c, *e2eChart)
return nil
}
}
7 changes: 6 additions & 1 deletion actions/helm_stage_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ package actions

import (
"github.com/codegangsta/cli"
"github.com/deis/deisrel/helm"
"github.com/google/go-github/github"
)

// HelmStageRouter is the cli handler for generating a release helm chart for router
func HelmStageRouter(ghClient *github.Client) func(*cli.Context) error {
return func(c *cli.Context) error {
helmStage(ghClient, c, RouterChart)
routerChart, err := helm.GetRouterChart(ghClient)
if err != nil {
return err
}
helmStage(ghClient, c, *routerChart)
return nil
}
}
7 changes: 6 additions & 1 deletion actions/helm_stage_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ package actions

import (
"github.com/codegangsta/cli"
"github.com/deis/deisrel/helm"
"github.com/google/go-github/github"
)

// HelmStageWorkflow is the cli handler for generating a release helm chart for workflow
func HelmStageWorkflow(ghClient *github.Client) func(*cli.Context) error {
return func(c *cli.Context) error {
helmStage(ghClient, c, WorkflowChart)
workflowChart, err := helm.GetWorkflowChart(ghClient)
if err != nil {
return err
}
helmStage(ghClient, c, *workflowChart)
return nil
}
}
Loading