You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh cs delete should support a flag like --org for user-owned repos #7315
Describe the feature or problem you’d like to solve
Pretty frequently I've got codespaces in a few repos I own and have wanted to wipe them all at once. If the repos were in an org, I could use --org, but since I own them that flag doesn't work (it ends up trying to hit /orgs/cmbrose/members/cmbrose/codespaces which 404s). So the best I can do in that case is to delete all codespaces by repo, for each repo.
It would be nice if there was a flag I could use to delete all codespaces in repos I own.
Proposed solution
[Edit] As pointed out by @kousikmitra - an option used by other commands is to have a --owner parameter for this case - in that case --owner could be a user or an org name. This has some apparent overlap with the existing --org parameter, but that flag is meant only for admins and can't be used by normal users so really they support distinct scenarios.
Another option is to support wildcards in --repo - e.g. --repo cmbrose/*. I think that this just entails switching the repo filter from exact match to supporting the wildcard.
Alternatively, we could overload the --org flag to support passing usernames in addition to orgs, but that will likely make the code convoluted because the --org flag is already only used in an org admin context and has some special behaviors.
Finally, if it's not desirable to change the usage of --repo we could add a new flag like --repo-like to make it explicit that the user wants to use a wildcard. This feels unnecessary though.
I have seen other commands to use --owner for targeting user owned repos, can that be an option here?
Oh nice, yeah that's a great idea - it also captures the "delete all of my repos in this org" scenario without needing org admin permissions required for --org
@cmbrose Sorry for the confusion, but don't think --owner would be an ideal flag name here. In github's term any codespace that I create the owner would be me.
For example,
If I create codespace both in cli/cli and kousikmitra/cli both will have kousikmitra as owner.
@kousikmitra yeah makes sense - the term owner applies to a couple things here - repo owner and codespace owner. Maybe the parameter could be called --repo-owner instead to avoid confusion? WDYT?
@kousikmitra yeah makes sense - the term owner applies to a couple things here - repo owner and codespace owner. Maybe the parameter could be called --repo-owner instead to avoid confusion? WDYT?
Activity
kousikmitra commentedon Apr 19, 2023
I have seen other commands to use
--ownerfor targeting user owned repos, can that be an option here?cmbrose commentedon Apr 19, 2023
Oh nice, yeah that's a great idea - it also captures the "delete all of my repos in this org" scenario without needing org admin permissions required for
--orgkousikmitra commentedon Apr 20, 2023
Great, would like to work on this if it's up for grab.
cmbrose commentedon Apr 20, 2023
Sounds great! I'm happy to review when it's ready
kousikmitra commentedon Apr 20, 2023
@cmbrose Sorry for the confusion, but don't think
--ownerwould be an ideal flag name here. In github's term any codespace that I create the owner would be me.For example,
If I create codespace both in
cli/cliandkousikmitra/cliboth will havekousikmitraas owner.Now using
gh cs delete --owner kousikmitrato delete codespaces relatedkousikmitra/*would be misleading.Let me know your thoughts or if I am missing something here.
cmbrose commentedon Apr 21, 2023
@kousikmitra yeah makes sense - the term
ownerapplies to a couple things here - repo owner and codespace owner. Maybe the parameter could be called--repo-ownerinstead to avoid confusion? WDYT?kousikmitra commentedon Apr 21, 2023
Yeah, Sounds good to me.