update secret inspect to support IDs
This updates secret inspect to support inspect by ID in addition to name as well as inspecting multiple secrets. This also cleans up the help text for consistency. Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
@ -18,3 +18,30 @@ func getSecretsByName(ctx context.Context, client client.APIClient, names []stri
|
||||
Filters: args,
|
||||
})
|
||||
}
|
||||
|
||||
func getCliRequestedSecretIDs(ctx context.Context, client client.APIClient, names []string) ([]string, error) {
|
||||
ids := names
|
||||
|
||||
// attempt to lookup secret by name
|
||||
secrets, err := getSecretsByName(ctx, client, ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lookup := make(map[string]struct{})
|
||||
for _, id := range ids {
|
||||
lookup[id] = struct{}{}
|
||||
}
|
||||
|
||||
if len(secrets) > 0 {
|
||||
ids = []string{}
|
||||
|
||||
for _, s := range secrets {
|
||||
if _, ok := lookup[s.Spec.Annotations.Name]; ok {
|
||||
ids = append(ids, s.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user