Skip to content
Merged
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
3abddd4
add pager to describe config command
samtholiya Apr 14, 2025
2c3c2a2
add model test
samtholiya Apr 14, 2025
180bc51
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 14, 2025
0d70b34
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe…
samtholiya Apr 15, 2025
6cdf3a3
update structure
samtholiya Apr 15, 2025
223fe38
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya Apr 15, 2025
0e28d7d
update with unit test cases
samtholiya Apr 15, 2025
2b5d34d
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 15, 2025
1981bbe
remove unwanted interface
samtholiya Apr 15, 2025
c035f9f
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya Apr 15, 2025
474d45e
fix tests
samtholiya Apr 16, 2025
7de12fb
updated describe config
samtholiya Apr 16, 2025
44cbfa9
implement status with help
samtholiya Apr 20, 2025
7b9c10e
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 20, 2025
9b03310
error view added
samtholiya Apr 20, 2025
57c7cac
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya Apr 20, 2025
67a37cf
Update pkg/pager/model.go
samtholiya Apr 20, 2025
00f5920
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe…
samtholiya Apr 20, 2025
9639a6e
fix tests
samtholiya Apr 21, 2025
5c4c67c
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya Apr 21, 2025
94c247b
fix lint
samtholiya Apr 21, 2025
f7be563
fix golangci-lint
samtholiya Apr 21, 2025
af69dc6
updated pager variable
samtholiya Apr 21, 2025
b101302
fix tests
samtholiya Apr 21, 2025
a2ab7b3
fixed test cases
samtholiya Apr 21, 2025
4b01ade
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe…
samtholiya Apr 22, 2025
d20c96a
update the pager variable logic
samtholiya Apr 22, 2025
8a84f67
updated the pager logic
samtholiya Apr 22, 2025
dcccd4a
updated test case
samtholiya Apr 22, 2025
5ef05c5
fix pager bool
samtholiya Apr 23, 2025
b7e52cb
add pager for describe component
samtholiya Apr 23, 2025
efafca9
fix test case
samtholiya Apr 23, 2025
51b9a2d
fix test cases
samtholiya Apr 23, 2025
8990001
Update the docs
samtholiya Apr 23, 2025
2494cd1
add pager to describe config command
samtholiya Apr 14, 2025
0bd38c8
add model test
samtholiya Apr 14, 2025
eb55512
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 14, 2025
746b105
update structure
samtholiya Apr 15, 2025
bfa2e74
update with unit test cases
samtholiya Apr 15, 2025
b23ac9d
remove unwanted interface
samtholiya Apr 15, 2025
03fa985
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 15, 2025
a20d636
fix tests
samtholiya Apr 16, 2025
51bd717
updated describe config
samtholiya Apr 16, 2025
bb88f35
implement status with help
samtholiya Apr 20, 2025
b6752b9
error view added
samtholiya Apr 20, 2025
5119033
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 20, 2025
bc455d3
fix tests
samtholiya Apr 21, 2025
7ccc618
Update pkg/pager/model.go
samtholiya Apr 20, 2025
1fcf428
fix lint
samtholiya Apr 21, 2025
aa35f38
fix golangci-lint
samtholiya Apr 21, 2025
fda30bb
updated pager variable
samtholiya Apr 21, 2025
dfc53e7
fix tests
samtholiya Apr 21, 2025
dd1e6da
fixed test cases
samtholiya Apr 21, 2025
6b38f6b
update the pager variable logic
samtholiya Apr 22, 2025
151e8da
updated the pager logic
samtholiya Apr 22, 2025
29ff77a
updated test case
samtholiya Apr 22, 2025
e39721f
fix pager bool
samtholiya Apr 23, 2025
3fa3c1d
unit test case for isPagerEnabled
samtholiya Apr 24, 2025
da01289
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya Apr 24, 2025
1649fa7
fix error name
samtholiya Apr 24, 2025
c1de851
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe…
samtholiya Apr 24, 2025
f467d7e
fix tests
samtholiya Apr 24, 2025
0155079
checking error in runner
samtholiya Apr 25, 2025
6ccb69c
fix struct
samtholiya Apr 25, 2025
967c830
fix tests
samtholiya Apr 25, 2025
62cb279
add tests
samtholiya Apr 25, 2025
3780c8a
added tests
samtholiya Apr 27, 2025
48c5c45
added test for cmd
samtholiya Apr 27, 2025
0758f21
added tests for print as json
samtholiya Apr 27, 2025
97b3b0a
revert changes to limit the pr contents
samtholiya Apr 27, 2025
9233db8
shift common code
samtholiya Apr 27, 2025
988dabf
fix command
samtholiya Apr 27, 2025
99c38f1
fix test coverage scope
samtholiya Apr 27, 2025
91b348a
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe…
samtholiya Apr 27, 2025
2248e87
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya Apr 27, 2025
e401eef
add more test cases
samtholiya Apr 28, 2025
aecd470
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 28, 2025
c0598f2
add more test cases
samtholiya Apr 30, 2025
f4ec621
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe…
osterman May 2, 2025
8e46da4
Merge branch 'feature/dev-3131-add-pager-to-atmos-describe-config-com…
samtholiya May 2, 2025
66162fa
describe affected with pager
samtholiya May 4, 2025
8d24f5b
[autofix.ci] apply automated fixes
autofix-ci[bot] May 4, 2025
9bd46bb
fix complexity
samtholiya May 5, 2025
7985cac
Merge branch 'feature/dev-3182-add-pager-to-atmos-describe-affected-c…
samtholiya May 5, 2025
a116546
Merge remote-tracking branch 'origin/main' into feature/dev-3182-add-…
Benbentwo May 7, 2025
70c7fa1
updated scroll function
samtholiya May 8, 2025
af53eff
Merge branch 'feature/dev-3182-add-pager-to-atmos-describe-affected-c…
samtholiya May 8, 2025
2bd026a
just checking
samtholiya May 8, 2025
2891ec9
push highlighted utils golint fix
samtholiya May 8, 2025
d86ddfd
make it more unit testable
samtholiya May 8, 2025
d705761
Merge branch 'main' into feature/dev-3182-add-pager-to-atmos-describe…
samtholiya May 8, 2025
1a93a97
[autofix.ci] apply automated fixes
autofix-ci[bot] May 8, 2025
2d4337a
fix lint
samtholiya May 8, 2025
b90befd
Merge branch 'feature/dev-3182-add-pager-to-atmos-describe-affected-c…
samtholiya May 8, 2025
0baebcc
[autofix.ci] apply automated fixes
autofix-ci[bot] May 8, 2025
755c15c
Merge branch 'main' into feature/dev-3182-add-pager-to-atmos-describe…
samtholiya May 9, 2025
6d6f957
fix golint
samtholiya May 9, 2025
1040770
Merge branch 'feature/dev-3182-add-pager-to-atmos-describe-affected-c…
samtholiya May 9, 2025
ee7a7a8
[autofix.ci] apply automated fixes
autofix-ci[bot] May 9, 2025
72e4ffb
fix build issue
samtholiya May 10, 2025
95fd01b
remove unwanted function
samtholiya May 10, 2025
96b44b9
fix code rabbit
samtholiya May 10, 2025
2581c56
fix code rabbit
samtholiya May 10, 2025
5d0a802
fix flag
samtholiya May 10, 2025
7f24ea8
fix default format
samtholiya May 11, 2025
e35cd98
add test cases
samtholiya May 11, 2025
e5ba0f4
[autofix.ci] apply automated fixes
autofix-ci[bot] May 11, 2025
215f607
fix test
samtholiya May 13, 2025
0a35636
Merge branch 'main' into feature/dev-3162-add-pager-to-atmos-describe…
samtholiya May 14, 2025
3567c20
Merge branch 'main' into feature/dev-3162-add-pager-to-atmos-describe…
samtholiya May 15, 2025
c4d20d7
Merge branch 'feature/dev-3162-add-pager-to-atmos-describe-component-…
samtholiya May 15, 2025
c6d6873
Merge branch 'main' into feature/dev-3182-add-pager-to-atmos-describe…
samtholiya May 18, 2025
bef67e4
fix lint
samtholiya May 18, 2025
a0deb55
Merge branch 'feature/dev-3182-add-pager-to-atmos-describe-affected-c…
samtholiya May 18, 2025
083ecd6
fix
samtholiya May 18, 2025
eeb792e
test updated
samtholiya May 18, 2025
03dab23
fix test case
samtholiya May 18, 2025
4b7d587
add more test coverage
samtholiya May 18, 2025
1a812ef
init changes describe stacks for pager
samtholiya May 18, 2025
35d747d
fix comments
samtholiya May 22, 2025
cf82fcb
describe stacks with scroll
samtholiya May 22, 2025
18e8ca2
add test case
samtholiya May 22, 2025
fddcc7a
Merge branch 'main' into feature/dev-3182-add-pager-to-atmos-describe…
samtholiya May 23, 2025
22e6c3c
Merge branch 'feature/dev-3182-add-pager-to-atmos-describe-affected-c…
samtholiya May 23, 2025
ed22a1c
[autofix.ci] apply automated fixes
autofix-ci[bot] May 23, 2025
b7ae279
[autofix.ci] apply automated fixes
autofix-ci[bot] May 23, 2025
6ae85b8
Merge branch 'feature/dev-3221-add-pager-to-atmos-describe-stack-comm…
samtholiya May 23, 2025
71f4f1b
add tests
samtholiya May 23, 2025
4dd8fa6
add pager to describe workflow
samtholiya May 25, 2025
951164e
add tests
samtholiya May 25, 2025
3ae314c
add tests
samtholiya May 25, 2025
c41f5db
Merge branch 'main' of https://github.com/cloudposse/atmos into featu…
samtholiya Jun 7, 2025
fc3ca77
fix lint
samtholiya Jun 7, 2025
3b0d241
[autofix.ci] apply automated fixes
autofix-ci[bot] Jun 7, 2025
ed6da98
fix coderabbit
samtholiya Jun 7, 2025
cd3236e
Merge branch 'feature/dev-3251-add-pager-to-atmos-describe-workflow-c…
samtholiya Jun 7, 2025
e9eb6b0
fix pager flag
samtholiya Jun 11, 2025
7cf9f20
Update cmd/describe_affected.go
samtholiya Jun 11, 2025
1788041
fix test
samtholiya Jun 11, 2025
b1e801c
[autofix.ci] apply automated fixes
autofix-ci[bot] Jun 11, 2025
823c024
Merge branch 'main' into feature/dev-3251-add-pager-to-atmos-describe…
Benbentwo Jun 12, 2025
d09365f
Merge branch 'main' into feature/dev-3251-add-pager-to-atmos-describe…
samtholiya Jun 13, 2025
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
5 changes: 5 additions & 0 deletions cmd/describe_affected.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
checkAtmosConfig()
props, err := parseDescribeAffectedCliArgs(cmd, args)
checkErrorAndExit(err)
if cmd.Flags().Changed("pager") {

Check failure

Code scanning / golangci-lint

File is not properly formatted Error

File is not properly formatted
// TODO: update this post pr:https://github.com/cloudposse/atmos/pull/1174 is merged
props.CLIConfig.Settings.Terminal.Pager, err = cmd.Flags().GetString("pager")
checkErrorAndExit(err)
}
err = newDescribeAffectedExec(props.CLIConfig).Execute(&props)
checkErrorAndExit(err)
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/describe_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func getRunnableDescribeStacksCmd(
printErrorAndExit(err)
describe := &exec.DescribeStacksArgs{}
err = setCliArgsForDescribeStackCli(cmd.Flags(), describe)
printErrorAndExit(err)
if cmd.Flags().Changed("pager") {
// TODO: update this post pr:https://github.com/cloudposse/atmos/pull/1174 is merged
atmosConfig.Settings.Terminal.Pager, err = cmd.Flags().GetString("pager")
}

printErrorAndExit(err)
err = g.newDescribeStacksExec.Execute(&atmosConfig, describe)
printErrorAndExit(err)
Expand Down
36 changes: 0 additions & 36 deletions cmd/describe_stacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,4 @@ func TestSetFlagValueInDescribeStacksCliArgs(t *testing.T) {
assert.Equal(t, tt.expected, tt.describe, "Describe struct does not match expected")
})
}

