Skip to content
Open
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
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