1
0
mirror of synced 2026-02-06 19:05:55 +00:00

Rename "auto" subcommands to "image"

This means all the sub-subcommands can drop the `image-` prefix,
making them shorter and more fluent.

E.g.,

    flux create image policy

rather than

    flux create auto image-policy

Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
Michael Bridgen
2020-12-08 16:07:07 +00:00
parent 22a5ac7f0f
commit 45240bdb71
54 changed files with 275 additions and 276 deletions

View File

@@ -22,18 +22,17 @@ import (
"github.com/spf13/cobra"
)
const createAutoLong = `
The create auto sub-cmmands works with automation objects; that is,
const createImageLong = `
The create image sub-commands work with image automation objects; that is,
object controlling updates to git based on e.g., new container images
being available.`
var createAutoCmd = &cobra.Command{
Use: "auto",
Aliases: []string{"automation"},
Short: "Create or update resources dealing with automation",
Long: strings.TrimSpace(createAutoLong),
var createImageCmd = &cobra.Command{
Use: "image",
Short: "Create or update resources dealing with image automation",
Long: strings.TrimSpace(createImageLong),
}
func init() {
createCmd.AddCommand(createAutoCmd)
createCmd.AddCommand(createImageCmd)
}

View File

@@ -34,16 +34,16 @@ import (
"github.com/fluxcd/pkg/apis/meta"
)
var createAutoImagePolicyCmd = &cobra.Command{
Use: "image-policy <name>",
var createImagePolicyCmd = &cobra.Command{
Use: "policy <name>",
Short: "Create or update an ImagePolicy object",
Long: `The create auto image-policy command generates an ImagePolicy resource.
Long: `The create image policy command generates an ImagePolicy resource.
An ImagePolicy object calculates a "latest image" given an image
repository and a policy, e.g., semver.
The image that sorts highest according to the policy is recorded in
the status of the object.`,
RunE: createAutoImagePolicyRun}
RunE: createImagePolicyRun}
type imagePolicyFlags struct {
imageRef string
@@ -53,14 +53,14 @@ type imagePolicyFlags struct {
var imagePolicyArgs = imagePolicyFlags{}
func init() {
flags := createAutoImagePolicyCmd.Flags()
flags := createImagePolicyCmd.Flags()
flags.StringVar(&imagePolicyArgs.imageRef, "image-ref", "", "the name of an image repository object")
flags.StringVar(&imagePolicyArgs.semver, "semver", "", "a semver range to apply to tags; e.g., '1.x'")
createAutoCmd.AddCommand(createAutoImagePolicyCmd)
createImageCmd.AddCommand(createImagePolicyCmd)
}
func createAutoImagePolicyRun(cmd *cobra.Command, args []string) error {
func createImagePolicyRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("ImagePolicy name is required")
}

View File

@@ -36,12 +36,12 @@ import (
"github.com/fluxcd/pkg/apis/meta"
)
var createAutoImageRepositoryCmd = &cobra.Command{
Use: "image-repository <name>",
var createImageRepositoryCmd = &cobra.Command{
Use: "repository <name>",
Short: "Create or update an ImageRepository object",
Long: `The create auto image-repository command generates an ImageRepository resource.
Long: `The create image repository command generates an ImageRepository resource.
An ImageRepository object specifies an image repository to scan.`,
RunE: createAutoImageRepositoryRun,
RunE: createImageRepositoryRun,
}
type imageRepoFlags struct {
@@ -53,17 +53,17 @@ type imageRepoFlags struct {
var imageRepoArgs = imageRepoFlags{}
func init() {
flags := createAutoImageRepositoryCmd.Flags()
flags := createImageRepositoryCmd.Flags()
flags.StringVar(&imageRepoArgs.image, "image", "", "the image repository to scan; e.g., library/alpine")
flags.StringVar(&imageRepoArgs.secretRef, "secret-ref", "", "the name of a docker-registry secret to use for credentials")
// NB there is already a --timeout in the global flags, for
// controlling timeout on operations while e.g., creating objects.
flags.DurationVar(&imageRepoArgs.timeout, "scan-timeout", 0, "a timeout for scanning; this defaults to the interval if not set")
createAutoCmd.AddCommand(createAutoImageRepositoryCmd)
createImageCmd.AddCommand(createImageRepositoryCmd)
}
func createAutoImageRepositoryRun(cmd *cobra.Command, args []string) error {
func createImageRepositoryRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("ImageRepository name is required")
}

View File

@@ -34,13 +34,13 @@ import (
"github.com/fluxcd/pkg/apis/meta"
)
var createAutoImageUpdateCmd = &cobra.Command{
Use: "image-update <name>",
var createImageUpdateCmd = &cobra.Command{
Use: "update <name>",
Short: "Create or update an ImageUpdateAutomation object",
Long: `The create auto image-update command generates an ImageUpdateAutomation resource.
Long: `The create image update command generates an ImageUpdateAutomation resource.
An ImageUpdateAutomation object specifies an automated update to images
mentioned in YAMLs in a git repository.`,
RunE: createAutoImageUpdateRun,
RunE: createImageUpdateRun,
}
type imageUpdateFlags struct {
@@ -56,17 +56,17 @@ type imageUpdateFlags struct {
var imageUpdateArgs = imageUpdateFlags{}
func init() {
flags := createAutoImageUpdateCmd.Flags()
flags := createImageUpdateCmd.Flags()
flags.StringVar(&imageUpdateArgs.gitRepoRef, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream git repository")
flags.StringVar(&imageUpdateArgs.branch, "branch", "", "the branch to push commits to")
flags.StringVar(&imageUpdateArgs.commitTemplate, "commit-template", "", "a template for commit messages")
flags.StringVar(&imageUpdateArgs.authorName, "author-name", "", "the name to use for commit author")
flags.StringVar(&imageUpdateArgs.authorEmail, "author-email", "", "the email to use for commit author")
createAutoCmd.AddCommand(createAutoImageUpdateCmd)
createImageCmd.AddCommand(createImageUpdateCmd)
}
func createAutoImageUpdateRun(cmd *cobra.Command, args []string) error {
func createImageUpdateRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("ImageUpdateAutomation name is required")
}

View File

@@ -20,12 +20,12 @@ import (
"github.com/spf13/cobra"
)
var getAutoCmd = &cobra.Command{
Use: "auto",
Short: "Get automation statuses",
Long: "The get auto sub-commands print the statuses of the automation objects.",
var exportImageCmd = &cobra.Command{
Use: "image",
Short: "Export image automation objects",
Long: "The export image sub-commands export image automation objects in YAML format.",
}
func init() {
getCmd.AddCommand(getAutoCmd)
exportCmd.AddCommand(exportImageCmd)
}

View File

@@ -24,14 +24,14 @@ import (
)
var exportImagePolicyCmd = &cobra.Command{
Use: "image-policy [name]",
Use: "policy [name]",
Short: "Export ImagePolicy resources in YAML format",
Long: "The export image-policy command exports one or all ImagePolicy resources in YAML format.",
Long: "The export image policy command exports one or all ImagePolicy resources in YAML format.",
Example: ` # Export all ImagePolicy resources
flux export auto image-policy --all > image-policies.yaml
flux export image policy --all > image-policies.yaml
# Export a specific policy
flux export auto image-policy alpine1x > alpine1x.yaml
flux export image policy alpine1x > alpine1x.yaml
`,
RunE: exportCommand{
object: imagePolicyAdapter{&imagev1.ImagePolicy{}},
@@ -40,7 +40,7 @@ var exportImagePolicyCmd = &cobra.Command{
}
func init() {
exportAutoCmd.AddCommand(exportImagePolicyCmd)
exportImageCmd.AddCommand(exportImagePolicyCmd)
}
// Export returns a ImagePolicy value which has extraneous information

View File

@@ -24,14 +24,14 @@ import (
)
var exportImageRepositoryCmd = &cobra.Command{
Use: "image-repository [name]",
Use: "repository [name]",
Short: "Export ImageRepository resources in YAML format",
Long: "The export image-repository command exports one or all ImageRepository resources in YAML format.",
Long: "The export image repository command exports one or all ImageRepository resources in YAML format.",
Example: ` # Export all ImageRepository resources
flux export auto image-repository --all > image-repositories.yaml
flux export image repository --all > image-repositories.yaml
# Export a Provider
flux export auto image-repository alpine > alpine.yaml
# Export a specific ImageRepository resource
flux export image repository alpine > alpine.yaml
`,
RunE: exportCommand{
object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
@@ -40,7 +40,7 @@ var exportImageRepositoryCmd = &cobra.Command{
}
func init() {
exportAutoCmd.AddCommand(exportImageRepositoryCmd)
exportImageCmd.AddCommand(exportImageRepositoryCmd)
}
func exportImageRepository(repo *imagev1.ImageRepository) interface{} {

View File

@@ -24,14 +24,14 @@ import (
)
var exportImageUpdateCmd = &cobra.Command{
Use: "image-update [name]",
Use: "update [name]",
Short: "Export ImageUpdateAutomation resources in YAML format",
Long: "The export image-update command exports one or all ImageUpdateAutomation resources in YAML format.",
Long: "The export image update command exports one or all ImageUpdateAutomation resources in YAML format.",
Example: ` # Export all ImageUpdateAutomation resources
flux export auto image-update --all > updates.yaml
flux export image update --all > updates.yaml
# Export a specific automation
flux export auto image-update latest-images > latest.yaml
flux export image update latest-images > latest.yaml
`,
RunE: exportCommand{
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
@@ -40,7 +40,7 @@ var exportImageUpdateCmd = &cobra.Command{
}
func init() {
exportAutoCmd.AddCommand(exportImageUpdateCmd)
exportImageCmd.AddCommand(exportImageUpdateCmd)
}
// exportImageUpdate returns a value which has extraneous information

View File

@@ -20,12 +20,12 @@ import (
"github.com/spf13/cobra"
)
var resumeAutoCmd = &cobra.Command{
Use: "auto",
Short: "Resume automation objects",
Long: "The resume auto sub-commands resume a suspended automation object.",
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.",
}
func init() {
resumeCmd.AddCommand(resumeAutoCmd)
getCmd.AddCommand(getImageCmd)
}

View File

@@ -23,14 +23,14 @@ import (
)
var getImagePolicyCmd = &cobra.Command{
Use: "image-policy",
Short: "Get ImagePolicy statuses",
Long: "The get auto image-policy command prints the status of ImagePolicy objects.",
Use: "policy",
Short: "Get ImagePolicy status",
Long: "The get image policy command prints the status of ImagePolicy objects.",
Example: ` # List all image policies and their status
flux get auto image-policy
flux get image policy
# List image policies from all namespaces
flux get auto image-policy --all-namespaces
flux get image policy --all-namespaces
`,
RunE: getCommand{
names: imagePolicyNames,
@@ -39,7 +39,7 @@ var getImagePolicyCmd = &cobra.Command{
}
func init() {
getAutoCmd.AddCommand(getImagePolicyCmd)
getImageCmd.AddCommand(getImagePolicyCmd)
}
func (s imagePolicyListAdapter) summariseItem(i int, includeNamespace bool) []string {

View File

@@ -27,14 +27,14 @@ import (
)
var getImageRepositoryCmd = &cobra.Command{
Use: "image-repository",
Short: "Get ImageRepository statuses",
Long: "The get auto image-repository command prints the status of ImageRepository objects.",
Use: "repository",
Short: "Get ImageRepository status",
Long: "The get image repository command prints the status of ImageRepository objects.",
Example: ` # List all image repositories and their status
flux get auto image-repository
flux get image repository
# List image repositories from all namespaces
flux get auto image-repository --all-namespaces
flux get image repository --all-namespaces
`,
RunE: getCommand{
names: imageRepositoryNames,
@@ -43,7 +43,7 @@ var getImageRepositoryCmd = &cobra.Command{
}
func init() {
getAutoCmd.AddCommand(getImageRepositoryCmd)
getImageCmd.AddCommand(getImageRepositoryCmd)
}
func (s imageRepositoryListAdapter) summariseItem(i int, includeNamespace bool) []string {

View File

@@ -27,14 +27,14 @@ import (
)
var getImageUpdateCmd = &cobra.Command{
Use: "image-update",
Short: "Get ImageUpdateAutomation statuses",
Long: "The get auto image-update command prints the status of ImageUpdateAutomation objects.",
Use: "update",
Short: "Get ImageUpdateAutomation status",
Long: "The get image update command prints the status of ImageUpdateAutomation objects.",
Example: ` # List all image update automation object and their status
flux get auto image-update
flux get image update
# List image update automations from all namespaces
flux get auto image-update --all-namespaces
flux get image update --all-namespaces
`,
RunE: getCommand{
names: imageUpdateAutomationNames,
@@ -43,7 +43,7 @@ var getImageUpdateCmd = &cobra.Command{
}
func init() {
getAutoCmd.AddCommand(getImageUpdateCmd)
getImageCmd.AddCommand(getImageUpdateCmd)
}
func (s imageUpdateAutomationListAdapter) summariseItem(i int, includeNamespace bool) []string {

View File

@@ -20,12 +20,12 @@ import (
"github.com/spf13/cobra"
)
var reconcileAutoCmd = &cobra.Command{
Use: "auto",
Short: "Reconcile automation objects",
Long: "The reconcile auto sub-commands trigger a reconciliation of automation objects.",
var reconcileImageCmd = &cobra.Command{
Use: "image",
Short: "Reconcile image automation objects",
Long: "The reconcile sub-commands trigger a reconciliation of image automation objects.",
}
func init() {
reconcileCmd.AddCommand(reconcileAutoCmd)
reconcileCmd.AddCommand(reconcileImageCmd)
}

View File

@@ -25,11 +25,11 @@ import (
)
var reconcileImageRepositoryCmd = &cobra.Command{
Use: "image-repository [name]",
Use: "repository [name]",
Short: "Reconcile an ImageRepository",
Long: `The reconcile auto image-repository command triggers a reconciliation of an ImageRepository resource and waits for it to finish.`,
Long: `The reconcile image repository command triggers a reconciliation of an ImageRepository resource and waits for it to finish.`,
Example: ` # Trigger an scan for an existing image repository
flux reconcile auto image-repository alpine
flux reconcile image repository alpine
`,
RunE: reconcileCommand{
names: imageRepositoryNames,
@@ -38,7 +38,7 @@ var reconcileImageRepositoryCmd = &cobra.Command{
}
func init() {
reconcileAutoCmd.AddCommand(reconcileImageRepositoryCmd)
reconcileImageCmd.AddCommand(reconcileImageRepositoryCmd)
}
func (obj imageRepositoryAdapter) lastHandledReconcileRequest() string {

View File

@@ -27,11 +27,11 @@ import (
)
var reconcileImageUpdateCmd = &cobra.Command{
Use: "image-update [name]",
Use: "update [name]",
Short: "Reconcile an ImageUpdateAutomation",
Long: `The reconcile auto image-update command triggers a reconciliation of an ImageUpdateAutomation resource and waits for it to finish.`,
Long: `The reconcile image update command triggers a reconciliation of an ImageUpdateAutomation resource and waits for it to finish.`,
Example: ` # Trigger an automation run for an existing image update automation
flux reconcile auto image-update latest-images
flux reconcile image update latest-images
`,
RunE: reconcileCommand{
names: imageUpdateAutomationNames,
@@ -40,7 +40,7 @@ var reconcileImageUpdateCmd = &cobra.Command{
}
func init() {
reconcileAutoCmd.AddCommand(reconcileImageUpdateCmd)
reconcileImageCmd.AddCommand(reconcileImageUpdateCmd)
}
func (obj imageUpdateAutomationAdapter) suspended() bool {

View File

@@ -20,12 +20,12 @@ import (
"github.com/spf13/cobra"
)
var exportAutoCmd = &cobra.Command{
Use: "auto",
Short: "Export automation objects",
Long: "The export auto sub-commands export automation object in YAML format.",
var resumeImageCmd = &cobra.Command{
Use: "image",
Short: "Resume image automation objects",
Long: "The resume image sub-commands resume suspended image automation objects.",
}
func init() {
exportCmd.AddCommand(exportAutoCmd)
resumeCmd.AddCommand(resumeImageCmd)
}

View File

@@ -23,11 +23,11 @@ import (
)
var resumeImageRepositoryCmd = &cobra.Command{
Use: "image-repository [name]",
Use: "repository [name]",
Short: "Resume a suspended ImageRepository",
Long: `The resume command marks a previously suspended ImageRepository resource for reconciliation and waits for it to finish.`,
Example: ` # Resume reconciliation for an existing ImageRepository
flux resume auto image-repository alpine
flux resume image repository alpine
`,
RunE: resumeCommand{
names: imageRepositoryNames,
@@ -36,7 +36,7 @@ var resumeImageRepositoryCmd = &cobra.Command{
}
func init() {
resumeAutoCmd.AddCommand(resumeImageRepositoryCmd)
resumeImageCmd.AddCommand(resumeImageRepositoryCmd)
}
func (obj imageRepositoryAdapter) getObservedGeneration() int64 {

View File

@@ -23,11 +23,11 @@ import (
)
var resumeImageUpdateCmd = &cobra.Command{
Use: "image-update [name]",
Use: "update [name]",
Short: "Resume a suspended ImageUpdateAutomation",
Long: `The resume command marks a previously suspended ImageUpdateAutomation resource for reconciliation and waits for it to finish.`,
Example: ` # Resume reconciliation for an existing ImageUpdateAutomation
flux resume auto image-update latest-images
flux resume image update latest-images
`,
RunE: resumeCommand{
names: imageUpdateAutomationNames,
@@ -36,7 +36,7 @@ var resumeImageUpdateCmd = &cobra.Command{
}
func init() {
resumeAutoCmd.AddCommand(resumeImageUpdateCmd)
resumeImageCmd.AddCommand(resumeImageUpdateCmd)
}
func (obj imageUpdateAutomationAdapter) setUnsuspended() {

View File

@@ -1,31 +0,0 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"github.com/spf13/cobra"
)
var suspendAutoCmd = &cobra.Command{
Use: "auto",
Short: "Suspend automation objects",
Long: "The suspend auto sub-commands suspend the reconciliation of an automation object.",
}
func init() {
suspendCmd.AddCommand(suspendAutoCmd)
}

31
cmd/flux/suspend_image.go Normal file
View File

@@ -0,0 +1,31 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"github.com/spf13/cobra"
)
var suspendImageCmd = &cobra.Command{
Use: "image",
Short: "Suspend image automation objects",
Long: "The suspend image sub-commands suspend the reconciliation of an image automation object.",
}
func init() {
suspendCmd.AddCommand(suspendImageCmd)
}

View File

@@ -23,11 +23,11 @@ import (
)
var suspendImageRepositoryCmd = &cobra.Command{
Use: "image-repository [name]",
Use: "repository [name]",
Short: "Suspend reconciliation of an ImageRepository",
Long: "The suspend command disables the reconciliation of a ImageRepository resource.",
Long: "The suspend image repository command disables the reconciliation of a ImageRepository resource.",
Example: ` # Suspend reconciliation for an existing ImageRepository
flux suspend auto image-repository alpine
flux suspend image repository alpine
`,
RunE: suspendCommand{
names: imageRepositoryNames,
@@ -36,7 +36,7 @@ var suspendImageRepositoryCmd = &cobra.Command{
}
func init() {
suspendAutoCmd.AddCommand(suspendImageRepositoryCmd)
suspendImageCmd.AddCommand(suspendImageRepositoryCmd)
}
func (obj imageRepositoryAdapter) isSuspended() bool {

View File

@@ -23,11 +23,11 @@ import (
)
var suspendImageUpdateCmd = &cobra.Command{
Use: "image-update [name]",
Use: "update [name]",
Short: "Suspend reconciliation of an ImageUpdateAutomation",
Long: "The suspend command disables the reconciliation of a ImageUpdateAutomation resource.",
Long: "The suspend image update command disables the reconciliation of a ImageUpdateAutomation resource.",
Example: ` # Suspend reconciliation for an existing ImageUpdateAutomation
flux suspend auto image-update latest-images
flux suspend image update latest-images
`,
RunE: suspendCommand{
names: imageUpdateAutomationNames,
@@ -36,7 +36,7 @@ var suspendImageUpdateCmd = &cobra.Command{
}
func init() {
suspendAutoCmd.AddCommand(suspendImageUpdateCmd)
suspendImageCmd.AddCommand(suspendImageUpdateCmd)
}
func (update imageUpdateAutomationAdapter) isSuspended() bool {