Skip to content
13 changes: 13 additions & 0 deletions firestartr-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ pushFiles:
terraform:
push: true # When the process finishes, the generated crs will be pushed to the crs repository.
repo: "state-infra" # Normally, the state-infra repository will be called "state-infra", but it is possible to change the name.
secrets:
push: true # When the process finishes, the generated crs will be pushed to the crs repository.
repo: "state-secrets" # Normally, the state-secrets repository will be called "state-secrets", but it is possible to change the name.
dotFirestartr:
push: true # When the process finishes, the generated crs will be pushed to the crs repository.
repo: ".firestartr" # Normally, the .firestartr repository will be called ".firestartr", but it is possible to change the name.

components:
- name: "dot-firestartr" # claim name
Expand Down Expand Up @@ -130,6 +136,13 @@ components:
version: latest # Check available versions at github.com/prefapp/features
labels:
- plan

- name: "state-secrets"
description: "Firestartr Secrets wet repository"
defaultBranch: main
features:
- name: state_secrets
version: latest # Check available versions at github.com/prefapp/features
```

All the parameters must be filled. When copy pasting this file, `<placeholders>` must be replaced, but any other values can be treated as defaults and changed if needed:
Expand Down
13 changes: 13 additions & 0 deletions firestartr-bootstrap/boot/BootstrapFile.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pushFiles:
terraform:
push: true # When the process finishes, the generated crs will be pushed to the crs repository.
repo: "state-infra" # Normally, the state-infra repository will be called "state-infra", but it is possible to change the name.
secrets:
push: true # When the process finishes, the generated crs will be pushed to the crs repository.
repo: "state-secrets" # Normally, the state-secrets repository will be called "state-secrets", but it is possible to change the name.
dotFirestartr:
push: true # When the process finishes, the generated crs will be pushed to the crs repository.
repo: ".firestartr" # Normally, the .firestartr repository will be called ".firestartr", but it is possible to change the name.

components:
- name: "dot-firestartr" # claim name
Expand Down Expand Up @@ -66,3 +72,10 @@ components:
version: latest # Check available versions at github.com/prefapp/features
labels:
- plan

- name: "state-secrets"
description: "Firestartr Secrets wet repository"
defaultBranch: main
features:
- name: state_secrets
version: latest # Check available versions at github.com/prefapp/features
31 changes: 30 additions & 1 deletion firestartr-bootstrap/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"dagger/firestartr-bootstrap/internal/dagger"
"fmt"
"strings"
)

func (m *FirestartrBootstrap) PushBootstrapFiles(
Expand Down Expand Up @@ -75,12 +76,40 @@ func (m *FirestartrBootstrap) PushBootstrapFiles(
if m.Bootstrap.PushFiles.Crs.Providers.Terraform.Push {
crsDir := kindContainer.Directory("/resources/firestartr-crs/infra")

// Exclude non terraform CRs
terraformDir := crsDir.Filter(dagger.DirectoryFilterOpts{
Include: []string{"FirestartrTerraformWorkspace.*"},
})

err := m.PushDirToRepo(
ctx,
crsDir,
terraformDir,
m.Bootstrap.PushFiles.Crs.Providers.Terraform.Repo,
tokenSecret,
)
if err != nil {
if strings.Contains(err.Error(), "nothing to commit") {
fmt.Println("No terraform CRs to push, skipping...")
} else {
return err
}
}
}

if m.Bootstrap.PushFiles.Crs.Providers.Secrets.Push {
crsDir := kindContainer.Directory("/resources/firestartr-crs/infra")

// Exclude non secret CRs
secretsDir := crsDir.Filter(dagger.DirectoryFilterOpts{
Include: []string{"ExternalSecret.*"},
})

err := m.PushDirToRepo(
ctx,
secretsDir,
m.Bootstrap.PushFiles.Crs.Providers.Secrets.Repo,
tokenSecret,
Comment thread
juanjosevazquezgil marked this conversation as resolved.
)
if err != nil {
Comment thread
juanjosevazquezgil marked this conversation as resolved.
return err
}
Expand Down
27 changes: 25 additions & 2 deletions firestartr-bootstrap/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,18 @@ func (m *FirestartrBootstrap) UpdateSummaryAndRunForImportResourcesStep(

createdInfraResources, err := kindContainer.Directory(
"/resources/firestartr-crs/infra",
).Entries(ctx)
).Glob(ctx, "FirestartrTerraformWorkspace.*")
if err != nil {
return "", fmt.Errorf("error creating the list of generated infra artifacts: %w", err)
}

createdSecretResources, err := kindContainer.Directory(
"/resources/firestartr-crs/infra",
).Glob(ctx, "ExternalSecret.*")
if err != nil {
return "", fmt.Errorf("error creating the list of generated secret artifacts: %w", err)
}

successMessage := fmt.Sprintf(`
=====================================================
📥 RESOURCES IMPORTED AND CREATED 📥
Expand All @@ -91,13 +98,17 @@ The environment is fully provisioned.
#### Generated and created resources (Infra):
- %s

#### Generated and created resources (Secrets):
- %s

#### Copied to the cache:
- /import
- /resources
`,
strings.Join(importedFiles, "\n- "),
strings.Join(createdGhResources, "\n- "),
strings.Join(createdInfraResources, "\n- "),
strings.Join(createdSecretResources, "\n- "),
)

return m.UpdateSummaryAndRun(ctx, successMessage), nil
Expand Down Expand Up @@ -130,11 +141,18 @@ func (m *FirestartrBootstrap) UpdateSummaryAndRunForPushResourcesStep(

pushedInfraCrs, err := kindContainer.Directory(
"/resources/firestartr-crs/infra",
).Entries(ctx)
).Glob(ctx, "FirestartrTerraformWorkspace.*")
if err != nil {
return "", fmt.Errorf("error creating the list of pushed infra CRs: %w", err)
}

pushedSecretCrs, err := kindContainer.Directory(
"/resources/firestartr-crs/infra",
).Glob(ctx, "ExternalSecret.*")
if err != nil {
return "", fmt.Errorf("error creating the list of pushed secret CRs: %w", err)
}

successMessage := fmt.Sprintf(`
=====================================================
⤴️RESOURCE PUSH COMPLETE ⤴️
Expand All @@ -151,13 +169,18 @@ func (m *FirestartrBootstrap) UpdateSummaryAndRunForPushResourcesStep(

#### List of pushed CRs (%s/state-infra)
- %s

#### List of pushed CRs (%s/state-secrets)
- %s
`,
m.Bootstrap.Org,
strings.Join(pushedClaims, "\n- "),
m.Bootstrap.Org,
strings.Join(pushedGithubCrs, "\n- "),
m.Bootstrap.Org,
strings.Join(pushedInfraCrs, "\n- "),
m.Bootstrap.Org,
strings.Join(pushedSecretCrs, "\n- "),
)
return m.UpdateSummaryAndRun(ctx, successMessage), nil

Expand Down
1 change: 1 addition & 0 deletions firestartr-bootstrap/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type PushFilesRepo struct {
type Providers struct {
Github PushFilesRepo `yaml:"github"`
Terraform PushFilesRepo `yaml:"terraform"`
Secrets PushFilesRepo `yaml:"secrets"`
}

type Firestartr struct {
Expand Down
Loading