Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab41a8a
feat: enable passing multiple attrFile flag
machichima Mar 1, 2025
8147b80
test: for multple --attrFile in workflow-execution-config
machichima Mar 1, 2025
a306c5a
fix: run make generate
machichima Mar 1, 2025
7e211dd
feat: pass config in yaml to subcommands
machichima Mar 10, 2025
8df595e
fix: revert modification in matchable workflow execution
machichima Mar 10, 2025
faeedc4
fix: revert matchable workflow config
machichima Mar 10, 2025
a837794
fix: goimports
machichima Mar 10, 2025
d9656e1
feat: enable for workflow-execution-config
machichima Mar 11, 2025
05001a5
feat: passs dryRun and flag to subcommands
machichima Mar 12, 2025
b4c8dd8
feat: apply for task-resource-attr and cluster-resource-attr
machichima Mar 14, 2025
5ca0bf0
fix: detect no attrFile
machichima Mar 14, 2025
ee4c6d9
feat: apply for execution-queue-attribute
machichima Mar 14, 2025
2202f68
feat: apply for execution-cluster-label
machichima Mar 14, 2025
4eb4c3e
feat: apply for plugin-override
machichima Mar 14, 2025
43e97cf
refactor: use existing variable
machichima Mar 14, 2025
860db74
feat: raise warning if not support config with file
machichima Mar 15, 2025
efa8388
lint
machichima Mar 15, 2025
070dc36
fix: mockery-v2 to mockery
machichima Mar 15, 2025
fb0b62b
test: check subcommands are called
machichima Mar 15, 2025
ff1228c
fix: remove unused import
machichima Mar 15, 2025
fab9d6d
lint
machichima Mar 15, 2025
8d42e7f
update comments
machichima Mar 15, 2025
df0f96a
docs: add docs for flytectl update --attrFile
machichima Mar 16, 2025
8b6895d
update docs
machichima Mar 16, 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
57 changes: 57 additions & 0 deletions flytectl/cmd/config/attrupdateconfig_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions flytectl/cmd/config/attrupdateconfig_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type AttrFileConfig struct {
*admin.ClusterResourceAttributes
}

var DefaultAttrFileConfig = &AttrFileConfig{}

