Skip to content
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
39b7b16
Add app command structure and error handling for Giant Swarm applicat…
teemow Mar 26, 2025
ddab70a
Merge branch 'main' into teemow-add-app-bootstrap-cmd
pipo02mix Mar 27, 2025
f843c01
Refactor app bootstrap process: streamline repository creation, place…
teemow Mar 27, 2025
f7c9d9a
Add workflow and Makefile generation, and create PR for giantswarm/gi…
teemow Mar 27, 2025
44ac693
Enhance GitHub repository PR creation: return PR URL and update succe…
teemow Mar 27, 2025
cbbd6a5
Merge branch 'teemow-add-app-bootstrap-cmd' of github.com:giantswarm/…
teemow Mar 27, 2025
9551787
Merge branch 'main' into teemow-add-app-bootstrap-cmd
teemow Mar 28, 2025
0e18828
Update README and enhance placeholder replacement in bootstrap process
teemow Mar 28, 2025
c107657
removed logs
teemow Mar 28, 2025
e649b94
Merge branch 'teemow-add-app-bootstrap-cmd' of github.com:giantswarm/…
teemow Mar 28, 2025
e1a833b
remove project info
teemow Mar 28, 2025
07acd0d
Refactor bootstrap flag handling and improve error checking; update d…
teemow Mar 28, 2025
ccdb4b0
Refactor debug logging checks and update GitHub client repository own…
teemow Mar 28, 2025
aa7d299
Merge branch 'main' into teemow-add-app-bootstrap-cmd
pipo02mix Apr 3, 2025
dba0078
Adapt to mac
pipo02mix Apr 3, 2025
7afda9c
Merge branch 'teemow-add-app-bootstrap-cmd' of github.com:giantswarm/…
pipo02mix Apr 4, 2025
02e98ee
Make it Mac compatible
pipo02mix Apr 7, 2025
bc2062d
Merge branch 'main' into make-it-mac-compatible
pipo02mix Apr 7, 2025
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
37 changes: 23 additions & 14 deletions cmd/app/bootstrap/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"time"

"github.com/briandowns/spinner"
Expand Down Expand Up @@ -314,6 +315,8 @@ directories:
return microerror.Mask(err)
}

fmt.Printf("Repo path %s \n vendir.yml file created \n", repoPath)

// Run initial sync
err = r.execCommand(ctx, repoPath, "vendir", "sync")
if err != nil {
Expand Down Expand Up @@ -422,40 +425,46 @@ func (r *runner) replacePlaceholders(ctx context.Context, repoPath string) error
return microerror.Mask(err)
}

// Determine the correct sed -i flag based on the OS
var sedInPlaceFlag string
if runtime.GOOS == "darwin" {
sedInPlaceFlag = "sed -i ''" // macOS requires an empty string after -i
} else {
sedInPlaceFlag = "sed -i" // Linux does not require an empty string
}

replaceString := fmt.Sprintf("\"s|github.com/giantswarm/{APP-NAME}|github.com/giantswarm/%s-app|g\"", r.flag.Name)
// First replace GitHub URLs that need the -app suffix
err = r.execCommand(ctx, repoPath,
"find", ".", "-type", "f",
"-not", "-path", "./.git/*",
"-exec", "sed", "-i",
fmt.Sprintf("s|github.com/giantswarm/{APP-NAME}|github.com/giantswarm/%s-app|g", r.flag.Name),
"{}", "+")
"find", ".", "-path", "\"./.git\"", "-prune",
Comment thread
pipo02mix marked this conversation as resolved.
"-o", "-type", "f", "-exec", sedInPlaceFlag,
replaceString, "{}", "+")
if err != nil {
return microerror.Mask(err)
}

// Then replace CircleCI URLs that need the -app suffix
err = r.execCommand(ctx, repoPath,
"find", ".", "-type", "f",
"-not", "-path", "./.git/*",
"-exec", "sed", "-i",
fmt.Sprintf("s|gh/giantswarm/{APP-NAME}/|gh/giantswarm/%s-app/|g", r.flag.Name),
"find", ".", "-path", "'./.git'", "-prune",
"-o", "-type", "f", "-exec", sedInPlaceFlag,
fmt.Sprintf("\"s|gh/giantswarm/{APP-NAME}/|gh/giantswarm/%s-app/|g\"", r.flag.Name),
Comment thread
pipo02mix marked this conversation as resolved.
"{}", "+")
if err != nil {
return microerror.Mask(err)
}

// Then do the general replacement for all other cases
err = r.execCommand(ctx, repoPath,
"find", ".", "-type", "f",
"-not", "-path", "./.git/*",
"-exec", "sed", "-i", fmt.Sprintf("s/{APP-NAME}/%s/g", r.flag.Name), "{}", "+")
"find", ".", "-path", "'./.git'", "-prune",
"-o", "-type", "f", "-exec", sedInPlaceFlag,
fmt.Sprintf("\"s/{APP-NAME}/%s/g\"", r.flag.Name), "{}", "+")
if err != nil {
return microerror.Mask(err)
}

// Replace team in CODEOWNERS
err = r.execCommand(ctx, repoPath,
"sed", "-i",
sedInPlaceFlag,
fmt.Sprintf("s/@giantswarm\\/team-honeybadger/@giantswarm\\/team-%s/g", r.flag.Team),
"CODEOWNERS")
if err != nil {
Expand All @@ -464,7 +473,7 @@ func (r *runner) replacePlaceholders(ctx context.Context, repoPath string) error

// Add team label
err = r.execCommand(ctx, repoPath,
"sed", "-i",
sedInPlaceFlag,
fmt.Sprintf(`s/app.kubernetes.io\/name: %s/app.kubernetes.io\/name: %s\n application.giantswarm.io\/team: %s/`,
r.flag.Name, r.flag.Name, r.flag.Team),
fmt.Sprintf("helm/%s/templates/_helpers.tpl", r.flag.Name))
Expand Down