Skip to content

Commit

Permalink
feat: support release rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
riven-blade committed Jan 3, 2025
1 parent d3115e3 commit 734d77e
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/apis/api.kusion.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ const (
// ReleasePhaseApplying indicates the stage of applying.
ReleasePhaseApplying ReleasePhase = "applying"

// ReleasePhaseRollbacking indicates the stage of rollbacking.
ReleasePhaseRollbacking ReleasePhase = "rollbacking"

// ReleasePhaseDestroying indicates the stage of destroying.
ReleasePhaseDestroying ReleasePhase = "destroying"

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Find more information at: https://www.kusionstack.io`),
{
Message: "Release Management Commands:",
Commands: []*cobra.Command{
rel.NewCmdRel(o.IOStreams),
rel.NewCmdRel(o.UI, o.IOStreams),
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"k8s.io/kubectl/pkg/util/templates"
cmdutil "kusionstack.io/kusion/pkg/cmd/util"
"kusionstack.io/kusion/pkg/util/i18n"
"kusionstack.io/kusion/pkg/util/terminal"
)

var relLong = i18n.T(`
Expand All @@ -14,7 +15,7 @@ var relLong = i18n.T(`
These commands help you observe and operate the Kusion release files of a Project in a Workspace. `)

// NewCmdRel returns an initialized Command instance for 'release' sub command.
func NewCmdRel(streams genericiooptions.IOStreams) *cobra.Command {
func NewCmdRel(ui *terminal.UI, streams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "release",
DisableFlagsInUseLine: true,
Expand All @@ -23,7 +24,7 @@ func NewCmdRel(streams genericiooptions.IOStreams) *cobra.Command {
Run: cmdutil.DefaultSubCommandRun(streams.ErrOut),
}

cmd.AddCommand(NewCmdUnlock(streams), NewCmdList(streams), NewCmdShow(streams))
cmd.AddCommand(NewCmdUnlock(streams), NewCmdList(streams), NewCmdShow(streams), NewCmdRollback(ui, streams))

return cmd
}
2 changes: 1 addition & 1 deletion pkg/cmd/release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestNewCmdRel(t *testing.T) {
t.Run("successfully get release help", func(t *testing.T) {
streams, _, _, _ := genericiooptions.NewTestIOStreams()

cmd := NewCmdRel(streams)
cmd := NewCmdRel(nil, streams)
assert.NotNil(t, cmd)
})
}
Loading

0 comments on commit 734d77e

Please sign in to comment.