Skip to content

Conversation

@lizrabuya
Copy link
Contributor

@lizrabuya lizrabuya commented Nov 25, 2025

The create pipeline API now requires a cluster_id to create the pipeline. The bk cli will now prompt the user to select from the org's existing clusters, or skip when the org was created with only an unclustered area.

@lizrabuya lizrabuya marked this pull request as ready for review November 25, 2025 08:20
@lizrabuya lizrabuya requested a review from a team as a code owner November 25, 2025 08:20
Copy link
Contributor

@JoeColeman95 JoeColeman95 left a comment

Choose a reason for hiding this comment

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

Hey Lizette, great work on this!

I've found a couple of things that seem blocking to me (pagination/the forced cluster), happy to discuss if you disagree on any of these, though 🙂

Comment on lines 112 to 127
func getClusters(ctx context.Context, f *factory.Factory) map[string]string {
clusters, _, err := f.RestAPIClient.Clusters.List(ctx, f.Config.OrganizationSlug(), nil)
if err != nil {
return map[string]string{}
}

if len(clusters) < 1 {
return map[string]string{}
}

clusterMap := make(map[string]string, len(clusters))
for _, cluster := range clusters {
clusterMap[cluster.Name] = cluster.ID
}
return clusterMap
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Blocking: We should paginate here as this will only fetch the first page of results which defaults to 30. In this case, it'd be widely working, but some users may have more than 30 clusters, which would mean they'd only see some of the results.

We have pagination in a few places, but it can vary quite a lot depending on the call. The best example of this I can see in this code base is in the filterPipelines function, which should be 1:1 transferable here.

func getClusters(ctx context.Context, f *factory.Factory) map[string]string {
clusters, _, err := f.RestAPIClient.Clusters.List(ctx, f.Config.OrganizationSlug(), nil)
if err != nil {
return map[string]string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: API errors are silently swallowed here. Not blocking, but could be confusing if the list call fails for network/auth reasons

Options: clusterNames,
}
var selectedClusterName string
err := survey.AskOne(prompt, &selectedClusterName, survey.WithValidator(survey.Required))
Copy link
Contributor

Choose a reason for hiding this comment

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

Design choice/blocking: This seems like it could be breaking for some users. The API at the moment sets cluster_id to optional, in this case, we're forcing an option if there is a cluster available, but what if an org has a cluster with 0 agents but 1+ unclustered agent(s)? We'd be forcing them to select an unusable cluster, should we allow skipping even if there's a cluster in this case to allow these cases? I think respecting the API is the best bet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Yeah, I agree we should allow skipping even if there is a cluster available.

lizrabuya and others added 2 commits November 26, 2025 09:07
Co-authored-by: Joe Coleman <107399878+JoeColeman95@users.noreply.github.com>
Copy link
Contributor

@JoeColeman95 JoeColeman95 left a comment

Choose a reason for hiding this comment

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

Very nice! 😄

@lizrabuya lizrabuya merged commit 454f9d6 into main Nov 26, 2025
1 check passed
@lizrabuya lizrabuya deleted the fix/add_cluster_on_create_pipeline branch November 26, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants