diff --git a/.github/workflows/e2e-bootstrap.yaml b/.github/workflows/e2e-bootstrap.yaml index 2bf2951c..6484a88e 100644 --- a/.github/workflows/e2e-bootstrap.yaml +++ b/.github/workflows/e2e-bootstrap.yaml @@ -85,13 +85,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }} GITHUB_REPO_NAME: ${{ steps.vars.outputs.test_repo_name }} GITHUB_ORG_NAME: fluxcd-testing - - name: libgit2 - run: | - /tmp/flux create source git test-libgit2 \ - --url=ssh://git@github.com/fluxcd-testing/${{ steps.vars.outputs.test_repo_name }} \ - --git-implementation=libgit2 \ - --secret-ref=flux-system \ - --branch=main - name: uninstall run: | /tmp/flux uninstall -s --keep-namespace diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 593446bb..b4de7dd2 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -86,13 +86,6 @@ jobs: --tag-semver=">=3.2.3" \ --export | kubectl apply -f - /tmp/flux delete source git podinfo-export --silent - - name: flux create source git libgit2 semver - run: | - /tmp/flux create source git podinfo-libgit2 \ - --url https://github.com/stefanprodan/podinfo \ - --tag-semver=">=3.2.3" \ - --git-implementation=libgit2 - /tmp/flux delete source git podinfo-libgit2 --silent - name: flux get sources git run: | /tmp/flux get sources git diff --git a/cmd/flux/bootstrap.go b/cmd/flux/bootstrap.go index 9e390a89..09b4ec9d 100644 --- a/cmd/flux/bootstrap.go +++ b/cmd/flux/bootstrap.go @@ -31,13 +31,13 @@ import ( var bootstrapCmd = &cobra.Command{ Use: "bootstrap", - Short: "Bootstrap toolkit components", - Long: "The bootstrap sub-commands bootstrap the toolkit components on the targeted Git provider.", + Short: "Deploy Flux on a cluster the GitOps way.", + Long: `The bootstrap sub-commands push the Flux manifests to a Git repository +and deploy Flux on the cluster.`, } type bootstrapFlags struct { version string - arch flags.Arch logLevel flags.LogLevel branch string @@ -91,9 +91,9 @@ func init() { "list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller'") bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.registry, "registry", "ghcr.io/fluxcd", - "container registry where the toolkit images are published") + "container registry where the Flux controller images are published") bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.imagePullSecret, "image-pull-secret", "", - "Kubernetes secret name used for pulling the toolkit images from a private registry") + "Kubernetes secret name used for pulling the controller images from a private registry") bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.branch, "branch", bootstrapDefaultBranch, "Git branch") bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.recurseSubmodules, "recurse-submodules", false, @@ -102,15 +102,15 @@ func init() { bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.manifestsPath, "manifests", "", "path to the manifest directory") bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.watchAllNamespaces, "watch-all-namespaces", true, - "watch for custom resources in all namespaces, if set to false it will only watch the namespace where the toolkit is installed") + "watch for custom resources in all namespaces, if set to false it will only watch the namespace where the Flux controllers are installed") bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.networkPolicy, "network-policy", true, - "deny ingress access to the toolkit controllers from other namespaces using network policies") + "setup Kubernetes network policies to deny ingress access to the Flux controllers from other namespaces") bootstrapCmd.PersistentFlags().BoolVar(&bootstrapArgs.tokenAuth, "token-auth", false, - "when enabled, the personal access token will be used instead of SSH deploy key") + "when enabled, the personal access token will be used instead of the SSH deploy key") bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.logLevel, "log-level", bootstrapArgs.logLevel.Description()) bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.clusterDomain, "cluster-domain", rootArgs.defaults.ClusterDomain, "internal cluster domain") bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.tolerationKeys, "toleration-keys", nil, - "list of toleration keys used to schedule the components pods onto nodes with matching taints") + "list of toleration keys used to schedule the controller pods onto nodes with matching taints") bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.secretName, "secret-name", rootArgs.defaults.Namespace, "name of the secret the sync credentials can be found in or stored to") bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.keyAlgorithm, "ssh-key-algorithm", bootstrapArgs.keyAlgorithm.Description()) @@ -129,8 +129,6 @@ func init() { bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.commitMessageAppendix, "commit-message-appendix", "", "string to add to the commit messages, e.g. '[ci skip]'") - bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.arch, "arch", bootstrapArgs.arch.Description()) - bootstrapCmd.PersistentFlags().MarkDeprecated("arch", "multi-arch container image is now available for AMD64, ARMv7 and ARM64") bootstrapCmd.PersistentFlags().MarkHidden("manifests") rootCmd.AddCommand(bootstrapCmd) diff --git a/cmd/flux/bootstrap_bitbucket_server.go b/cmd/flux/bootstrap_bitbucket_server.go index b656db4d..ee56a32d 100644 --- a/cmd/flux/bootstrap_bitbucket_server.go +++ b/cmd/flux/bootstrap_bitbucket_server.go @@ -38,29 +38,26 @@ import ( var bootstrapBServerCmd = &cobra.Command{ Use: "bitbucket-server", - Short: "Bootstrap toolkit components in a Bitbucket Server repository", + Short: "Deploy Flux on a cluster connected to a Bitbucket Server repository", Long: `The bootstrap bitbucket-server command creates the Bitbucket Server repository if it doesn't exists and -commits the toolkit components manifests to the master branch. +commits the Flux manifests to the master branch. Then it configures the target cluster to synchronize with the repository. -If the toolkit components are present on the cluster, +If the Flux components are present on the cluster, the bootstrap command will perform an upgrade if needed.`, Example: ` # Create a Bitbucket Server API token and export it as an env var export BITBUCKET_TOKEN= # Run bootstrap for a private repository using HTTPS token authentication - flux bootstrap bitbucket-server --owner= --username= --repository= --hostname= --token-auth + flux bootstrap bitbucket-server --owner= --username= --repository= --hostname= --token-auth --path=clusters/my-cluster # Run bootstrap for a private repository using SSH authentication - flux bootstrap bitbucket-server --owner= --username= --repository= --hostname= - - # Run bootstrap for a repository path - flux bootstrap bitbucket-server --owner= --username= --repository= --path=dev-cluster --hostname= + flux bootstrap bitbucket-server --owner= --username= --repository= --hostname= --path=clusters/my-cluster # Run bootstrap for a public repository on a personal account - flux bootstrap bitbucket-server --owner= --repository= --private=false --personal --hostname= --token-auth + flux bootstrap bitbucket-server --owner= --repository= --private=false --personal --hostname= --token-auth --path=clusters/my-cluster # Run bootstrap for a an existing repository with a branch named main - flux bootstrap bitbucket-server --owner= --username= --repository= --branch=main --hostname= --token-auth`, + flux bootstrap bitbucket-server --owner= --username= --repository= --branch=main --hostname= --token-auth --path=clusters/my-cluster`, RunE: bootstrapBServerCmdRun, } @@ -247,7 +244,6 @@ func bootstrapBServerCmdRun(cmd *cobra.Command, args []string) error { Secret: bootstrapArgs.secretName, TargetPath: bServerArgs.path.ToSlash(), ManifestFile: sync.MakeDefaultOptions().ManifestFile, - GitImplementation: sourceGitArgs.gitImplementation.String(), RecurseSubmodules: bootstrapArgs.recurseSubmodules, } diff --git a/cmd/flux/bootstrap_git.go b/cmd/flux/bootstrap_git.go index d7677e6e..3d1dd255 100644 --- a/cmd/flux/bootstrap_git.go +++ b/cmd/flux/bootstrap_git.go @@ -41,31 +41,31 @@ import ( var bootstrapGitCmd = &cobra.Command{ Use: "git", - Short: "Bootstrap toolkit components in a Git repository", - Long: `The bootstrap git command commits the toolkit components manifests to the -branch of a Git repository. It then configures the target cluster to synchronize with -the repository. If the toolkit components are present on the cluster, the bootstrap + Short: "Deploy Flux on a cluster connected to a Git repository", + Long: `The bootstrap git command commits the Flux manifests to the +branch of a Git repository. And then it configures the target cluster to synchronize with +that repository. If the Flux components are present on the cluster, the bootstrap command will perform an upgrade if needed.`, Example: ` # Run bootstrap for a Git repository and authenticate with your SSH agent - flux bootstrap git --url=ssh://git@example.com/repository.git + flux bootstrap git --url=ssh://git@example.com/repository.git --path=clusters/my-cluster # Run bootstrap for a Git repository and authenticate using a password - flux bootstrap git --url=https://example.com/repository.git --password= + flux bootstrap git --url=https://example.com/repository.git --password= --path=clusters/my-cluster # Run bootstrap for a Git repository and authenticate using a password from environment variable - GIT_PASSWORD= && flux bootstrap git --url=https://example.com/repository.git + GIT_PASSWORD= && flux bootstrap git --url=https://example.com/repository.git --path=clusters/my-cluster # Run bootstrap for a Git repository with a passwordless private key - flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file= + flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file= --path=clusters/my-cluster # Run bootstrap for a Git repository with a private key and password - flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file= --password= + flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file= --password= --path=clusters/my-cluster # Run bootstrap for a Git repository on AWS CodeCommit - flux bootstrap git --url=ssh://@git-codecommit..amazonaws.com/v1/repos/ --private-key-file= --password= + flux bootstrap git --url=ssh://@git-codecommit..amazonaws.com/v1/repos/ --private-key-file= --password= --path=clusters/my-cluster # Run bootstrap for a Git repository on Azure Devops - flux bootstrap git --url=ssh://git@ssh.dev.azure.com/v3/// --ssh-key-algorithm=rsa --ssh-rsa-bits=4096 + flux bootstrap git --url=ssh://git@ssh.dev.azure.com/v3/// --ssh-key-algorithm=rsa --ssh-rsa-bits=4096 --path=clusters/my-cluster `, RunE: bootstrapGitCmdRun, } @@ -93,7 +93,7 @@ func init() { bootstrapGitCmd.Flags().StringVarP(&gitArgs.username, "username", "u", "git", "basic authentication username") bootstrapGitCmd.Flags().StringVarP(&gitArgs.password, "password", "p", "", "basic authentication password") bootstrapGitCmd.Flags().BoolVarP(&gitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation") - bootstrapGitCmd.Flags().BoolVar(&gitArgs.insecureHttpAllowed, "allow-insecure-http", false, "allows http git url connections") + bootstrapGitCmd.Flags().BoolVar(&gitArgs.insecureHttpAllowed, "allow-insecure-http", false, "allows insecure HTTP connections") bootstrapCmd.AddCommand(bootstrapGitCmd) } @@ -271,7 +271,6 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error { Secret: bootstrapArgs.secretName, TargetPath: gitArgs.path.ToSlash(), ManifestFile: sync.MakeDefaultOptions().ManifestFile, - GitImplementation: sourceGitArgs.gitImplementation.String(), RecurseSubmodules: bootstrapArgs.recurseSubmodules, } diff --git a/cmd/flux/bootstrap_github.go b/cmd/flux/bootstrap_github.go index f789aae8..e015e4bb 100644 --- a/cmd/flux/bootstrap_github.go +++ b/cmd/flux/bootstrap_github.go @@ -38,38 +38,35 @@ import ( var bootstrapGitHubCmd = &cobra.Command{ Use: "github", - Short: "Bootstrap toolkit components in a GitHub repository", + Short: "Deploy Flux on a cluster connected to a GitHub repository", Long: `The bootstrap github command creates the GitHub repository if it doesn't exists and -commits the toolkit components manifests to the main branch. -Then it configures the target cluster to synchronize with the repository. -If the toolkit components are present on the cluster, +commits the Flux manifests to the specified branch. +Then it configures the target cluster to synchronize with that repository. +If the Flux components are present on the cluster, the bootstrap command will perform an upgrade if needed.`, Example: ` # Create a GitHub personal access token and export it as an env var export GITHUB_TOKEN= # Run bootstrap for a private repository owned by a GitHub organization - flux bootstrap github --owner= --repository= + flux bootstrap github --owner= --repository= --path=clusters/my-cluster # Run bootstrap for a private repository and assign organization teams to it - flux bootstrap github --owner= --repository= --team= --team= + flux bootstrap github --owner= --repository= --team= --team= --path=clusters/my-cluster # Run bootstrap for a private repository and assign organization teams with their access level(e.g maintain, admin) to it - flux bootstrap github --owner= --repository= --team=: - - # Run bootstrap for a repository path - flux bootstrap github --owner= --repository= --path=dev-cluster + flux bootstrap github --owner= --repository= --team=: --path=clusters/my-cluster # Run bootstrap for a public repository on a personal account - flux bootstrap github --owner= --repository= --private=false --personal=true + flux bootstrap github --owner= --repository= --private=false --personal=true --path=clusters/my-cluster # Run bootstrap for a private repository hosted on GitHub Enterprise using SSH auth - flux bootstrap github --owner= --repository= --hostname= --ssh-hostname= + flux bootstrap github --owner= --repository= --hostname= --ssh-hostname= --path=clusters/my-cluster # Run bootstrap for a private repository hosted on GitHub Enterprise using HTTPS auth - flux bootstrap github --owner= --repository= --hostname= --token-auth + flux bootstrap github --owner= --repository= --hostname= --token-auth --path=clusters/my-cluster # Run bootstrap for an existing repository with a branch named main - flux bootstrap github --owner= --repository= --branch=main`, + flux bootstrap github --owner= --repository= --branch=main --path=clusters/my-cluster`, RunE: bootstrapGitHubCmdRun, } @@ -233,7 +230,6 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error { Secret: bootstrapArgs.secretName, TargetPath: githubArgs.path.ToSlash(), ManifestFile: sync.MakeDefaultOptions().ManifestFile, - GitImplementation: sourceGitArgs.gitImplementation.String(), RecurseSubmodules: bootstrapArgs.recurseSubmodules, } diff --git a/cmd/flux/bootstrap_gitlab.go b/cmd/flux/bootstrap_gitlab.go index 7266545a..e5d27229 100644 --- a/cmd/flux/bootstrap_gitlab.go +++ b/cmd/flux/bootstrap_gitlab.go @@ -40,11 +40,11 @@ import ( var bootstrapGitLabCmd = &cobra.Command{ Use: "gitlab", - Short: "Bootstrap toolkit components in a GitLab repository", + Short: "Deploy Flux on a cluster connected to a GitLab repository", Long: `The bootstrap gitlab command creates the GitLab repository if it doesn't exists and -commits the toolkit components manifests to the master branch. -Then it configures the target cluster to synchronize with the repository. -If the toolkit components are present on the cluster, +commits the Flux manifests to the specified branch. +Then it configures the target cluster to synchronize with that repository. +If the Flux components are present on the cluster, the bootstrap command will perform an upgrade if needed.`, Example: ` # Create a GitLab API token and export it as an env var export GITLAB_TOKEN= @@ -250,7 +250,6 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error { Secret: bootstrapArgs.secretName, TargetPath: gitlabArgs.path.ToSlash(), ManifestFile: sync.MakeDefaultOptions().ManifestFile, - GitImplementation: sourceGitArgs.gitImplementation.String(), RecurseSubmodules: bootstrapArgs.recurseSubmodules, } diff --git a/cmd/flux/create_source_git.go b/cmd/flux/create_source_git.go index 22306dc5..5a321c08 100644 --- a/cmd/flux/create_source_git.go +++ b/cmd/flux/create_source_git.go @@ -55,7 +55,6 @@ type sourceGitFlags struct { keyRSABits flags.RSAKeyBits keyECDSACurve flags.ECDSACurve secretRef string - gitImplementation flags.GitImplementation caFile string privateKeyFile string recurseSubmodules bool @@ -136,7 +135,6 @@ func init() { createSourceGitCmd.Flags().Var(&sourceGitArgs.keyRSABits, "ssh-rsa-bits", sourceGitArgs.keyRSABits.Description()) createSourceGitCmd.Flags().Var(&sourceGitArgs.keyECDSACurve, "ssh-ecdsa-curve", sourceGitArgs.keyECDSACurve.Description()) createSourceGitCmd.Flags().StringVar(&sourceGitArgs.secretRef, "secret-ref", "", "the name of an existing secret containing SSH or basic credentials") - createSourceGitCmd.Flags().Var(&sourceGitArgs.gitImplementation, "git-implementation", sourceGitArgs.gitImplementation.Description()) createSourceGitCmd.Flags().StringVar(&sourceGitArgs.caFile, "ca-file", "", "path to TLS CA file used for validating self-signed certificates") createSourceGitCmd.Flags().StringVar(&sourceGitArgs.privateKeyFile, "private-key-file", "", "path to a passwordless private key file used for authenticating to the Git SSH server") createSourceGitCmd.Flags().BoolVar(&sourceGitArgs.recurseSubmodules, "recurse-submodules", false, @@ -178,10 +176,6 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { return fmt.Errorf("specifying a CA file is not supported for Git over SSH") } - if sourceGitArgs.recurseSubmodules && sourceGitArgs.gitImplementation == sourcev1.LibGit2Implementation { - return fmt.Errorf("recurse submodules requires --git-implementation=%s", sourcev1.GoGitImplementation) - } - tmpDir, err := os.MkdirTemp("", name) if err != nil { return err @@ -220,10 +214,6 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { gitRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout} } - if sourceGitArgs.gitImplementation != "" { - gitRepository.Spec.GitImplementation = sourceGitArgs.gitImplementation.String() - } - if sourceGitArgs.semver != "" { gitRepository.Spec.Reference.SemVer = sourceGitArgs.semver } else if sourceGitArgs.tag != "" { diff --git a/cmd/flux/install.go b/cmd/flux/install.go index 4d0e6d82..4c645640 100644 --- a/cmd/flux/install.go +++ b/cmd/flux/install.go @@ -59,7 +59,6 @@ If a previous version is installed, then an in-place upgrade will be performed.` type installFlags struct { export bool - dryRun bool version string defaultComponents []string extraComponents []string @@ -69,7 +68,6 @@ type installFlags struct { watchAllNamespaces bool networkPolicy bool manifestsPath string - arch flags.Arch logLevel flags.LogLevel tokenAuth bool clusterDomain string @@ -81,8 +79,6 @@ var installArgs = NewInstallFlags() func init() { installCmd.Flags().BoolVar(&installArgs.export, "export", false, "write the install manifests to stdout and exit") - installCmd.Flags().BoolVarP(&installArgs.dryRun, "dry-run", "", false, - "only print the object that would be applied") installCmd.Flags().StringVarP(&installArgs.version, "version", "v", "", "toolkit version, when specified the manifests are downloaded from https://github.com/fluxcd/flux2/releases") installCmd.Flags().StringSliceVar(&installArgs.defaultComponents, "components", rootArgs.defaults.Components, @@ -94,7 +90,6 @@ func init() { "container registry where the toolkit images are published") installCmd.Flags().StringVar(&installArgs.imagePullSecret, "image-pull-secret", "", "Kubernetes secret name used for pulling the toolkit images from a private registry") - installCmd.Flags().Var(&installArgs.arch, "arch", installArgs.arch.Description()) installCmd.Flags().BoolVar(&installArgs.watchAllNamespaces, "watch-all-namespaces", rootArgs.defaults.WatchAllNamespaces, "watch for custom resources in all namespaces, if set to false it will only watch the namespace where the toolkit is installed") installCmd.Flags().Var(&installArgs.logLevel, "log-level", installArgs.logLevel.Description()) @@ -104,8 +99,7 @@ func init() { installCmd.Flags().StringSliceVar(&installArgs.tolerationKeys, "toleration-keys", nil, "list of toleration keys used to schedule the components pods onto nodes with matching taints") installCmd.Flags().MarkHidden("manifests") - installCmd.Flags().MarkDeprecated("arch", "multi-arch container image is now available for AMD64, ARMv7 and ARM64") - installCmd.Flags().MarkDeprecated("dry-run", "use 'flux install --export | kubectl apply --dry-run=client -f-'") + rootCmd.AddCommand(installCmd) } @@ -189,11 +183,6 @@ func installCmdRun(cmd *cobra.Command, args []string) error { logger.Successf("manifests build completed") logger.Actionf("installing components in %s namespace", *kubeconfigArgs.Namespace) - if installArgs.dryRun { - logger.Successf("install dry-run finished") - return nil - } - applyOutput, err := utils.Apply(ctx, kubeconfigArgs, kubeclientOptions, tmpDir, filepath.Join(tmpDir, manifest.Path)) if err != nil { return fmt.Errorf("install failed: %w", err) diff --git a/internal/flags/arch.go b/internal/flags/arch.go deleted file mode 100644 index 7d39a4ea..00000000 --- a/internal/flags/arch.go +++ /dev/null @@ -1,54 +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 flags - -import ( - "fmt" - "strings" - - "github.com/fluxcd/flux2/internal/utils" -) - -var supportedArchs = []string{"amd64", "arm", "arm64"} - -type Arch string - -func (a *Arch) String() string { - return string(*a) -} - -func (a *Arch) Set(str string) error { - if strings.TrimSpace(str) == "" { - return fmt.Errorf("no arch given, must be one of: %s", - strings.Join(supportedArchs, ", ")) - } - if !utils.ContainsItemString(supportedArchs, str) { - return fmt.Errorf("unsupported arch '%s', must be one of: %s", - str, strings.Join(supportedArchs, ", ")) - - } - *a = Arch(str) - return nil -} - -func (a *Arch) Type() string { - return "arch" -} - -func (a *Arch) Description() string { - return fmt.Sprintf("cluster architecture, available options are: (%s)", strings.Join(supportedArchs, ", ")) -} diff --git a/internal/flags/arch_test.go b/internal/flags/arch_test.go deleted file mode 100644 index 9902fff4..00000000 --- a/internal/flags/arch_test.go +++ /dev/null @@ -1,45 +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 flags - -import ( - "testing" -) - -func TestArch_Set(t *testing.T) { - tests := []struct { - name string - str string - expect string - expectErr bool - }{ - {"supported", "amd64", "amd64", false}, - {"unsupported", "unsupported", "", true}, - {"empty", "", "", true}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var a Arch - if err := a.Set(tt.str); (err != nil) != tt.expectErr { - t.Errorf("Set() error = %v, expectErr %v", err, tt.expectErr) - } - if str := a.String(); str != tt.expect { - t.Errorf("Set() = %v, expect %v", str, tt.expect) - } - }) - } -} diff --git a/internal/flags/git_implementation.go b/internal/flags/git_implementation.go deleted file mode 100644 index 77512c2e..00000000 --- a/internal/flags/git_implementation.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2021 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 flags - -import ( - "fmt" - "strings" - - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" - - "github.com/fluxcd/flux2/internal/utils" -) - -var supportedGitImplementations = []string{sourcev1.GoGitImplementation, sourcev1.LibGit2Implementation} - -type GitImplementation string - -func (i *GitImplementation) String() string { - return string(*i) -} - -func (i *GitImplementation) Set(str string) error { - if str == "" { - return nil - } - if !utils.ContainsItemString(supportedGitImplementations, str) { - return fmt.Errorf("unsupported Git implementation '%s', must be one of: %s", - str, strings.Join(supportedGitImplementations, ", ")) - - } - *i = GitImplementation(str) - return nil -} - -func (i *GitImplementation) Type() string { - return "gitImplementation" -} - -func (i *GitImplementation) Description() string { - return fmt.Sprintf("the Git implementation to use, available options are: (%s)", strings.Join(supportedGitImplementations, ", ")) -} diff --git a/internal/flags/git_implementation_test.go b/internal/flags/git_implementation_test.go deleted file mode 100644 index 9af8cfe2..00000000 --- a/internal/flags/git_implementation_test.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:build !e2e -// +build !e2e - -/* -Copyright 2021 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 flags - -import ( - "testing" - - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" -) - -func TestGitImplementation_Set(t *testing.T) { - tests := []struct { - name string - str string - expect string - expectErr bool - }{ - {"supported", sourcev1.GoGitImplementation, sourcev1.GoGitImplementation, false}, - {"unsupported", "unsupported", "", true}, - {"empty", "", "", false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var i GitImplementation - if err := i.Set(tt.str); (err != nil) != tt.expectErr { - t.Errorf("Set() error = %v, expectErr %v", err, tt.expectErr) - } - if str := i.String(); str != tt.expect { - t.Errorf("Set() = %v, expect %v", str, tt.expect) - } - }) - } -} diff --git a/pkg/manifestgen/sync/options.go b/pkg/manifestgen/sync/options.go index 7085d56e..4a209827 100644 --- a/pkg/manifestgen/sync/options.go +++ b/pkg/manifestgen/sync/options.go @@ -32,20 +32,18 @@ type Options struct { Secret string TargetPath string ManifestFile string - GitImplementation string RecurseSubmodules bool } func MakeDefaultOptions() Options { return Options{ - Interval: 1 * time.Minute, - URL: "", - Name: "flux-system", - Namespace: "flux-system", - Branch: "main", - Secret: "flux-system", - ManifestFile: "gotk-sync.yaml", - TargetPath: "", - GitImplementation: "", + Interval: 1 * time.Minute, + URL: "", + Name: "flux-system", + Namespace: "flux-system", + Branch: "main", + Secret: "flux-system", + ManifestFile: "gotk-sync.yaml", + TargetPath: "", } } diff --git a/pkg/manifestgen/sync/sync.go b/pkg/manifestgen/sync/sync.go index 818c11f4..6b7953fc 100644 --- a/pkg/manifestgen/sync/sync.go +++ b/pkg/manifestgen/sync/sync.go @@ -67,7 +67,6 @@ func Generate(options Options) (*manifestgen.Manifest, error) { SecretRef: &meta.LocalObjectReference{ Name: options.Secret, }, - GitImplementation: options.GitImplementation, RecurseSubmodules: options.RecurseSubmodules, }, }