From a5fa73154561fc9cf51f16ea881a8fa7de2116c5 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 5 Feb 2021 16:24:01 +0200 Subject: [PATCH] Add support for getting resources by name - add singular alias to get commands - allow filtering the get commands result by resource name - add the image commands to mkdocs index Signed-off-by: Stefan Prodan --- cmd/flux/get.go | 5 +++ cmd/flux/get_alert.go | 7 +++-- cmd/flux/get_alertprovider.go | 7 +++-- cmd/flux/get_helmrelease.go | 2 +- cmd/flux/get_image.go | 7 +++-- cmd/flux/get_kustomization.go | 2 +- cmd/flux/get_receiver.go | 7 +++-- cmd/flux/get_source.go | 7 +++-- docs/cmd/flux_get.md | 2 +- .../{flux_get_image.md => flux_get_images.md} | 10 +++--- ...ge_policy.md => flux_get_images_policy.md} | 6 ++-- ...itory.md => flux_get_images_repository.md} | 6 ++-- ...ge_update.md => flux_get_images_update.md} | 6 ++-- mkdocs.yml | 31 +++++++++++++++++-- 14 files changed, 71 insertions(+), 34 deletions(-) rename docs/cmd/{flux_get_image.md => flux_get_images.md} (69%) rename docs/cmd/{flux_get_image_policy.md => flux_get_images_policy.md} (86%) rename docs/cmd/{flux_get_image_repository.md => flux_get_images_repository.md} (86%) rename docs/cmd/{flux_get_image_update.md => flux_get_images_update.md} (86%) diff --git a/cmd/flux/get.go b/cmd/flux/get.go index 5a60b2b8..7ef3583e 100644 --- a/cmd/flux/get.go +++ b/cmd/flux/get.go @@ -90,6 +90,11 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error { if !getArgs.allNamespaces { listOpts = append(listOpts, client.InNamespace(rootArgs.namespace)) } + + if len(args) > 0 { + listOpts = append(listOpts, client.MatchingFields{"metadata.name": args[0]}) + } + err = kubeClient.List(ctx, get.list.asClientList(), listOpts...) if err != nil { return err diff --git a/cmd/flux/get_alert.go b/cmd/flux/get_alert.go index 2219cdd8..5d4ab78d 100644 --- a/cmd/flux/get_alert.go +++ b/cmd/flux/get_alert.go @@ -33,9 +33,10 @@ import ( ) var getAlertCmd = &cobra.Command{ - Use: "alerts", - Short: "Get Alert statuses", - Long: "The get alert command prints the statuses of the resources.", + Use: "alerts", + Aliases: []string{"alert"}, + Short: "Get Alert statuses", + Long: "The get alert command prints the statuses of the resources.", Example: ` # List all Alerts and their status flux get alerts `, diff --git a/cmd/flux/get_alertprovider.go b/cmd/flux/get_alertprovider.go index 72f76df1..3cf58e3c 100644 --- a/cmd/flux/get_alertprovider.go +++ b/cmd/flux/get_alertprovider.go @@ -31,9 +31,10 @@ import ( ) var getAlertProviderCmd = &cobra.Command{ - Use: "alert-providers", - Short: "Get Provider statuses", - Long: "The get alert-provider command prints the statuses of the resources.", + Use: "alert-providers", + Aliases: []string{"alert-provider"}, + Short: "Get Provider statuses", + Long: "The get alert-provider command prints the statuses of the resources.", Example: ` # List all Providers and their status flux get alert-providers `, diff --git a/cmd/flux/get_helmrelease.go b/cmd/flux/get_helmrelease.go index 89828acd..4e5d9a04 100644 --- a/cmd/flux/get_helmrelease.go +++ b/cmd/flux/get_helmrelease.go @@ -26,7 +26,7 @@ import ( var getHelmReleaseCmd = &cobra.Command{ Use: "helmreleases", - Aliases: []string{"hr"}, + Aliases: []string{"hr", "helmrelease"}, Short: "Get HelmRelease statuses", Long: "The get helmreleases command prints the statuses of the resources.", Example: ` # List all Helm releases and their status diff --git a/cmd/flux/get_image.go b/cmd/flux/get_image.go index 44e39880..41181189 100644 --- a/cmd/flux/get_image.go +++ b/cmd/flux/get_image.go @@ -21,9 +21,10 @@ import ( ) var getImageCmd = &cobra.Command{ - Use: "image", - Short: "Get image automation object status", - Long: "The get image sub-commands print the status of image automation objects.", + Use: "images", + Aliases: []string{"image"}, + Short: "Get image automation object status", + Long: "The get image sub-commands print the status of image automation objects.", } func init() { diff --git a/cmd/flux/get_kustomization.go b/cmd/flux/get_kustomization.go index 58623a8a..3d661ef8 100644 --- a/cmd/flux/get_kustomization.go +++ b/cmd/flux/get_kustomization.go @@ -26,7 +26,7 @@ import ( var getKsCmd = &cobra.Command{ Use: "kustomizations", - Aliases: []string{"ks"}, + Aliases: []string{"ks", "kustomization"}, Short: "Get Kustomization statuses", Long: "The get kustomizations command prints the statuses of the resources.", Example: ` # List all kustomizations and their status diff --git a/cmd/flux/get_receiver.go b/cmd/flux/get_receiver.go index 41232d53..4334a4ff 100644 --- a/cmd/flux/get_receiver.go +++ b/cmd/flux/get_receiver.go @@ -33,9 +33,10 @@ import ( ) var getReceiverCmd = &cobra.Command{ - Use: "receivers", - Short: "Get Receiver statuses", - Long: "The get receiver command prints the statuses of the resources.", + Use: "receivers", + Aliases: []string{"receiver"}, + Short: "Get Receiver statuses", + Long: "The get receiver command prints the statuses of the resources.", Example: ` # List all Receiver and their status flux get receivers `, diff --git a/cmd/flux/get_source.go b/cmd/flux/get_source.go index 6ae765e6..0be7acf0 100644 --- a/cmd/flux/get_source.go +++ b/cmd/flux/get_source.go @@ -21,9 +21,10 @@ import ( ) var getSourceCmd = &cobra.Command{ - Use: "sources", - Short: "Get source statuses", - Long: "The get source sub-commands print the statuses of the sources.", + Use: "sources", + Aliases: []string{"source"}, + Short: "Get source statuses", + Long: "The get source sub-commands print the statuses of the sources.", } func init() { diff --git a/docs/cmd/flux_get.md b/docs/cmd/flux_get.md index 629b1b53..676d91b1 100644 --- a/docs/cmd/flux_get.md +++ b/docs/cmd/flux_get.md @@ -29,7 +29,7 @@ The get sub-commands print the statuses of sources and resources. * [flux get alert-providers](flux_get_alert-providers.md) - Get Provider statuses * [flux get alerts](flux_get_alerts.md) - Get Alert statuses * [flux get helmreleases](flux_get_helmreleases.md) - Get HelmRelease statuses -* [flux get image](flux_get_image.md) - Get image automation object status +* [flux get images](flux_get_images.md) - Get image automation object status * [flux get kustomizations](flux_get_kustomizations.md) - Get Kustomization statuses * [flux get receivers](flux_get_receivers.md) - Get Receiver statuses * [flux get sources](flux_get_sources.md) - Get source statuses diff --git a/docs/cmd/flux_get_image.md b/docs/cmd/flux_get_images.md similarity index 69% rename from docs/cmd/flux_get_image.md rename to docs/cmd/flux_get_images.md index 13a76441..c349f5eb 100644 --- a/docs/cmd/flux_get_image.md +++ b/docs/cmd/flux_get_images.md @@ -1,4 +1,4 @@ -## flux get image +## flux get images Get image automation object status @@ -9,7 +9,7 @@ The get image sub-commands print the status of image automation objects. ### Options ``` - -h, --help help for image + -h, --help help for images ``` ### Options inherited from parent commands @@ -26,7 +26,7 @@ The get image sub-commands print the status of image automation objects. ### SEE ALSO * [flux get](flux_get.md) - Get sources and resources -* [flux get image policy](flux_get_image_policy.md) - Get ImagePolicy status -* [flux get image repository](flux_get_image_repository.md) - Get ImageRepository status -* [flux get image update](flux_get_image_update.md) - Get ImageUpdateAutomation status +* [flux get images policy](flux_get_images_policy.md) - Get ImagePolicy status +* [flux get images repository](flux_get_images_repository.md) - Get ImageRepository status +* [flux get images update](flux_get_images_update.md) - Get ImageUpdateAutomation status diff --git a/docs/cmd/flux_get_image_policy.md b/docs/cmd/flux_get_images_policy.md similarity index 86% rename from docs/cmd/flux_get_image_policy.md rename to docs/cmd/flux_get_images_policy.md index 6380117b..e528d83b 100644 --- a/docs/cmd/flux_get_image_policy.md +++ b/docs/cmd/flux_get_images_policy.md @@ -1,4 +1,4 @@ -## flux get image policy +## flux get images policy Get ImagePolicy status @@ -7,7 +7,7 @@ Get ImagePolicy status The get image policy command prints the status of ImagePolicy objects. ``` -flux get image policy [flags] +flux get images policy [flags] ``` ### Examples @@ -40,5 +40,5 @@ flux get image policy [flags] ### SEE ALSO -* [flux get image](flux_get_image.md) - Get image automation object status +* [flux get images](flux_get_images.md) - Get image automation object status diff --git a/docs/cmd/flux_get_image_repository.md b/docs/cmd/flux_get_images_repository.md similarity index 86% rename from docs/cmd/flux_get_image_repository.md rename to docs/cmd/flux_get_images_repository.md index b50d4566..587bd357 100644 --- a/docs/cmd/flux_get_image_repository.md +++ b/docs/cmd/flux_get_images_repository.md @@ -1,4 +1,4 @@ -## flux get image repository +## flux get images repository Get ImageRepository status @@ -7,7 +7,7 @@ Get ImageRepository status The get image repository command prints the status of ImageRepository objects. ``` -flux get image repository [flags] +flux get images repository [flags] ``` ### Examples @@ -40,5 +40,5 @@ flux get image repository [flags] ### SEE ALSO -* [flux get image](flux_get_image.md) - Get image automation object status +* [flux get images](flux_get_images.md) - Get image automation object status diff --git a/docs/cmd/flux_get_image_update.md b/docs/cmd/flux_get_images_update.md similarity index 86% rename from docs/cmd/flux_get_image_update.md rename to docs/cmd/flux_get_images_update.md index b4075302..ab25dfeb 100644 --- a/docs/cmd/flux_get_image_update.md +++ b/docs/cmd/flux_get_images_update.md @@ -1,4 +1,4 @@ -## flux get image update +## flux get images update Get ImageUpdateAutomation status @@ -7,7 +7,7 @@ Get ImageUpdateAutomation status The get image update command prints the status of ImageUpdateAutomation objects. ``` -flux get image update [flags] +flux get images update [flags] ``` ### Examples @@ -40,5 +40,5 @@ flux get image update [flags] ### SEE ALSO -* [flux get image](flux_get_image.md) - Get image automation object status +* [flux get images](flux_get_images.md) - Get image automation object status diff --git a/mkdocs.yml b/mkdocs.yml index f64a763e..6087e4f9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -104,10 +104,15 @@ nav: - Create alert provider: cmd/flux_create_alert-provider.md - Create alert: cmd/flux_create_alert.md - Create receiver: cmd/flux_create_receiver.md + - Create image: cmd/flux_create_image.md + - Create image policy: cmd/flux_create_image_policy.md + - Create image repository: cmd/flux_create_image_repository.md + - Create image update: cmd/flux_create_image_update.md - Create tenant: cmd/flux_create_tenant.md - Create secret: cmd/flux_create_secret.md - Create secret git: cmd/flux_create_secret_git.md - Create secret helm: cmd/flux_create_secret_helm.md + - Create secret tls: cmd/flux_create_secret_tls.md - Delete: cmd/flux_delete.md - Delete kustomization: cmd/flux_delete_kustomization.md - Delete helmrelease: cmd/flux_delete_helmrelease.md @@ -115,6 +120,10 @@ nav: - Delete source git: cmd/flux_delete_source_git.md - Delete source helm: cmd/flux_delete_source_helm.md - Delete source bucket: cmd/flux_delete_source_bucket.md + - Delete image: cmd/flux_delete_image.md + - Delete image policy: cmd/flux_delete_image_policy.md + - Delete image repository: cmd/flux_delete_image_repository.md + - Delete image update: cmd/flux_delete_image_update.md - Export: cmd/flux_export.md - Export kustomization: cmd/flux_export_kustomization.md - Export helmrelease: cmd/flux_export_helmrelease.md @@ -125,6 +134,10 @@ nav: - Export alert provider: cmd/flux_export_alert-provider.md - Export alert: cmd/flux_export_alert.md - Export receiver: cmd/flux_export_receiver.md + - Export image: cmd/flux_export_image.md + - Export image policy: cmd/flux_export_image_policy.md + - Export image repository: cmd/flux_export_image_repository.md + - Export image update: cmd/flux_export_image_update.md - Get: cmd/flux_get.md - Get kustomizations: cmd/flux_get_kustomizations.md - Get helmreleases: cmd/flux_get_helmreleases.md @@ -134,8 +147,13 @@ nav: - Get sources chart: cmd/flux_get_sources_chart.md - Get sources bucket: cmd/flux_get_sources_bucket.md - Get alert provider: cmd/flux_get_alert-provider.md - - Get alert: cmd/flux_get_alert.md - - Get receiver: cmd/flux_get_receiver.md + - Get alerts: cmd/flux_get_alerts.md + - Get alert providers: cmd/flux_get_alert-providers.md + - Get receivers: cmd/flux_get_receivers.md + - Get images: cmd/flux_get_images.md + - Get images policy: cmd/flux_get_images_policy.md + - Get images repository: cmd/flux_get_images_repository.md + - Get images update: cmd/flux_get_images_update.md - Install: cmd/flux_install.md - Resume: cmd/flux_resume.md - Resume kustomization: cmd/flux_resume_kustomization.md @@ -148,6 +166,9 @@ nav: - Resume alert provider: cmd/flux_resume_alert-provider.md - Resume alert: cmd/flux_resume_alert.md - Resume receiver: cmd/flux_resume_receiver.md + - Resume image: cmd/flux_resume_image.md + - Resume image repository: cmd/flux_resume_image_repository.md + - Resume image update: cmd/flux_resume_image_update.md - Suspend: cmd/flux_suspend.md - Suspend kustomization: cmd/flux_suspend_kustomization.md - Suspend helmrelease: cmd/flux_suspend_helmrelease.md @@ -159,6 +180,9 @@ nav: - Suspend alert provider: cmd/flux_suspend_alert-provider.md - Suspend alert: cmd/flux_suspend_alert.md - Suspend receiver: cmd/flux_suspend_receiver.md + - Suspend image: cmd/flux_suspend_image.md + - Suspend image repository: cmd/flux_suspend_image_repository.md + - Suspend image update: cmd/flux_suspend_image_update.md - Reconcile: cmd/flux_reconcile.md - Reconcile kustomization: cmd/flux_reconcile_kustomization.md - Reconcile helmrelease: cmd/flux_reconcile_helmrelease.md @@ -166,6 +190,9 @@ nav: - Reconcile source git: cmd/flux_reconcile_source_git.md - Reconcile source helm: cmd/flux_reconcile_source_helm.md - Reconcile source bucket: cmd/flux_reconcile_source_bucket.md + - Reconcile image: cmd/flux_reconcile_image.md + - Reconcile image repository: cmd/flux_reconcile_image_repository.md + - Reconcile image update: cmd/flux_reconcile_image_update.md - Uninstall: cmd/flux_uninstall.md - Dev Guides: - Watching for source changes: dev-guides/source-watcher.md