// Test panic for unsupported type
t.Run("Unsupported flag type", func(t *testing.T) {
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
fs.Int("invalid", 0, "Invalid flag") // Int type is not supported
fs.Set("invalid", "42")

defer func() {
if r := recover(); r != nil {
expected := "unsupported type *int for flag invalid"
if fmt.Sprintf("%v", r) != expected {
t.Errorf("Expected panic message %q, got %v", expected, r)
}
} else {
t.Error("Expected panic but none occurred")
}
}()

// Override flagsKeyValue to include an int type
originalFlagsKeyValue := map[string]any{
"invalid": new(int),
}
for k, v := range originalFlagsKeyValue {
if !fs.Changed(k) {
continue
}
switch v := v.(type) {
case *string:
*v, _ = fs.GetString(k)
case *bool:
*v, _ = fs.GetBool(k)
default:
panic(fmt.Sprintf("unsupported type %T for flag %s", v, k))
}
}
})
}
89 changes: 81 additions & 8 deletions cmd/describe_workflows.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

e "github.com/cloudposse/atmos/internal/exec"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/cloudposse/atmos/internal/exec"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/schema"
)

// describeWorkflowsCmd executes 'atmos describe workflows' CLI commands
Expand All @@ -14,12 +18,31 @@ var describeWorkflowsCmd = &cobra.Command{
Long: "List all Atmos workflows, showing their associated files and workflow names for easy reference.",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
err := e.ExecuteDescribeWorkflowsCmd(cmd, args)
if err != nil {
u.PrintErrorMarkdownAndExit("", err, "")
}
},
Run: getRunnableDescribeWorkflowsCmd(checkAtmosConfig, exec.ProcessCommandLineArgs, cfg.InitCliConfig, exec.NewDescribeWorkflowsExec()),
}

