Skip to content

Commit

Permalink
pass args to enable more detailed error message
Browse files Browse the repository at this point in the history
Signed-off-by: Sjors Holtrop <[email protected]>
  • Loading branch information
sjorsholtrop-ritense committed Jan 14, 2025
1 parent 3478fe3 commit 2e9e8e2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmd/flux/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (resume resumeCommand) run(cmd *cobra.Command, args []string) error {
// If the args slice is empty, it patches all resumable objects in the given namespace.
func (resume *resumeCommand) getPatchedResumables(ctx context.Context, args []string) ([]resumable, error) {
if len(args) < 1 {
objs, err := resume.patch(ctx, []client.ListOption{
objs, err := resume.patch(ctx, args, []client.ListOption{
client.InNamespace(resume.namespace),
})
if err != nil {
Expand All @@ -151,12 +151,7 @@ func (resume *resumeCommand) getPatchedResumables(ctx context.Context, args []st
}
processed[arg] = struct{}{}

if resume.list.len() == 0 {
logger.Failuref("%s object '%s' not found in %s namespace", resume.kind, arg, resume.namespace)
continue
}

objs, err := resume.patch(ctx, []client.ListOption{
objs, err := resume.patch(ctx, args, []client.ListOption{
client.InNamespace(resume.namespace),
client.MatchingFields{
"metadata.name": arg,
Expand All @@ -174,11 +169,16 @@ func (resume *resumeCommand) getPatchedResumables(ctx context.Context, args []st

// Patches resumable objects by setting their status to unsuspended.
// Returns a slice of resumables that have been patched and any error encountered during patching.
func (resume resumeCommand) patch(ctx context.Context, listOpts []client.ListOption) ([]resumable, error) {
func (resume resumeCommand) patch(ctx context.Context, args []string, listOpts []client.ListOption) ([]resumable, error) {
if err := resume.client.List(ctx, resume.list.asClientList(), listOpts...); err != nil {
return nil, err
}

if resume.list.len() == 0 {
logger.Failuref("%s object '%s' not found in %s namespace", resume.kind, args[0], resume.namespace)
return nil, nil
}

var resumables []resumable

for i := 0; i < resume.list.len(); i++ {
Expand Down

0 comments on commit 2e9e8e2

Please sign in to comment.