-
Notifications
You must be signed in to change notification settings - Fork 20
APIE-571 - update for default compute pool #3193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tmalikconfluent
wants to merge
7
commits into
main
Choose a base branch
from
APIE-571
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37c858f
APIE-571 - update for default compute pool
tmalikconfluent 342c3a5
Add --default-pool
tmalikconfluent 86fe4b6
Add compute pool config
tmalikconfluent 288e84c
Tests fix
tmalikconfluent 7a86a93
Tests fix
tmalikconfluent b41d251
Lint
tmalikconfluent 25301fe
Nits
tmalikconfluent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package flink | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| type computePoolConfigOut struct { | ||
| DefaultPoolEnabled bool `human:"Default Pool Enabled" serialized:"default_pool_enabled"` | ||
| DefaultPoolMaxCFU int32 `human:"Default Pool Max CFU" serialized:"default_pool_max_cfu"` | ||
| } | ||
|
|
||
| func (c *command) newComputePoolConfigCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "compute-pool-config", | ||
| Short: "Manage Flink compute pools configs.", | ||
| } | ||
|
|
||
| cmd.AddCommand(c.newComputePoolConfigDescribeCommand()) | ||
| cmd.AddCommand(c.newComputePoolConfigUpdateCommand()) | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package flink | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
|
|
||
| pcmd "github.com/confluentinc/cli/v4/pkg/cmd" | ||
| "github.com/confluentinc/cli/v4/pkg/output" | ||
| ) | ||
|
|
||
| func (c *command) newComputePoolConfigDescribeCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "describe", | ||
| Short: "Describe a Flink compute pool config.", | ||
| Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, | ||
| RunE: c.computePoolConfigDescribe, | ||
| } | ||
|
|
||
| pcmd.AddOutputFlag(cmd) | ||
| return cmd | ||
| } | ||
|
|
||
| func (c *command) computePoolConfigDescribe(cmd *cobra.Command, args []string) error { | ||
| computePoolConfig, err := c.V2Client.DescribeFlinkComputePoolConfig() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| table := output.NewTable(cmd) | ||
| table.Add(&computePoolConfigOut{ | ||
| DefaultPoolEnabled: computePoolConfig.Spec.GetDefaultPoolEnabled(), | ||
| DefaultPoolMaxCFU: computePoolConfig.Spec.GetDefaultPoolMaxCfu(), | ||
| }) | ||
| return table.Print() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package flink | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
|
|
||
| flinkv2 "github.com/confluentinc/ccloud-sdk-go-v2/flink/v2" | ||
|
|
||
| pcmd "github.com/confluentinc/cli/v4/pkg/cmd" | ||
| "github.com/confluentinc/cli/v4/pkg/examples" | ||
| "github.com/confluentinc/cli/v4/pkg/output" | ||
| ) | ||
|
|
||
| func (c *command) newComputePoolConfigUpdateCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "update", | ||
| Short: "Update a Flink compute pool config.", | ||
| Args: cobra.MaximumNArgs(1), | ||
| ValidArgsFunction: pcmd.NewValidArgsFunction(c.validComputePoolArgs), | ||
| Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, | ||
| RunE: c.computePoolConfigUpdate, | ||
| Example: examples.BuildExampleString( | ||
| examples.Example{ | ||
| Text: `Update CFU count of a Flink compute pool config.`, | ||
| Code: `confluent flink compute-pool update --max-cfu 5`, | ||
| }, | ||
| ), | ||
| } | ||
|
|
||
| cmd.Flags().Int32("max-cfu", -1, "Maximum number of Confluent Flink Units (CFUs) that default compute pools in this organization should auto-scale to.") | ||
| cmd.Flags().Bool("default-pool", false, "Whether default compute pools are enabled for the organization.") | ||
| pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand) | ||
| pcmd.AddOutputFlag(cmd) | ||
|
|
||
| cmd.MarkFlagsOneRequired("max-cfu", "default-pool") | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| func (c *command) computePoolConfigUpdate(cmd *cobra.Command, args []string) error { | ||
| computePoolConfig, err := c.V2Client.DescribeFlinkComputePoolConfig() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| update := flinkv2.FcpmV2OrgComputePoolConfigUpdate{ | ||
| Spec: &flinkv2.FcpmV2OrgComputePoolConfigSpec{ | ||
| DefaultPoolEnabled: flinkv2.PtrBool(computePoolConfig.Spec.GetDefaultPoolEnabled()), | ||
| DefaultPoolMaxCfu: flinkv2.PtrInt32(computePoolConfig.Spec.GetDefaultPoolMaxCfu()), | ||
| }, | ||
| } | ||
|
|
||
| if cmd.Flags().Changed("default-pool") { | ||
| defaultPool, err := cmd.Flags().GetBool("default-pool") | ||
| if err != nil { | ||
| return err | ||
| } | ||
| update.Spec.DefaultPoolEnabled = flinkv2.PtrBool(defaultPool) | ||
| } | ||
|
|
||
| maxCfu, err := cmd.Flags().GetInt32("max-cfu") | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if maxCfu != -1 { | ||
| update.Spec.DefaultPoolMaxCfu = flinkv2.PtrInt32(maxCfu) | ||
| } | ||
|
|
||
| updatedComputePoolConfig, err := c.V2Client.UpdateFlinkComputePoolConfig(update) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| table := output.NewTable(cmd) | ||
| table.Add(&computePoolConfigOut{ | ||
| DefaultPoolEnabled: updatedComputePoolConfig.Spec.GetDefaultPoolEnabled(), | ||
| DefaultPoolMaxCFU: updatedComputePoolConfig.Spec.GetDefaultPoolMaxCfu(), | ||
| }) | ||
| return table.Print() | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.