Skip to content

Commit

Permalink
refactor(cli): refactors deployment commands to use KCL instead of Ti…
Browse files Browse the repository at this point in the history
…moni (#116)
  • Loading branch information
jmgilman authored Jan 17, 2025
1 parent aa2f9e4 commit 924e6bb
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 545 deletions.
2 changes: 1 addition & 1 deletion blueprint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ global: {
]
}
deployment: {
registry: ci.providers.aws.ecr.registry
registry: ci.providers.aws.ecr.registry + "/catalyst-deployments"
repo: {
url: "https://github.com/input-output-hk/catalyst-world"
ref: "master"
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/cmds/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

type PushCmd struct {
Force bool `help:"Force deployment even if no deployment event is firing."`
Project string `arg:"" help:"The path to the project to deploy." kong:"arg,predictor=path"`
}

Expand All @@ -19,7 +20,7 @@ func (c *PushCmd) Run(ctx run.RunContext) error {
}

eh := events.NewDefaultEventHandler(ctx.Logger)
if !eh.Firing(&project, project.GetDeploymentEvents()) {
if !eh.Firing(&project, project.GetDeploymentEvents()) && !c.Force {
ctx.Logger.Info("No deployment event is firing, skipping deployment")
return nil
}
Expand Down
27 changes: 18 additions & 9 deletions cli/cmd/cmds/deploy/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package deploy

import (
"fmt"
"strings"

"github.com/input-output-hk/catalyst-forge/cli/pkg/deployment"
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
)

type TemplateCmd struct {
Project string `arg:"" help:"The path to the project." kong:"arg,predictor=path"`
Values bool `help:"Only print the values.yml for the main module"`
}

func (c *TemplateCmd) Run(ctx run.RunContext) error {
Expand All @@ -17,22 +19,29 @@ func (c *TemplateCmd) Run(ctx run.RunContext) error {
return fmt.Errorf("could not load project: %w", err)
}

bundle, err := deployment.GenerateBundle(&project)
if err != nil {
return fmt.Errorf("could not generate bundle: %w", err)
runner := deployment.NewKCLRunner(ctx.Logger)

if c.Values {
values, err := runner.GetMainValues(&project)
if err != nil {
return fmt.Errorf("could not get values: %w", err)
}

fmt.Print(values)
return nil
}

templater, err := deployment.NewDefaultBundleTemplater(ctx.Logger)
result, err := runner.RunDeployment(&project)
if err != nil {
return fmt.Errorf("could not create bundle templater: %w", err)
return fmt.Errorf("could not run deployment: %w", err)
}

out, err := templater.Render(bundle)
if err != nil {
return fmt.Errorf("could not render bundle: %w", err)
var out string
for _, module := range result {
out += fmt.Sprintf("%s---\n", module.Manifests)
}

fmt.Println(out)
fmt.Print(strings.TrimSuffix(out, "---\n"))

return nil
}
111 changes: 0 additions & 111 deletions cli/pkg/deployment/bundle.go

This file was deleted.

184 changes: 0 additions & 184 deletions cli/pkg/deployment/bundle_test.go

This file was deleted.

Loading

0 comments on commit 924e6bb

Please sign in to comment.