Skip to content

Commit

Permalink
mv base dir from setup to bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Sep 4, 2024
1 parent b30e498 commit ca0b5ad
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions pkg/up/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (ctx *Context) Generate() (dir string, err error) {
return
}

if err = git.PathClone("https://github.com/pluralsh/bootstrap.git", "more-up-improvements", dir); err != nil {
if err = git.PathClone("https://github.com/pluralsh/bootstrap.git", "resources-refactor", dir); err != nil {
return
}

Expand Down Expand Up @@ -69,8 +69,9 @@ func (ctx *Context) Generate() (dir string, err error) {
copies := []templatePair{
{from: ctx.path("terraform/modules/clusters"), to: "terraform/modules/clusters"},
{from: ctx.path(fmt.Sprintf("terraform/clouds/%s", prov)), to: "terraform/mgmt/cluster"},
{from: ctx.path("setup"), to: "setup"},
{from: ctx.path("setup"), to: "bootstrap"},
{from: ctx.path("templates"), to: "templates"},
{from: ctx.path("resources"), to: "resources"},
}

for _, copy := range copies {
Expand All @@ -84,19 +85,38 @@ func (ctx *Context) Generate() (dir string, err error) {
}

if ctx.Cloud {
toRemove := []string{"setup/console.yaml", "setup/flux.yaml"}
toRemove := []string{"bootstrap/console.yaml", "bootstrap/flux.yaml"}
for _, f := range toRemove {
os.Remove(f)
}
}

ctx.changeDelims()
overwrites := []templatePair{
{from: "setup/setup.yaml", to: "setup/setup.yaml"},
{from: "setup/pr-automation/cluster-creator.yaml", to: "setup/pr-automation/cluster-creator.yaml"},
{from: "bootstrap/setup.yaml", to: "setup/setup.yaml"},
{from: "bootstrap/pr-automation", to: "bootstrap/pr-automation"},
}

for _, tpl := range overwrites {
if utils.IsDir(tpl.from) {
files, err := utils.ListDirectory(tpl.from)
if err != nil {
return dir, err
}

for _, file := range files {
destFile, err := filepath.Rel(tpl.from, file)
if err != nil {
return dir, err
}

destFile = filepath.Join(string(tpl.to), destFile)
if err = ctx.templateFrom(file, destFile); err != nil {
return dir, err
}
}
}

if err = ctx.templateFrom(tpl.from, tpl.to); err != nil {
return
}
Expand Down

0 comments on commit ca0b5ad

Please sign in to comment.