Skip to content

Commit 924e6bb

Browse files
authored
refactor(cli): refactors deployment commands to use KCL instead of Timoni (#116)
1 parent aa2f9e4 commit 924e6bb

File tree

15 files changed

+533
-545
lines changed

15 files changed

+533
-545
lines changed

blueprint.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ global: {
7070
]
7171
}
7272
deployment: {
73-
registry: ci.providers.aws.ecr.registry
73+
registry: ci.providers.aws.ecr.registry + "/catalyst-deployments"
7474
repo: {
7575
url: "https://github.com/input-output-hk/catalyst-world"
7676
ref: "master"

cli/cmd/cmds/deploy/deploy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
)
1010

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

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

2122
eh := events.NewDefaultEventHandler(ctx.Logger)
22-
if !eh.Firing(&project, project.GetDeploymentEvents()) {
23+
if !eh.Firing(&project, project.GetDeploymentEvents()) && !c.Force {
2324
ctx.Logger.Info("No deployment event is firing, skipping deployment")
2425
return nil
2526
}

cli/cmd/cmds/deploy/template.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package deploy
22

33
import (
44
"fmt"
5+
"strings"
56

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

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

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

20-
bundle, err := deployment.GenerateBundle(&project)
21-
if err != nil {
22-
return fmt.Errorf("could not generate bundle: %w", err)
22+
runner := deployment.NewKCLRunner(ctx.Logger)
23+
24+
if c.Values {
25+
values, err := runner.GetMainValues(&project)
26+
if err != nil {
27+
return fmt.Errorf("could not get values: %w", err)
28+
}
29+
30+
fmt.Print(values)
31+
return nil
2332
}
2433

25-
templater, err := deployment.NewDefaultBundleTemplater(ctx.Logger)
34+
result, err := runner.RunDeployment(&project)
2635
if err != nil {
27-
return fmt.Errorf("could not create bundle templater: %w", err)
36+
return fmt.Errorf("could not run deployment: %w", err)
2837
}
2938

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

35-
fmt.Println(out)
44+
fmt.Print(strings.TrimSuffix(out, "---\n"))
3645

3746
return nil
3847
}

cli/pkg/deployment/bundle.go

Lines changed: 0 additions & 111 deletions
This file was deleted.

cli/pkg/deployment/bundle_test.go

Lines changed: 0 additions & 184 deletions
This file was deleted.

0 commit comments

Comments
 (0)