func getRunnableDescribeWorkflowsCmd(
checkAtmosConfig func(opts ...AtmosValidateOption),
processCommandLineArgs func(componentType string, cmd *cobra.Command, args []string, additionalArgsAndFlags []string) (schema.ConfigAndStacksInfo, error),
initCliConfig func(info schema.ConfigAndStacksInfo, validate bool) (schema.AtmosConfiguration, error),
describeWorkflowsExec exec.DescribeWorkflowsExec,
) func(cmd *cobra.Command, args []string) {
return func(cmd *cobra.Command, args []string) {
// Check Atmos configuration
checkAtmosConfig()
info, err := processCommandLineArgs("terraform", cmd, args, nil)
checkErrorAndExit(err)
atmosConfig, err := initCliConfig(info, true)
checkErrorAndExit(err)
describeWorkflowArgs := &exec.DescribeWorkflowsArgs{}
err = flagsToDescribeWorkflowsArgs(cmd.Flags(), describeWorkflowArgs)
checkErrorAndExit(err)
pager, err := cmd.Flags().GetString("pager")
checkFlagNotPresentError(err)
atmosConfig.Settings.Terminal.Pager = pager
err = describeWorkflowsExec.Execute(&atmosConfig, describeWorkflowArgs)
checkErrorAndExit(err)
}
}

