1
0
mirror of synced 2026-03-03 19:56:57 +00:00

Compare commits

...

10 Commits

Author SHA1 Message Date
Stefan Prodan
3a76c26822 Merge pull request #1844 from fluxcd/fail-manifests-build-properly
Update Makefile target in release workflow
2021-09-20 18:33:05 +03:00
Michael Bridgen
9d9fff5796 Update Makefile target in release workflow
There's another location which uses the "manifests directory" target
directly, but isn't run when testing a PR: the release workflow.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-20 16:06:01 +01:00
Stefan Prodan
0a92c61b09 Merge pull request #1830 from makkes/fix-create-hr
fix: don't set 'Install' field by default in 'create hr'
2021-09-20 17:11:30 +03:00
Max Jonas Werner
546be76f55 fix: don't set 'Install' field by default in 'create hr'
This fixes the case where you create a HelmRelease with `--export` and
the `install: {}` field being there, adding no value to the manifest.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-20 14:42:29 +02:00
Stefan Prodan
d770f3f53f Merge pull request #1838 from superbrothers/dynamic-completions
Add dynamic completion suppport
2021-09-20 09:42:54 +03:00
Kazuki Suda
254cc131ae Add dynamic completion suppport
This commit adds dynamic completion support for the following commands
and flags:

- `flux delete ...` command
- `flux export ...` command
- `flux get ...` command
- `flux reconcile ...` command
- `flux resume ...` command
- `flux suspend ...` command
- `--namespace` flag
- `--context` flag

Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-09-18 17:27:47 +09:00
Stefan Prodan
70509ffcb4 Merge pull request #1833 from superbrothers/fix-971
Fix `flux completion zsh` to work with `source` only
2021-09-18 11:14:44 +03:00
Kazuki Suda
4cc2326c7f Fix flux completion zsh to work with source only
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-09-17 17:49:47 +09:00
Michael Bridgen
0133caaec4 Merge pull request #1828 from fluxcd/fail-manifests-build-properly
Use a file to record successful manifests build
2021-09-16 14:33:58 +01:00
Michael Bridgen
7ae4f28920 Use a file to record successful manifests build
Using the directory cmd/flux/manifests as a prerequisite causes a
problem: if the script that creates the files within fails, the next
invocation of make will see the directory and assume it
succeeded. Since the executable expects certain files to be present,
but they are not explicit prerequisites of the recipe for building the
binary, this results in a successful build but a broken `flux`
executable.

Instead, depend on a file that's explicitly updated when the script
has succeeded, and which itself depends on the inputs.

A couple of the CI workflows run

    make cmd/flux/manifests

before doing other things, presumably as a way to avoid running the
whole test suite in a CI pipeline for some purpose other than testing,
so these needed changing as well.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-16 14:03:13 +01:00
74 changed files with 179 additions and 14 deletions

View File

@@ -33,7 +33,7 @@ jobs:
uses: fluxcd/pkg//actions/kustomize@main uses: fluxcd/pkg//actions/kustomize@main
- name: Build - name: Build
run: | run: |
make cmd/flux/manifests make cmd/flux/.manifests.done
go build -o /tmp/flux ./cmd/flux go build -o /tmp/flux ./cmd/flux
- name: Set outputs - name: Set outputs
id: vars id: vars

View File

@@ -50,7 +50,7 @@ jobs:
uses: fluxcd/pkg//actions/kustomize@main uses: fluxcd/pkg//actions/kustomize@main
- name: Generate manifests - name: Generate manifests
run: | run: |
make cmd/flux/manifests make cmd/flux/.manifests.done
./manifests/scripts/bundle.sh "" ./output manifests.tar.gz ./manifests/scripts/bundle.sh "" ./output manifests.tar.gz
kustomize build ./manifests/install > ./output/install.yaml kustomize build ./manifests/install > ./output/install.yaml
- name: Build CRDs - name: Build CRDs

View File

@@ -31,7 +31,7 @@ jobs:
uses: fluxcd/pkg//actions/kustomize@main uses: fluxcd/pkg//actions/kustomize@main
- name: Build manifests - name: Build manifests
run: | run: |
make cmd/flux/manifests make cmd/flux/.manifests.done
- name: Run Snyk to check for vulnerabilities - name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master uses: snyk/actions/golang@master
continue-on-error: true continue-on-error: true

1
.gitignore vendored
View File

@@ -19,6 +19,7 @@ dist/
bin/ bin/
output/ output/
cmd/flux/manifests/ cmd/flux/manifests/
cmd/flux/.manifests.done
# Docs # Docs
site/ site/

View File

@@ -1,5 +1,5 @@
VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | head -n 1 | tr -d '"') VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | head -n 1 | tr -d '"')
EMBEDDED_MANIFESTS_TARGET=cmd/flux/manifests EMBEDDED_MANIFESTS_TARGET=cmd/flux/.manifests.done
TEST_KUBECONFIG?=/tmp/flux-e2e-test-kubeconfig TEST_KUBECONFIG?=/tmp/flux-e2e-test-kubeconfig
ENVTEST_BIN_VERSION?=latest ENVTEST_BIN_VERSION?=latest
KUBEBUILDER_ASSETS?="$(shell $(SETUP_ENVTEST) use -i $(ENVTEST_BIN_VERSION) -p path)" KUBEBUILDER_ASSETS?="$(shell $(SETUP_ENVTEST) use -i $(ENVTEST_BIN_VERSION) -p path)"
@@ -46,6 +46,7 @@ test-with-kind: setup-envtest
$(EMBEDDED_MANIFESTS_TARGET): $(call rwildcard,manifests/,*.yaml *.json) $(EMBEDDED_MANIFESTS_TARGET): $(call rwildcard,manifests/,*.yaml *.json)
./manifests/scripts/bundle.sh ./manifests/scripts/bundle.sh
touch $@
build: $(EMBEDDED_MANIFESTS_TARGET) build: $(EMBEDDED_MANIFESTS_TARGET)
CGO_ENABLED=0 go build -ldflags="-s -w -X main.VERSION=$(VERSION)" -o ./bin/flux ./cmd/flux CGO_ENABLED=0 go build -ldflags="-s -w -X main.VERSION=$(VERSION)" -o ./bin/flux ./cmd/flux