// Decorate decorator over ClusterResourceAttributes.
func (c AttrFileConfig) Decorate() *admin.MatchingAttributes {
return &admin.MatchingAttributes{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type FileConfig struct {
*admin.ExecutionClusterLabel
}

var DefaultFileConfig = &FileConfig{}

// Decorate decorator over ExecutionClusterLabel.
func (t FileConfig) Decorate() *admin.MatchingAttributes {
return &admin.MatchingAttributes{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type AttrFileConfig struct {
*admin.ExecutionQueueAttributes
}

var DefaultAttrFileConfig = &AttrFileConfig{}

// Decorate decorator over ExecutionQueueAttributes.
func (a AttrFileConfig) Decorate() *admin.MatchingAttributes {
return &admin.MatchingAttributes{
Expand Down
2 changes: 2 additions & 0 deletions flytectl/cmd/config/subcommand/plugin_override/file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type FileConfig struct {
*admin.PluginOverrides
}

var DefaultFileConfig = &FileConfig{}

// Decorate decorator over PluginOverrides.
func (t FileConfig) Decorate() *admin.MatchingAttributes {
return &admin.MatchingAttributes{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type TaskResourceAttrFileConfig struct {
*admin.TaskResourceAttributes
}

var DefaultTaskResourceAttrFileConfig = &TaskResourceAttrFileConfig{}

// Decorate decorator over TaskResourceAttributes.
func (t TaskResourceAttrFileConfig) Decorate() *admin.MatchingAttributes {
return &admin.MatchingAttributes{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type FileConfig struct {
*admin.WorkflowExecutionConfig
}

var DefaultFileConfig = &FileConfig{}

// Decorate decorator over WorkflowExecutionConfig.
func (t FileConfig) Decorate() *admin.MatchingAttributes {
return &admin.MatchingAttributes{
Expand Down
12 changes: 12 additions & 0 deletions flytectl/cmd/config/update_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package config

//go:generate pflags AttrUpdateConfig --default-var DefaultUpdateConfig --bind-default-var

// AttrUpdateConfig Matchable resource attributes configuration passed from command line
type AttrUpdateConfig struct {
AttrFile []string `json:"attrFile" pflag:",attribute file names to be used for updating attribute for the resource type."`
DryRun bool `json:"dryRun" pflag:",execute command without making any modifications."`
Force bool `json:"force" pflag:",do not ask for an acknowledgement during updates."`
}

var DefaultUpdateConfig = &AttrUpdateConfig{}
16 changes: 16 additions & 0 deletions flytectl/cmd/testutils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ func (s *TestStruct) TearDownAndVerifyContains(t *testing.T, expectedLog string)
assert.Contains(t, sanitizeString(buf.String()), sanitizeString(expectedLog))
}

func (s *TestStruct) TearDownAndVerifyContainsSpecificCount(t *testing.T, expectedLog string, expectedCount int) {
if err := s.Writer.Close(); err != nil {
panic(fmt.Errorf("could not close test context writer: %w", err))
}

var buf bytes.Buffer
if _, err := io.Copy(&buf, s.Reader); err != nil {
panic(fmt.Errorf("could not read from test context reader: %w", err))
}

assert.Contains(t, sanitizeString(buf.String()), sanitizeString(expectedLog))

count := strings.Count(sanitizeString(buf.String()), sanitizeString(expectedLog))
assert.Equal(t, expectedCount, count)
}

// RandomName returns a string composed of random lowercase English letters of specified length.
func RandomName(length int) string {
if length < 0 {
Expand Down
13 changes: 8 additions & 5 deletions flytectl/cmd/update/matchable_cluster_resource_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ Usage

func updateClusterResourceAttributesFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error {
updateConfig := clusterresourceattribute.DefaultUpdateConfig
if len(updateConfig.AttrFile) == 0 {
return fmt.Errorf("attrFile is mandatory while calling update for cluster resource attribute")
}

clustrResourceAttrFileConfig := clusterresourceattribute.AttrFileConfig{}
if err := sconfig.ReadConfigFromFile(&clustrResourceAttrFileConfig, updateConfig.AttrFile); err != nil {
return err
if updateConfig.AttrFile != "" {
if err := sconfig.ReadConfigFromFile(&clustrResourceAttrFileConfig, updateConfig.AttrFile); err != nil {
return err
}
} else if *clusterresourceattribute.DefaultAttrFileConfig == clustrResourceAttrFileConfig {
return fmt.Errorf("attrFile is mandatory while calling update for cluster resource attribute")
Comment on lines +67 to +68

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider more explicit struct emptiness check

The condition *clusterresourceattribute.DefaultAttrFileConfig == clustrResourceAttrFileConfig is checking if the attribute file config is empty, but this comparison might not work as expected for structs. Consider using a more explicit check for empty fields instead.

Code suggestion
Check the AI-generated fix before applying
Suggested change
} else if *clusterresourceattribute.DefaultAttrFileConfig == clustrResourceAttrFileConfig {
return fmt.Errorf("attrFile is mandatory while calling update for cluster resource attribute")
} else if clustrResourceAttrFileConfig.Project == "" && clustrResourceAttrFileConfig.Domain == "" && clustrResourceAttrFileConfig.Workflow == "" {
return fmt.Errorf("attrFile is mandatory while calling update for cluster resource attribute")

Code Review Run #ea5294


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

} else {
clustrResourceAttrFileConfig = *clusterresourceattribute.DefaultAttrFileConfig
}

// Get project domain workflow name from the read file.
Expand Down
13 changes: 8 additions & 5 deletions flytectl/cmd/update/matchable_execution_cluster_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ Usage

func updateExecutionClusterLabelFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error {
updateConfig := executionclusterlabel.DefaultUpdateConfig
if len(updateConfig.AttrFile) == 0 {
return fmt.Errorf("attrFile is mandatory while calling update for execution cluster label")
}

executionClusterLabelFileConfig := executionclusterlabel.FileConfig{}
if err := sconfig.ReadConfigFromFile(&executionClusterLabelFileConfig, updateConfig.AttrFile); err != nil {
return err
if updateConfig.AttrFile != "" {
if err := sconfig.ReadConfigFromFile(&executionClusterLabelFileConfig, updateConfig.AttrFile); err != nil {
return err
}
} else if *executionclusterlabel.DefaultFileConfig == executionClusterLabelFileConfig {
return fmt.Errorf("attrFile is mandatory while calling update for execution cluster label")
} else {
executionClusterLabelFileConfig = *executionclusterlabel.DefaultFileConfig
}

// Get project domain workflow name from the read file.
Expand Down
13 changes: 8 additions & 5 deletions flytectl/cmd/update/matchable_execution_queue_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ Usage

func updateExecutionQueueAttributesFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error {
updateConfig := executionqueueattribute.DefaultUpdateConfig
if len(updateConfig.AttrFile) == 0 {
return fmt.Errorf("attrFile is mandatory while calling update for execution queue attribute")
}

executionQueueAttrFileConfig := executionqueueattribute.AttrFileConfig{}
if err := sconfig.ReadConfigFromFile(&executionQueueAttrFileConfig, updateConfig.AttrFile); err != nil {
return err
if updateConfig.AttrFile != "" {
if err := sconfig.ReadConfigFromFile(&executionQueueAttrFileConfig, updateConfig.AttrFile); err != nil {
return err
}
} else if *executionqueueattribute.DefaultAttrFileConfig == executionQueueAttrFileConfig {
return fmt.Errorf("attrFile is mandatory while calling update for execution queue attribute")
} else {
executionQueueAttrFileConfig = *executionqueueattribute.DefaultAttrFileConfig
}

// Get project domain workflow name from the read file.
Expand Down
13 changes: 8 additions & 5 deletions flytectl/cmd/update/matchable_plugin_override.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ Usage

func updatePluginOverridesFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error {
updateConfig := pluginoverride.DefaultUpdateConfig
if len(updateConfig.AttrFile) == 0 {
return fmt.Errorf("attrFile is mandatory while calling update for plugin override")
}

pluginOverrideFileConfig := pluginoverride.FileConfig{}
if err := sconfig.ReadConfigFromFile(&pluginOverrideFileConfig, updateConfig.AttrFile); err != nil {
return err
if updateConfig.AttrFile != "" {
if err := sconfig.ReadConfigFromFile(&pluginOverrideFileConfig, updateConfig.AttrFile); err != nil {
return err
}
} else if *pluginoverride.DefaultFileConfig == pluginOverrideFileConfig {
return fmt.Errorf("attrFile is mandatory while calling update for plugin override")
} else {
pluginOverrideFileConfig = *pluginoverride.DefaultFileConfig
}

// Get project domain workflow name from the read file.
Expand Down
Loading
Loading