func init() {
Expand All @@ -28,3 +51,53 @@ func init() {

describeCmd.AddCommand(describeWorkflowsCmd)
}

func flagsToDescribeWorkflowsArgs(flags *pflag.FlagSet, describe *exec.DescribeWorkflowsArgs) error {
if err := setStringFlagIfChanged(flags, "format", &describe.Format); err != nil {
return err
}
if err := setStringFlagIfChanged(flags, "output", &describe.OutputType); err != nil {
return err
}
if err := setStringFlagIfChanged(flags, "query", &describe.Query); err != nil {
return err
}

if err := validateAndSetDefaults(describe); err != nil {
return err
}

return nil
}

func setStringFlagIfChanged(flags *pflag.FlagSet, name string, target *string) error {
if flags.Changed(name) {
val, err := flags.GetString(name)
if err != nil {
return err
}
*target = val
}
return nil
}

var (
ErrInvalidOutputType = fmt.Errorf("invalid output type specified. Valid values are 'list', 'map', and 'all'")
ErrInvalidFormat = fmt.Errorf("invalid format specified. Valid values are 'yaml' and 'json'")
)

func validateAndSetDefaults(describe *exec.DescribeWorkflowsArgs) error {
if describe.Format == "" {
describe.Format = "yaml"
} else if describe.Format != "yaml" && describe.Format != "json" {
return ErrInvalidFormat
}

if describe.OutputType == "" {
describe.OutputType = "list"
} else if describe.OutputType != "list" && describe.OutputType != "map" && describe.OutputType != "all" {
return ErrInvalidOutputType
}

return nil
}
94 changes: 94 additions & 0 deletions cmd/describe_workflows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package cmd

import (
"testing"

"github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/schema"
"github.com/golang/mock/gomock"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"
)

func TestSetFlagInDescribeWorkflow(t *testing.T) {
// Initialize test cases
tests := []struct {
name string
setFlags func(*pflag.FlagSet)
expected *exec.DescribeWorkflowsArgs
expectedErr bool
}{
{
name: "Set string flags",
setFlags: func(fs *pflag.FlagSet) {
fs.Set("format", "json")
fs.Set("output", "map")
},
expected: &exec.DescribeWorkflowsArgs{
Format: "json",
OutputType: "map",
},
},
{
name: "No flags changed, set default format",
setFlags: func(fs *pflag.FlagSet) {
// No flags set
},
expected: &exec.DescribeWorkflowsArgs{
Format: "yaml",
OutputType: "list",
},
},
{
name: "Set invalid format, no override",
setFlags: func(fs *pflag.FlagSet) {
fs.Set("format", "invalid_format")
},
expectedErr: true,
},
{
name: "Set invalid output type, no override",
setFlags: func(fs *pflag.FlagSet) {
fs.Set("output", "invalid_output")
},
expectedErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
fs.StringP("format", "f", "yaml", "Specify the output format (`yaml` is default)")
fs.StringP("output", "o", "list", "Specify the output type (`list` is default)")
fs.StringP("query", "q", "", "Specify a query to filter the output")
tt.setFlags(fs)
describeWorkflowsArgs := &exec.DescribeWorkflowsArgs{}
err := flagsToDescribeWorkflowsArgs(fs, describeWorkflowsArgs)
if tt.expectedErr {
assert.Error(t, err)
return
}
assert.NoError(t, err)
assert.Equal(t, tt.expected, describeWorkflowsArgs)
})
}
}