View File

@@ -17,7 +17,18 @@ limitations under the License.
package main package main
import ( import (
"context"
"strings"
"github.com/fluxcd/flux2/internal/utils"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery"
memory "k8s.io/client-go/discovery/cached"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/restmapper"
) )
var completionCmd = &cobra.Command{ var completionCmd = &cobra.Command{
@@ -29,3 +40,77 @@ var completionCmd = &cobra.Command{
func init() { func init() {
rootCmd.AddCommand(completionCmd) rootCmd.AddCommand(completionCmd)
} }
func contextsCompletionFunc(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
rawConfig, err := utils.ClientConfig(rootArgs.kubeconfig, rootArgs.kubecontext).RawConfig()
if err != nil {
return completionError(err)
}
var comps []string
for name := range rawConfig.Contexts {
if strings.HasPrefix(name, toComplete) {
comps = append(comps, name)
}
}
return comps, cobra.ShellCompDirectiveNoFileComp
}
func resourceNamesCompletionFunc(gvk schema.GroupVersionKind) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
cfg, err := utils.KubeConfig(rootArgs.kubeconfig, rootArgs.kubecontext)
if err != nil {
return completionError(err)
}
dc, err := discovery.NewDiscoveryClientForConfig(cfg)
if err != nil {
return completionError(err)
}
mapper := restmapper.NewDeferredDiscoveryRESTMapper(memory.NewMemCacheClient(dc))
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
return completionError(err)
}
client, err := dynamic.NewForConfig(cfg)
if err != nil {
return completionError(err)
}
var dr dynamic.ResourceInterface
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
dr = client.Resource(mapping.Resource).Namespace(rootArgs.namespace)
} else {
dr = client.Resource(mapping.Resource)
}
list, err := dr.List(ctx, metav1.ListOptions{})
if err != nil {
return completionError(err)
}
var comps []string
for _, item := range list.Items {
name := item.GetName()
if strings.HasPrefix(name, toComplete) {
comps = append(comps, name)
}
}
return comps, cobra.ShellCompDirectiveNoFileComp
}
}
func completionError(err error) ([]string, cobra.ShellCompDirective) {
cobra.CompError(err.Error())
return nil, cobra.ShellCompDirectiveError
}

View File

@@ -17,6 +17,7 @@ limitations under the License.
package main package main
import ( import (
"fmt"
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -27,12 +28,12 @@ var completionZshCmd = &cobra.Command{
Short: "Generates zsh completion scripts", Short: "Generates zsh completion scripts",
Example: `To load completion run Example: `To load completion run
. <(flux completion zsh) && compdef _flux flux . <(flux completion zsh)
To configure your zsh shell to load completions for each session add to your zshrc To configure your zsh shell to load completions for each session add to your zshrc
# ~/.zshrc or ~/.profile # ~/.zshrc or ~/.profile
command -v flux >/dev/null && . <(flux completion zsh) && compdef _flux flux command -v flux >/dev/null && . <(flux completion zsh)
or write a cached file in one of the completion directories in your ${fpath}: or write a cached file in one of the completion directories in your ${fpath}:
@@ -43,6 +44,8 @@ mv _flux ~/.oh-my-zsh/completions # oh-my-zsh
mv _flux ~/.zprezto/modules/completion/external/src/ # zprezto`, mv _flux ~/.zprezto/modules/completion/external/src/ # zprezto`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenZshCompletion(os.Stdout) rootCmd.GenZshCompletion(os.Stdout)
// Cobra doesn't source zsh completion file, explicitly doing it here
fmt.Println("compdef _flux flux")
}, },
} }

View File

@@ -182,13 +182,16 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
}, },
}, },
}, },
Install: &helmv2.Install{
CreateNamespace: helmReleaseArgs.createNamespace,
},
Suspend: false, Suspend: false,
}, },
} }
if helmReleaseArgs.createNamespace {
helmRelease.Spec.Install = &helmv2.Install{
CreateNamespace: helmReleaseArgs.createNamespace,
}
}
if helmReleaseArgs.saName != "" { if helmReleaseArgs.saName != "" {
helmRelease.Spec.ServiceAccountName = helmReleaseArgs.saName helmRelease.Spec.ServiceAccountName = helmReleaseArgs.saName
} }

View File