func TestDescribeWorklows(t *testing.T) {
ctrl := gomock.NewController(t)
describeWorkflowsMock := exec.NewMockDescribeWorkflowsExec(ctrl)
describeWorkflowsMock.EXPECT().Execute(gomock.Any(), gomock.Any()).Return(nil).Times(1)
run := getRunnableDescribeWorkflowsCmd(
func(opts ...AtmosValidateOption) {},
func(componentType string, cmd *cobra.Command, args, additionalArgsAndFlags []string) (schema.ConfigAndStacksInfo, error) {
return schema.ConfigAndStacksInfo{}, nil
},
func(info schema.ConfigAndStacksInfo, validate bool) (schema.AtmosConfiguration, error) {
return schema.AtmosConfiguration{}, nil
},
describeWorkflowsMock,
)
run(describeWorkflowsCmd, []string{})
ctrl.Finish()
}
2 changes: 1 addition & 1 deletion internal/exec/describe_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (d *describeStacksExec) Execute(atmosConfig *schema.AtmosConfiguration, arg
}

return viewWithScroll(&viewWithScrollProps{
pageCreator: pager.New(),
pageCreator: d.pageCreator,
isTTYSupportForStdout: d.isTTYSupportForStdout,
printOrWriteToFile: d.printOrWriteToFile,
atmosConfig: atmosConfig,
Expand Down
91 changes: 42 additions & 49 deletions internal/exec/describe_workflows.go
Original file line number Diff line number Diff line change
@@ -1,62 +1,46 @@
package exec

import (
"fmt"

"github.com/cloudposse/atmos/internal/tui/templates/term"
"github.com/cloudposse/atmos/pkg/pager"
"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"

cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/spf13/cobra"
)

// ExecuteDescribeWorkflowsCmd executes `atmos describe workflows` CLI command
func ExecuteDescribeWorkflowsCmd(cmd *cobra.Command, args []string) error {
info, err := ProcessCommandLineArgs("terraform", cmd, args, nil)
if err != nil {
return err
}

info.CliArgs = []string{"describe", "workflows"}

atmosConfig, err := cfg.InitCliConfig(info, true)
if err != nil {
return err
}

flags := cmd.Flags()

format, err := flags.GetString("format")
if err != nil {
return err
}

if format != "" && format != "yaml" && format != "json" {
return fmt.Errorf("invalid '--format' flag '%s'. Valid values are 'yaml' (default) and 'json'", format)
}

if format == "" {
format = "yaml"
}
type DescribeWorkflowsArgs struct {
Format string
OutputType string
Query string
}

outputType, err := flags.GetString("output")
if err != nil {
return err
}
//go:generate mockgen -source=$GOFILE -destination=mock_$GOFILE -package=$GOPACKAGE
type DescribeWorkflowsExec interface {
Execute(*schema.AtmosConfiguration, *DescribeWorkflowsArgs) error
}

if outputType != "" && outputType != "list" && outputType != "map" && outputType != "all" {
return fmt.Errorf("invalid '--output' flag '%s'. Valid values are 'list' (default), 'map' and 'all'", outputType)
}
type describeWorkflowsExec struct {
printOrWriteToFile func(atmosConfig *schema.AtmosConfiguration, format, file string, data any) error
IsTTYSupportForStdout func() bool
pagerCreator pager.PageCreator
executeDescribeWorkflows func(atmosConfig schema.AtmosConfiguration) ([]schema.DescribeWorkflowsItem, map[string][]string, map[string]schema.WorkflowManifest, error)
}

if outputType == "" {
outputType = "list"
func NewDescribeWorkflowsExec() DescribeWorkflowsExec {
return &describeWorkflowsExec{
printOrWriteToFile: printOrWriteToFile,
IsTTYSupportForStdout: term.IsTTYSupportForStdout,
executeDescribeWorkflows: ExecuteDescribeWorkflows,
pagerCreator: pager.New(),
}
}

query, err := flags.GetString("query")
if err != nil {
return err
}
// ExecuteDescribeWorkflowsCmd executes `atmos describe workflows` CLI command.
func (d *describeWorkflowsExec) Execute(atmosConfig *schema.AtmosConfiguration, describeWorkflowsArgs *DescribeWorkflowsArgs) error {
outputType := describeWorkflowsArgs.OutputType
query := describeWorkflowsArgs.Query
format := describeWorkflowsArgs.Format

describeWorkflowsList, describeWorkflowsMap, describeWorkflowsAll, err := ExecuteDescribeWorkflows(atmosConfig)
describeWorkflowsList, describeWorkflowsMap, describeWorkflowsAll, err := d.executeDescribeWorkflows(*atmosConfig)
if err != nil {
return err
}
Expand All @@ -72,13 +56,22 @@ func ExecuteDescribeWorkflowsCmd(cmd *cobra.Command, args []string) error {
}

if query != "" {
res, err = u.EvaluateYqExpression(&atmosConfig, res, query)
res, err = u.EvaluateYqExpression(atmosConfig, res, query)
if err != nil {
return err
}
}

err = printOrWriteToFile(&atmosConfig, format, "", res)
err = viewWithScroll(&viewWithScrollProps{
pageCreator: d.pagerCreator,
isTTYSupportForStdout: d.IsTTYSupportForStdout,
printOrWriteToFile: d.printOrWriteToFile,
atmosConfig: atmosConfig,
displayName: "Describe Workflows",
format: format,
file: "",
res: res,
})
if err != nil {
return err
}
Expand Down
Loading
Loading