@@ -28,6 +28,7 @@ var deleteAlertCmd = &cobra.Command{
Long: "The delete alert command removes the given Alert from the cluster.", Long: "The delete alert command removes the given Alert from the cluster.",
Example: ` # Delete an Alert and the Kubernetes resources created by it Example: ` # Delete an Alert and the Kubernetes resources created by it
flux delete alert main`, flux delete alert main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: alertType, apiType: alertType,
object: universalAdapter{&notificationv1.Alert{}}, object: universalAdapter{&notificationv1.Alert{}},

View File

@@ -28,6 +28,7 @@ var deleteAlertProviderCmd = &cobra.Command{
Long: "The delete alert-provider command removes the given Provider from the cluster.", Long: "The delete alert-provider command removes the given Provider from the cluster.",
Example: ` # Delete a Provider and the Kubernetes resources created by it Example: ` # Delete a Provider and the Kubernetes resources created by it
flux delete alert-provider slack`, flux delete alert-provider slack`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: alertProviderType, apiType: alertProviderType,
object: universalAdapter{&notificationv1.Provider{}}, object: universalAdapter{&notificationv1.Provider{}},

View File

@@ -29,6 +29,7 @@ var deleteHelmReleaseCmd = &cobra.Command{
Long: "The delete helmrelease command removes the given HelmRelease from the cluster.", Long: "The delete helmrelease command removes the given HelmRelease from the cluster.",
Example: ` # Delete a Helm release and the Kubernetes resources created by it Example: ` # Delete a Helm release and the Kubernetes resources created by it
flux delete hr podinfo`, flux delete hr podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: helmReleaseType, apiType: helmReleaseType,
object: universalAdapter{&helmv2.HelmRelease{}}, object: universalAdapter{&helmv2.HelmRelease{}},

View File

@@ -28,6 +28,7 @@ var deleteImagePolicyCmd = &cobra.Command{
Long: "The delete image policy command deletes the given ImagePolicy from the cluster.", Long: "The delete image policy command deletes the given ImagePolicy from the cluster.",
Example: ` # Delete an image policy Example: ` # Delete an image policy
flux delete image policy alpine3.x`, flux delete image policy alpine3.x`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: imagePolicyType, apiType: imagePolicyType,
object: universalAdapter{&imagev1.ImagePolicy{}}, object: universalAdapter{&imagev1.ImagePolicy{}},

View File

@@ -28,6 +28,7 @@ var deleteImageRepositoryCmd = &cobra.Command{
Long: "The delete image repository command deletes the given ImageRepository from the cluster.", Long: "The delete image repository command deletes the given ImageRepository from the cluster.",
Example: ` # Delete an image repository Example: ` # Delete an image repository
flux delete image repository alpine`, flux delete image repository alpine`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: imageRepositoryType, apiType: imageRepositoryType,
object: universalAdapter{&imagev1.ImageRepository{}}, object: universalAdapter{&imagev1.ImageRepository{}},

View File

@@ -28,6 +28,7 @@ var deleteImageUpdateCmd = &cobra.Command{
Long: "The delete image update command deletes the given ImageUpdateAutomation from the cluster.", Long: "The delete image update command deletes the given ImageUpdateAutomation from the cluster.",
Example: ` # Delete an image update automation Example: ` # Delete an image update automation
flux delete image update latest-images`, flux delete image update latest-images`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: imageUpdateAutomationType, apiType: imageUpdateAutomationType,
object: universalAdapter{&autov1.ImageUpdateAutomation{}}, object: universalAdapter{&autov1.ImageUpdateAutomation{}},

View File

@@ -29,6 +29,7 @@ var deleteKsCmd = &cobra.Command{
Long: "The delete kustomization command deletes the given Kustomization from the cluster.", Long: "The delete kustomization command deletes the given Kustomization from the cluster.",
Example: ` # Delete a kustomization and the Kubernetes resources created by it Example: ` # Delete a kustomization and the Kubernetes resources created by it
flux delete kustomization podinfo`, flux delete kustomization podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: kustomizationType, apiType: kustomizationType,
object: universalAdapter{&kustomizev1.Kustomization{}}, object: universalAdapter{&kustomizev1.Kustomization{}},

View File

@@ -28,6 +28,7 @@ var deleteReceiverCmd = &cobra.Command{
Long: "The delete receiver command removes the given Receiver from the cluster.", Long: "The delete receiver command removes the given Receiver from the cluster.",
Example: ` # Delete an Receiver and the Kubernetes resources created by it Example: ` # Delete an Receiver and the Kubernetes resources created by it
flux delete receiver main`, flux delete receiver main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: receiverType, apiType: receiverType,
object: universalAdapter{&notificationv1.Receiver{}}, object: universalAdapter{&notificationv1.Receiver{}},

View File

@@ -28,6 +28,7 @@ var deleteSourceBucketCmd = &cobra.Command{
Long: "The delete source bucket command deletes the given Bucket from the cluster.", Long: "The delete source bucket command deletes the given Bucket from the cluster.",
Example: ` # Delete a Bucket source Example: ` # Delete a Bucket source
flux delete source bucket podinfo`, flux delete source bucket podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: bucketType, apiType: bucketType,
object: universalAdapter{&sourcev1.Bucket{}}, object: universalAdapter{&sourcev1.Bucket{}},

View File

@@ -28,6 +28,7 @@ var deleteSourceGitCmd = &cobra.Command{
Long: "The delete source git command deletes the given GitRepository from the cluster.", Long: "The delete source git command deletes the given GitRepository from the cluster.",
Example: ` # Delete a Git repository Example: ` # Delete a Git repository
flux delete source git podinfo`, flux delete source git podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: gitRepositoryType, apiType: gitRepositoryType,
object: universalAdapter{&sourcev1.GitRepository{}}, object: universalAdapter{&sourcev1.GitRepository{}},

View File

@@ -28,6 +28,7 @@ var deleteSourceHelmCmd = &cobra.Command{
Long: "The delete source helm command deletes the given HelmRepository from the cluster.", Long: "The delete source helm command deletes the given HelmRepository from the cluster.",
Example: ` # Delete a Helm repository Example: ` # Delete a Helm repository
flux delete source helm podinfo`, flux delete source helm podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: deleteCommand{ RunE: deleteCommand{
apiType: helmRepositoryType, apiType: helmRepositoryType,
object: universalAdapter{&sourcev1.HelmRepository{}}, object: universalAdapter{&sourcev1.HelmRepository{}},

View File

@@ -32,6 +32,7 @@ var exportAlertCmd = &cobra.Command{
# Export a Alert # Export a Alert
flux export alert main > main.yaml`, flux export alert main > main.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: exportCommand{ RunE: exportCommand{
object: alertAdapter{&notificationv1.Alert{}}, object: alertAdapter{&notificationv1.Alert{}},
list: alertListAdapter{&notificationv1.AlertList{}}, list: alertListAdapter{&notificationv1.AlertList{}},

View File

@@ -32,6 +32,7 @@ var exportAlertProviderCmd = &cobra.Command{
# Export a Provider # Export a Provider
flux export alert-provider slack > slack.yaml`, flux export alert-provider slack > slack.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
RunE: exportCommand{ RunE: exportCommand{
object: alertProviderAdapter{&notificationv1.Provider{}}, object: alertProviderAdapter{&notificationv1.Provider{}},
list: alertProviderListAdapter{&notificationv1.ProviderList{}}, list: alertProviderListAdapter{&notificationv1.ProviderList{}},

View File

@@ -33,6 +33,7 @@ var exportHelmReleaseCmd = &cobra.Command{
# Export a HelmRelease # Export a HelmRelease
flux export hr my-app > app-release.yaml`, flux export hr my-app > app-release.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: exportCommand{ RunE: exportCommand{
object: helmReleaseAdapter{&helmv2.HelmRelease{}}, object: helmReleaseAdapter{&helmv2.HelmRelease{}},
list: helmReleaseListAdapter{&helmv2.HelmReleaseList{}}, list: helmReleaseListAdapter{&helmv2.HelmReleaseList{}},

View File

@@ -32,6 +32,7 @@ var exportImagePolicyCmd = &cobra.Command{
# Export a specific policy # Export a specific policy
flux export image policy alpine1x > alpine1x.yaml`, flux export image policy alpine1x > alpine1x.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
RunE: exportCommand{ RunE: exportCommand{
object: imagePolicyAdapter{&imagev1.ImagePolicy{}}, object: imagePolicyAdapter{&imagev1.ImagePolicy{}},
list: imagePolicyListAdapter{&imagev1.ImagePolicyList{}}, list: imagePolicyListAdapter{&imagev1.ImagePolicyList{}},

View File

@@ -32,6 +32,7 @@ var exportImageRepositoryCmd = &cobra.Command{
# Export a specific ImageRepository resource # Export a specific ImageRepository resource
flux export image repository alpine > alpine.yaml`, flux export image repository alpine > alpine.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: exportCommand{ RunE: exportCommand{
object: imageRepositoryAdapter{&imagev1.ImageRepository{}}, object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}}, list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}},

View File

@@ -32,6 +32,7 @@ var exportImageUpdateCmd = &cobra.Command{
# Export a specific automation # Export a specific automation
flux export image update latest-images > latest.yaml`, flux export image update latest-images > latest.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: exportCommand{ RunE: exportCommand{
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}}, object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
list: imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}}, list: imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}},

View File

@@ -33,6 +33,7 @@ var exportKsCmd = &cobra.Command{
# Export a Kustomization # Export a Kustomization
flux export kustomization my-app > kustomization.yaml`, flux export kustomization my-app > kustomization.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: exportCommand{ RunE: exportCommand{
object: kustomizationAdapter{&kustomizev1.Kustomization{}}, object: kustomizationAdapter{&kustomizev1.Kustomization{}},
list: kustomizationListAdapter{&kustomizev1.KustomizationList{}}, list: kustomizationListAdapter{&kustomizev1.KustomizationList{}},

View File

@@ -32,6 +32,7 @@ var exportReceiverCmd = &cobra.Command{
# Export a Receiver # Export a Receiver
flux export receiver main > main.yaml`, flux export receiver main > main.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: exportCommand{ RunE: exportCommand{
list: receiverListAdapter{&notificationv1.ReceiverList{}}, list: receiverListAdapter{&notificationv1.ReceiverList{}},
object: receiverAdapter{&notificationv1.Receiver{}}, object: receiverAdapter{&notificationv1.Receiver{}},

View File

@@ -33,6 +33,7 @@ var exportSourceBucketCmd = &cobra.Command{
# Export a Bucket source including the static credentials # Export a Bucket source including the static credentials
flux export source bucket my-bucket --with-credentials > source.yaml`, flux export source bucket my-bucket --with-credentials > source.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: exportWithSecretCommand{ RunE: exportWithSecretCommand{
list: bucketListAdapter{&sourcev1.BucketList{}}, list: bucketListAdapter{&sourcev1.BucketList{}},
object: bucketAdapter{&sourcev1.Bucket{}}, object: bucketAdapter{&sourcev1.Bucket{}},

View File

@@ -33,6 +33,7 @@ var exportSourceGitCmd = &cobra.Command{
# Export a GitRepository source including the SSH key pair or basic auth credentials # Export a GitRepository source including the SSH key pair or basic auth credentials
flux export source git my-private-repo --with-credentials > source.yaml`, flux export source git my-private-repo --with-credentials > source.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: exportWithSecretCommand{ RunE: exportWithSecretCommand{
object: gitRepositoryAdapter{&sourcev1.GitRepository{}}, object: gitRepositoryAdapter{&sourcev1.GitRepository{}},
list: gitRepositoryListAdapter{&sourcev1.GitRepositoryList{}}, list: gitRepositoryListAdapter{&sourcev1.GitRepositoryList{}},

View File

@@ -33,6 +33,7 @@ var exportSourceHelmCmd = &cobra.Command{
# Export a HelmRepository source including the basic auth credentials # Export a HelmRepository source including the basic auth credentials
flux export source helm my-private-repo --with-credentials > source.yaml`, flux export source helm my-private-repo --with-credentials > source.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: exportWithSecretCommand{ RunE: exportWithSecretCommand{
list: helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}}, list: helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}},
object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}},

View File

@@ -34,6 +34,7 @@ var getAlertCmd = &cobra.Command{
Long: "The get alert command prints the statuses of the resources.", Long: "The get alert command prints the statuses of the resources.",
Example: ` # List all Alerts and their status Example: ` # List all Alerts and their status
flux get alerts`, flux get alerts`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: alertType, apiType: alertType,

View File

@@ -32,6 +32,7 @@ var getAlertProviderCmd = &cobra.Command{
Long: "The get alert-provider command prints the statuses of the resources.", Long: "The get alert-provider command prints the statuses of the resources.",
Example: ` # List all Providers and their status Example: ` # List all Providers and their status
flux get alert-providers`, flux get alert-providers`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: alertProviderType, apiType: alertProviderType,

View File

@@ -33,6 +33,7 @@ var getHelmReleaseCmd = &cobra.Command{
Long: "The get helmreleases command prints the statuses of the resources.", Long: "The get helmreleases command prints the statuses of the resources.",
Example: ` # List all Helm releases and their status Example: ` # List all Helm releases and their status
flux get helmreleases`, flux get helmreleases`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: helmReleaseType, apiType: helmReleaseType,

View File

@@ -34,6 +34,7 @@ var getImagePolicyCmd = &cobra.Command{
# List image policies from all namespaces # List image policies from all namespaces
flux get image policy --all-namespaces`, flux get image policy --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: imagePolicyType, apiType: imagePolicyType,

View File

@@ -37,6 +37,7 @@ var getImageRepositoryCmd = &cobra.Command{
# List image repositories from all namespaces # List image repositories from all namespaces
flux get image repository --all-namespaces`, flux get image repository --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: imageRepositoryType, apiType: imageRepositoryType,

View File

@@ -37,6 +37,7 @@ var getImageUpdateCmd = &cobra.Command{
# List image update automations from all namespaces # List image update automations from all namespaces
flux get image update --all-namespaces`, flux get image update --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: imageUpdateAutomationType, apiType: imageUpdateAutomationType,

View File

@@ -34,6 +34,7 @@ var getKsCmd = &cobra.Command{
Long: "The get kustomizations command prints the statuses of the resources.", Long: "The get kustomizations command prints the statuses of the resources.",
Example: ` # List all kustomizations and their status Example: ` # List all kustomizations and their status
flux get kustomizations`, flux get kustomizations`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: kustomizationType, apiType: kustomizationType,

View File

@@ -34,6 +34,7 @@ var getReceiverCmd = &cobra.Command{
Long: "The get receiver command prints the statuses of the resources.", Long: "The get receiver command prints the statuses of the resources.",
Example: ` # List all Receiver and their status Example: ` # List all Receiver and their status
flux get receivers`, flux get receivers`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: receiverType, apiType: receiverType,

View File

@@ -36,6 +36,7 @@ var getSourceBucketCmd = &cobra.Command{
# List buckets from all namespaces # List buckets from all namespaces
flux get sources helm --all-namespaces`, flux get sources helm --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: bucketType, apiType: bucketType,

View File

@@ -36,6 +36,7 @@ var getSourceHelmChartCmd = &cobra.Command{
# List Helm charts from all namespaces # List Helm charts from all namespaces
flux get sources chart --all-namespaces`, flux get sources chart --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmChartKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: helmChartType, apiType: helmChartType,

View File

@@ -36,6 +36,7 @@ var getSourceGitCmd = &cobra.Command{
# List Git repositories from all namespaces # List Git repositories from all namespaces
flux get sources git --all-namespaces`, flux get sources git --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: gitRepositoryType, apiType: gitRepositoryType,

View File

@@ -36,6 +36,7 @@ var getSourceHelmCmd = &cobra.Command{
# List Helm repositories from all namespaces # List Helm repositories from all namespaces
flux get sources helm --all-namespaces`, flux get sources helm --all-namespaces`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
get := getCommand{ get := getCommand{
apiType: helmRepositoryType, apiType: helmRepositoryType,

View File

@@ -23,6 +23,7 @@ import (
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth" _ "k8s.io/client-go/plugin/pkg/client/auth"
"github.com/fluxcd/flux2/pkg/manifestgen/install" "github.com/fluxcd/flux2/pkg/manifestgen/install"
@@ -108,11 +109,15 @@ var rootArgs = NewRootFlags()
func init() { func init() {
rootCmd.PersistentFlags().StringVarP(&rootArgs.namespace, "namespace", "n", rootArgs.defaults.Namespace, "the namespace scope for this operation") rootCmd.PersistentFlags().StringVarP(&rootArgs.namespace, "namespace", "n", rootArgs.defaults.Namespace, "the namespace scope for this operation")
rootCmd.RegisterFlagCompletionFunc("namespace", resourceNamesCompletionFunc(corev1.SchemeGroupVersion.WithKind("Namespace")))
rootCmd.PersistentFlags().DurationVar(&rootArgs.timeout, "timeout", 5*time.Minute, "timeout for this operation") rootCmd.PersistentFlags().DurationVar(&rootArgs.timeout, "timeout", 5*time.Minute, "timeout for this operation")
rootCmd.PersistentFlags().BoolVar(&rootArgs.verbose, "verbose", false, "print generated objects") rootCmd.PersistentFlags().BoolVar(&rootArgs.verbose, "verbose", false, "print generated objects")
rootCmd.PersistentFlags().StringVarP(&rootArgs.kubeconfig, "kubeconfig", "", "", rootCmd.PersistentFlags().StringVarP(&rootArgs.kubeconfig, "kubeconfig", "", "",
"absolute path to the kubeconfig file") "absolute path to the kubeconfig file")
rootCmd.PersistentFlags().StringVarP(&rootArgs.kubecontext, "context", "", "", "kubernetes context to use") rootCmd.PersistentFlags().StringVarP(&rootArgs.kubecontext, "context", "", "", "kubernetes context to use")
rootCmd.RegisterFlagCompletionFunc("context", contextsCompletionFunc)
rootCmd.DisableAutoGenTag = true rootCmd.DisableAutoGenTag = true
} }

View File

@@ -28,6 +28,7 @@ var reconcileAlertCmd = &cobra.Command{
Long: `The reconcile alert command triggers a reconciliation of an Alert resource and waits for it to finish.`, Long: `The reconcile alert command triggers a reconciliation of an Alert resource and waits for it to finish.`,
Example: ` # Trigger a reconciliation for an existing alert Example: ` # Trigger a reconciliation for an existing alert
flux reconcile alert main`, flux reconcile alert main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: reconcileCommand{ RunE: reconcileCommand{
apiType: alertType, apiType: alertType,
object: alertAdapter{&notificationv1.Alert{}}, object: alertAdapter{&notificationv1.Alert{}},

View File

@@ -37,6 +37,7 @@ var reconcileAlertProviderCmd = &cobra.Command{
Long: `The reconcile alert-provider command triggers a reconciliation of a Provider resource and waits for it to finish.`, Long: `The reconcile alert-provider command triggers a reconciliation of a Provider resource and waits for it to finish.`,
Example: ` # Trigger a reconciliation for an existing provider Example: ` # Trigger a reconciliation for an existing provider
flux reconcile alert-provider slack`, flux reconcile alert-provider slack`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
RunE: reconcileAlertProviderCmdRun, RunE: reconcileAlertProviderCmdRun,
} }

View File

@@ -35,6 +35,7 @@ The reconcile kustomization command triggers a reconciliation of a HelmRelease r
# Trigger a reconciliation of the HelmRelease's source and apply changes # Trigger a reconciliation of the HelmRelease's source and apply changes
flux reconcile hr podinfo --with-source`, flux reconcile hr podinfo --with-source`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: reconcileWithSourceCommand{ RunE: reconcileWithSourceCommand{
apiType: helmReleaseType, apiType: helmReleaseType,
object: helmReleaseAdapter{&helmv2.HelmRelease{}}, object: helmReleaseAdapter{&helmv2.HelmRelease{}},

View File

@@ -30,6 +30,7 @@ var reconcileImageRepositoryCmd = &cobra.Command{
Long: `The reconcile 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 Example: ` # Trigger an scan for an existing image repository
flux reconcile image repository alpine`, flux reconcile image repository alpine`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
RunE: reconcileCommand{ RunE: reconcileCommand{
apiType: imageRepositoryType, apiType: imageRepositoryType,
object: imageRepositoryAdapter{&imagev1.ImageRepository{}}, object: imageRepositoryAdapter{&imagev1.ImageRepository{}},

View File

@@ -32,6 +32,7 @@ var reconcileImageUpdateCmd = &cobra.Command{
Long: `The reconcile 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 Example: ` # Trigger an automation run for an existing image update automation
flux reconcile image update latest-images`, flux reconcile image update latest-images`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: reconcileCommand{ RunE: reconcileCommand{
apiType: imageUpdateAutomationType, apiType: imageUpdateAutomationType,
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}}, object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},

View File

@@ -35,6 +35,7 @@ The reconcile kustomization command triggers a reconciliation of a Kustomization
# Trigger a sync of the Kustomization's source and apply changes # Trigger a sync of the Kustomization's source and apply changes
flux reconcile kustomization podinfo --with-source`, flux reconcile kustomization podinfo --with-source`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: reconcileWithSourceCommand{ RunE: reconcileWithSourceCommand{
apiType: kustomizationType, apiType: kustomizationType,
object: kustomizationAdapter{&kustomizev1.Kustomization{}}, object: kustomizationAdapter{&kustomizev1.Kustomization{}},

View File

@@ -37,6 +37,7 @@ var reconcileReceiverCmd = &cobra.Command{
Long: `The reconcile receiver command triggers a reconciliation of a Receiver resource and waits for it to finish.`, Long: `The reconcile receiver command triggers a reconciliation of a Receiver resource and waits for it to finish.`,
Example: ` # Trigger a reconciliation for an existing receiver Example: ` # Trigger a reconciliation for an existing receiver
flux reconcile receiver main`, flux reconcile receiver main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: reconcileReceiverCmdRun, RunE: reconcileReceiverCmdRun,
} }

View File

@@ -37,6 +37,7 @@ var reconcileSourceBucketCmd = &cobra.Command{
Long: `The reconcile source command triggers a reconciliation of a Bucket resource and waits for it to finish.`, Long: `The reconcile source command triggers a reconciliation of a Bucket resource and waits for it to finish.`,
Example: ` # Trigger a reconciliation for an existing source Example: ` # Trigger a reconciliation for an existing source
flux reconcile source bucket podinfo`, flux reconcile source bucket podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: reconcileCommand{ RunE: reconcileCommand{
apiType: bucketType, apiType: bucketType,
object: bucketAdapter{&sourcev1.Bucket{}}, object: bucketAdapter{&sourcev1.Bucket{}},

View File

@@ -30,6 +30,7 @@ var reconcileSourceGitCmd = &cobra.Command{
Long: `The reconcile source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`, Long: `The reconcile source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`,
Example: ` # Trigger a git pull for an existing source Example: ` # Trigger a git pull for an existing source
flux reconcile source git podinfo`, flux reconcile source git podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: reconcileCommand{ RunE: reconcileCommand{
apiType: gitRepositoryType, apiType: gitRepositoryType,
object: gitRepositoryAdapter{&sourcev1.GitRepository{}}, object: gitRepositoryAdapter{&sourcev1.GitRepository{}},

View File

@@ -30,6 +30,7 @@ var reconcileSourceHelmCmd = &cobra.Command{
Long: `The reconcile source command triggers a reconciliation of a HelmRepository resource and waits for it to finish.`, Long: `The reconcile source command triggers a reconciliation of a HelmRepository resource and waits for it to finish.`,
Example: ` # Trigger a reconciliation for an existing source Example: ` # Trigger a reconciliation for an existing source
flux reconcile source helm podinfo`, flux reconcile source helm podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: reconcileCommand{ RunE: reconcileCommand{
apiType: helmRepositoryType, apiType: helmRepositoryType,
object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}},

View File

@@ -29,6 +29,7 @@ var resumeAlertCmd = &cobra.Command{
finish the apply.`, finish the apply.`,
Example: ` # Resume reconciliation for an existing Alert Example: ` # Resume reconciliation for an existing Alert
flux resume alert main`, flux resume alert main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: alertType, apiType: alertType,
object: alertAdapter{&notificationv1.Alert{}}, object: alertAdapter{&notificationv1.Alert{}},

View File

@@ -32,6 +32,7 @@ var resumeHrCmd = &cobra.Command{
finish the apply.`, finish the apply.`,
Example: ` # Resume reconciliation for an existing Helm release Example: ` # Resume reconciliation for an existing Helm release
flux resume hr podinfo`, flux resume hr podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: helmReleaseType, apiType: helmReleaseType,
object: helmReleaseAdapter{&helmv2.HelmRelease{}}, object: helmReleaseAdapter{&helmv2.HelmRelease{}},

View File

@@ -28,6 +28,7 @@ var resumeImageRepositoryCmd = &cobra.Command{
Long: `The resume command marks a previously suspended ImageRepository resource for reconciliation and waits for it to finish.`, 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 Example: ` # Resume reconciliation for an existing ImageRepository
flux resume image repository alpine`, flux resume image repository alpine`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: imageRepositoryType, apiType: imageRepositoryType,
object: imageRepositoryAdapter{&imagev1.ImageRepository{}}, object: imageRepositoryAdapter{&imagev1.ImageRepository{}},

View File

@@ -28,6 +28,7 @@ var resumeImageUpdateCmd = &cobra.Command{
Long: `The resume command marks a previously suspended ImageUpdateAutomation resource for reconciliation and waits for it to finish.`, 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 Example: ` # Resume reconciliation for an existing ImageUpdateAutomation
flux resume image update latest-images`, flux resume image update latest-images`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: imageUpdateAutomationType, apiType: imageUpdateAutomationType,
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}}, object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},

View File

@@ -32,6 +32,7 @@ var resumeKsCmd = &cobra.Command{
finish the apply.`, finish the apply.`,
Example: ` # Resume reconciliation for an existing Kustomization Example: ` # Resume reconciliation for an existing Kustomization
flux resume ks podinfo`, flux resume ks podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: kustomizationType, apiType: kustomizationType,
object: kustomizationAdapter{&kustomizev1.Kustomization{}}, object: kustomizationAdapter{&kustomizev1.Kustomization{}},

View File

@@ -29,6 +29,7 @@ var resumeReceiverCmd = &cobra.Command{
finish the apply.`, finish the apply.`,
Example: ` # Resume reconciliation for an existing Receiver Example: ` # Resume reconciliation for an existing Receiver
flux resume receiver main`, flux resume receiver main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: receiverType, apiType: receiverType,
object: receiverAdapter{&notificationv1.Receiver{}}, object: receiverAdapter{&notificationv1.Receiver{}},

View File

@@ -28,6 +28,7 @@ var resumeSourceBucketCmd = &cobra.Command{
Long: `The resume command marks a previously suspended Bucket resource for reconciliation and waits for it to finish.`, Long: `The resume command marks a previously suspended Bucket resource for reconciliation and waits for it to finish.`,
Example: ` # Resume reconciliation for an existing Bucket Example: ` # Resume reconciliation for an existing Bucket
flux resume source bucket podinfo`, flux resume source bucket podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: bucketType, apiType: bucketType,
object: &bucketAdapter{&sourcev1.Bucket{}}, object: &bucketAdapter{&sourcev1.Bucket{}},

View File

@@ -30,6 +30,7 @@ var resumeSourceHelmChartCmd = &cobra.Command{
Long: `The resume command marks a previously suspended HelmChart resource for reconciliation and waits for it to finish.`, Long: `The resume command marks a previously suspended HelmChart resource for reconciliation and waits for it to finish.`,
Example: ` # Resume reconciliation for an existing HelmChart Example: ` # Resume reconciliation for an existing HelmChart
flux resume source chart podinfo`, flux resume source chart podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmChartKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: helmChartType, apiType: helmChartType,
object: &helmChartAdapter{&sourcev1.HelmChart{}}, object: &helmChartAdapter{&sourcev1.HelmChart{}},

View File

@@ -28,6 +28,7 @@ var resumeSourceGitCmd = &cobra.Command{
Long: `The resume command marks a previously suspended GitRepository resource for reconciliation and waits for it to finish.`, Long: `The resume command marks a previously suspended GitRepository resource for reconciliation and waits for it to finish.`,
Example: ` # Resume reconciliation for an existing GitRepository Example: ` # Resume reconciliation for an existing GitRepository
flux resume source git podinfo`, flux resume source git podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: gitRepositoryType, apiType: gitRepositoryType,
object: gitRepositoryAdapter{&sourcev1.GitRepository{}}, object: gitRepositoryAdapter{&sourcev1.GitRepository{}},

View File

@@ -28,6 +28,7 @@ var resumeSourceHelmCmd = &cobra.Command{
Long: `The resume command marks a previously suspended HelmRepository resource for reconciliation and waits for it to finish.`, Long: `The resume command marks a previously suspended HelmRepository resource for reconciliation and waits for it to finish.`,
Example: ` # Resume reconciliation for an existing HelmRepository Example: ` # Resume reconciliation for an existing HelmRepository
flux resume source helm bitnami`, flux resume source helm bitnami`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: resumeCommand{ RunE: resumeCommand{
apiType: helmRepositoryType, apiType: helmRepositoryType,
object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}},

View File

@@ -28,6 +28,7 @@ var suspendAlertCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a Alert resource.", Long: "The suspend command disables the reconciliation of a Alert resource.",
Example: ` # Suspend reconciliation for an existing Alert Example: ` # Suspend reconciliation for an existing Alert
flux suspend alert main`, flux suspend alert main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: alertType, apiType: alertType,
object: &alertAdapter{&notificationv1.Alert{}}, object: &alertAdapter{&notificationv1.Alert{}},

View File

@@ -29,6 +29,7 @@ var suspendHrCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a HelmRelease resource.", Long: "The suspend command disables the reconciliation of a HelmRelease resource.",
Example: ` # Suspend reconciliation for an existing Helm release Example: ` # Suspend reconciliation for an existing Helm release
flux suspend hr podinfo`, flux suspend hr podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: helmReleaseType, apiType: helmReleaseType,
object: &helmReleaseAdapter{&helmv2.HelmRelease{}}, object: &helmReleaseAdapter{&helmv2.HelmRelease{}},

View File

@@ -28,6 +28,7 @@ var suspendImageRepositoryCmd = &cobra.Command{
Long: "The suspend image repository 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 Example: ` # Suspend reconciliation for an existing ImageRepository
flux suspend image repository alpine`, flux suspend image repository alpine`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: imageRepositoryType, apiType: imageRepositoryType,
object: imageRepositoryAdapter{&imagev1.ImageRepository{}}, object: imageRepositoryAdapter{&imagev1.ImageRepository{}},

View File

@@ -28,6 +28,7 @@ var suspendImageUpdateCmd = &cobra.Command{
Long: "The suspend image update 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 Example: ` # Suspend reconciliation for an existing ImageUpdateAutomation
flux suspend image update latest-images`, flux suspend image update latest-images`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: imageUpdateAutomationType, apiType: imageUpdateAutomationType,
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}}, object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},

View File

@@ -29,6 +29,7 @@ var suspendKsCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a Kustomization resource.", Long: "The suspend command disables the reconciliation of a Kustomization resource.",
Example: ` # Suspend reconciliation for an existing Kustomization Example: ` # Suspend reconciliation for an existing Kustomization
flux suspend ks podinfo`, flux suspend ks podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: kustomizationType, apiType: kustomizationType,
object: kustomizationAdapter{&kustomizev1.Kustomization{}}, object: kustomizationAdapter{&kustomizev1.Kustomization{}},

View File

@@ -28,6 +28,7 @@ var suspendReceiverCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a Receiver resource.", Long: "The suspend command disables the reconciliation of a Receiver resource.",
Example: ` # Suspend reconciliation for an existing Receiver Example: ` # Suspend reconciliation for an existing Receiver
flux suspend receiver main`, flux suspend receiver main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: receiverType, apiType: receiverType,
object: &receiverAdapter{&notificationv1.Receiver{}}, object: &receiverAdapter{&notificationv1.Receiver{}},

View File

@@ -28,6 +28,7 @@ var suspendSourceBucketCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a Bucket resource.", Long: "The suspend command disables the reconciliation of a Bucket resource.",
Example: ` # Suspend reconciliation for an existing Bucket Example: ` # Suspend reconciliation for an existing Bucket
flux suspend source bucket podinfo`, flux suspend source bucket podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: bucketType, apiType: bucketType,
object: bucketAdapter{&sourcev1.Bucket{}}, object: bucketAdapter{&sourcev1.Bucket{}},

View File

@@ -28,6 +28,7 @@ var suspendSourceHelmChartCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a HelmChart resource.", Long: "The suspend command disables the reconciliation of a HelmChart resource.",
Example: ` # Suspend reconciliation for an existing HelmChart Example: ` # Suspend reconciliation for an existing HelmChart
flux suspend source chart podinfo`, flux suspend source chart podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmChartKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: helmChartType, apiType: helmChartType,
object: helmChartAdapter{&sourcev1.HelmChart{}}, object: helmChartAdapter{&sourcev1.HelmChart{}},

View File

@@ -28,6 +28,7 @@ var suspendSourceGitCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a GitRepository resource.", Long: "The suspend command disables the reconciliation of a GitRepository resource.",
Example: ` # Suspend reconciliation for an existing GitRepository Example: ` # Suspend reconciliation for an existing GitRepository
flux suspend source git podinfo`, flux suspend source git podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: gitRepositoryType, apiType: gitRepositoryType,
object: gitRepositoryAdapter{&sourcev1.GitRepository{}}, object: gitRepositoryAdapter{&sourcev1.GitRepository{}},

View File

@@ -28,6 +28,7 @@ var suspendSourceHelmCmd = &cobra.Command{
Long: "The suspend command disables the reconciliation of a HelmRepository resource.", Long: "The suspend command disables the reconciliation of a HelmRepository resource.",
Example: ` # Suspend reconciliation for an existing HelmRepository Example: ` # Suspend reconciliation for an existing HelmRepository
flux suspend source helm bitnami`, flux suspend source helm bitnami`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: suspendCommand{ RunE: suspendCommand{
apiType: helmRepositoryType, apiType: helmRepositoryType,
object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}},

View File

@@ -107,7 +107,7 @@ func ExecKubectlCommand(ctx context.Context, mode ExecMode, kubeConfigPath strin
return "", nil return "", nil
} }
func KubeConfig(kubeConfigPath string, kubeContext string) (*rest.Config, error) { func ClientConfig(kubeConfigPath string, kubeContext string) clientcmd.ClientConfig {
configFiles := SplitKubeConfigPath(kubeConfigPath) configFiles := SplitKubeConfigPath(kubeConfigPath)
configOverrides := clientcmd.ConfigOverrides{} configOverrides := clientcmd.ConfigOverrides{}
@@ -115,11 +115,14 @@ func KubeConfig(kubeConfigPath string, kubeContext string) (*rest.Config, error)
configOverrides.CurrentContext = kubeContext configOverrides.CurrentContext = kubeContext
} }
cfg, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
&clientcmd.ClientConfigLoadingRules{Precedence: configFiles}, &clientcmd.ClientConfigLoadingRules{Precedence: configFiles},
&configOverrides, &configOverrides,
).ClientConfig() )
}
func KubeConfig(kubeConfigPath string, kubeContext string) (*rest.Config, error) {
cfg, err := ClientConfig(kubeConfigPath, kubeContext).ClientConfig()
if err != nil { if err != nil {
return nil, fmt.Errorf("kubernetes configuration load failed: %w", err) return nil, fmt.Errorf("kubernetes configuration load failed: %w", err)
} }