1
0
mirror of synced 2026-03-02 19:46:55 +00:00

Compare commits

..

8 Commits

Author SHA1 Message Date
Hidde Beydals
f5c29a7a72 Merge pull request #720 from fluxcd/update-components
Update kustomize-controller to v0.6.2
2021-01-15 17:16:50 +01:00
fluxcdbot
e243df93f1 Update toolkit components 2021-01-15 16:02:02 +00:00
Hidde Beydals
388642d9dd Merge pull request #721 from fluxcd/git-impl-fixes 2021-01-15 17:01:08 +01:00
Hidde Beydals
9e1db06936 Move Git implementation validation to custom flag
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-15 16:50:23 +01:00
Hidde Beydals
a260403334 Remove GitImplementation default
As the field in the CRD is optional.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-15 16:49:26 +01:00
Stefan Prodan
6396b25886 Merge pull request #641 from jonaskello/patch-1
Link docs how to get zsh/fish/ps completion to work in getting-started
2021-01-15 15:12:11 +02:00
Jonas Kello
ca480164b7 Merge branch 'main' into patch-1 2021-01-15 13:55:42 +01:00
Jonas Kello
714f9df3cf Link docs how to get zsh completion to work in getting-started
I tried to make completions work in zsh by just adding the same code as for the bash example but of course switching bash for zsh but it did not work. When I googled and dug deeper I finally found the answer in the deeper docs here:

https://github.com/fluxcd/flux2/blob/main/docs/cmd/flux_completion_zsh.md

The command in there works if I add it to my .zshrc file. I think linking to these specific docs may prevent others from just assuming it will work the same in zsh.

Signed-off-by: Jonas Kello <jonas.kello@gmail.com>
2021-01-15 13:17:29 +01:00
10 changed files with 125 additions and 28 deletions

View File

@@ -164,14 +164,13 @@ func applyInstallManifests(ctx context.Context, manifestPath string, components
func generateSyncManifests(url, branch, name, namespace, targetPath, tmpDir string, interval time.Duration) (string, error) { func generateSyncManifests(url, branch, name, namespace, targetPath, tmpDir string, interval time.Duration) (string, error) {
opts := sync.Options{ opts := sync.Options{
Name: name, Name: name,
Namespace: namespace, Namespace: namespace,
URL: url, URL: url,
Branch: branch, Branch: branch,
Interval: interval, Interval: interval,
TargetPath: targetPath, TargetPath: targetPath,
ManifestFile: sync.MakeDefaultOptions().ManifestFile, ManifestFile: sync.MakeDefaultOptions().ManifestFile,
GitImplementation: sync.MakeDefaultOptions().GitImplementation,
} }
manifest, err := sync.Generate(opts) manifest, err := sync.Generate(opts)

View File

@@ -96,7 +96,7 @@ var (
sourceGitRSABits flags.RSAKeyBits = 2048 sourceGitRSABits flags.RSAKeyBits = 2048
sourceGitECDSACurve = flags.ECDSACurve{Curve: elliptic.P384()} sourceGitECDSACurve = flags.ECDSACurve{Curve: elliptic.P384()}
sourceGitSecretRef string sourceGitSecretRef string
sourceGitImplementation string sourceGitImplementation flags.GitImplementation
) )
func init() { func init() {
@@ -110,7 +110,7 @@ func init() {
createSourceGitCmd.Flags().Var(&sourceGitRSABits, "ssh-rsa-bits", sourceGitRSABits.Description()) createSourceGitCmd.Flags().Var(&sourceGitRSABits, "ssh-rsa-bits", sourceGitRSABits.Description())
createSourceGitCmd.Flags().Var(&sourceGitECDSACurve, "ssh-ecdsa-curve", sourceGitECDSACurve.Description()) createSourceGitCmd.Flags().Var(&sourceGitECDSACurve, "ssh-ecdsa-curve", sourceGitECDSACurve.Description())
createSourceGitCmd.Flags().StringVarP(&sourceGitSecretRef, "secret-ref", "", "", "the name of an existing secret containing SSH or basic credentials") createSourceGitCmd.Flags().StringVarP(&sourceGitSecretRef, "secret-ref", "", "", "the name of an existing secret containing SSH or basic credentials")
createSourceGitCmd.Flags().StringVar(&sourceGitImplementation, "git-implementation", "", "the git implementation to use, can be 'go-git' or 'libgit2'") createSourceGitCmd.Flags().Var(&sourceGitImplementation, "git-implementation", sourceGitImplementation.Description())
createSourceCmd.AddCommand(createSourceGitCmd) createSourceCmd.AddCommand(createSourceGitCmd)
} }
@@ -141,10 +141,6 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
return err return err
} }
if !utils.ContainsItemString([]string{sourcev1.GoGitImplementation, sourcev1.LibGit2Implementation, ""}, sourceGitImplementation) {
return fmt.Errorf("Invalid git implementation %q", sourceGitImplementation)
}
gitRepository := sourcev1.GitRepository{ gitRepository := sourcev1.GitRepository{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
@@ -156,11 +152,14 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
Interval: metav1.Duration{ Interval: metav1.Duration{
Duration: interval, Duration: interval,
}, },
Reference: &sourcev1.GitRepositoryRef{}, Reference: &sourcev1.GitRepositoryRef{},
GitImplementation: sourceGitImplementation,
}, },
} }
if sourceGitImplementation != "" {
gitRepository.Spec.GitImplementation = sourceGitImplementation.String()
}
if sourceGitSemver != "" { if sourceGitSemver != "" {
gitRepository.Spec.Reference.SemVer = sourceGitSemver gitRepository.Spec.Reference.SemVer = sourceGitSemver
} else if sourceGitTag != "" { } else if sourceGitTag != "" {

View File

@@ -56,7 +56,7 @@ flux create source git [name] [flags]
``` ```
--branch string git branch (default "master") --branch string git branch (default "master")
--git-implementation string the git implementation to use, can be 'go-git' or 'libgit2' --git-implementation gitImplementation the Git implementation to use, available options are: (go-git, libgit2)
-h, --help help for git -h, --help help for git
-p, --password string basic authentication password -p, --password string basic authentication password
--secret-ref string the name of an existing secret containing SSH or basic credentials --secret-ref string the name of an existing secret containing SSH or basic credentials

View File

@@ -52,15 +52,14 @@ binary).
Binaries for **macOS**, **Windows** and **Linux** AMD64/ARM are available for download on the Binaries for **macOS**, **Windows** and **Linux** AMD64/ARM are available for download on the
[release page](https://github.com/fluxcd/flux2/releases). [release page](https://github.com/fluxcd/flux2/releases).
To configure your shell to load `flux` completions add to your Bash To configure your shell to load `flux` [bash completions](../cmd/flux_completion_bash.md) add to your profile:
profile:
```sh ```sh
# ~/.bashrc or ~/.bash_profile # ~/.bashrc or ~/.bash_profile
. <(flux completion bash) . <(flux completion bash)
``` ```
`zsh`, `fish`, and `powershell` are also supported with their own sub-commands. [`zsh`](../cmd/flux_completion_zsh.md), [`fish`](../cmd/flux_completion_fish.md), and [`powershell`](../cmd/flux_completion_powershell.md) are also supported with their own sub-commands.
## Install Flux components ## Install Flux components

2
go.mod
View File

@@ -8,7 +8,7 @@ require (
github.com/fluxcd/helm-controller/api v0.5.1 github.com/fluxcd/helm-controller/api v0.5.1
github.com/fluxcd/image-automation-controller/api v0.3.0 github.com/fluxcd/image-automation-controller/api v0.3.0
github.com/fluxcd/image-reflector-controller/api v0.2.0 github.com/fluxcd/image-reflector-controller/api v0.2.0
github.com/fluxcd/kustomize-controller/api v0.6.1 github.com/fluxcd/kustomize-controller/api v0.6.2
github.com/fluxcd/notification-controller/api v0.6.1 github.com/fluxcd/notification-controller/api v0.6.1
github.com/fluxcd/pkg/apis/meta v0.5.0 github.com/fluxcd/pkg/apis/meta v0.5.0
github.com/fluxcd/pkg/git v0.2.1 github.com/fluxcd/pkg/git v0.2.1

4
go.sum
View File

@@ -182,8 +182,8 @@ github.com/fluxcd/image-automation-controller/api v0.3.0 h1:1cwNjY4t7gy3k+dYf47x
github.com/fluxcd/image-automation-controller/api v0.3.0/go.mod h1:dn/HSWvYMEMv1ILOasXtbM2Y1vTgrv2Edcw69rL7QpQ= github.com/fluxcd/image-automation-controller/api v0.3.0/go.mod h1:dn/HSWvYMEMv1ILOasXtbM2Y1vTgrv2Edcw69rL7QpQ=
github.com/fluxcd/image-reflector-controller/api v0.2.0 h1:/qAamO2y1Bq4rn/JedB33V9kOkSeXIYxwpnEHBz0HeE= github.com/fluxcd/image-reflector-controller/api v0.2.0 h1:/qAamO2y1Bq4rn/JedB33V9kOkSeXIYxwpnEHBz0HeE=
github.com/fluxcd/image-reflector-controller/api v0.2.0/go.mod h1:2KC4Zijp+iIbkID/KT+hhH4iSSQP3Hrzh0t971tjWjk= github.com/fluxcd/image-reflector-controller/api v0.2.0/go.mod h1:2KC4Zijp+iIbkID/KT+hhH4iSSQP3Hrzh0t971tjWjk=
github.com/fluxcd/kustomize-controller/api v0.6.1 h1:NUe+Aa3w6z8PR5zyyOSjAN3RTGNLwb5jGAm+u6aJuWk= github.com/fluxcd/kustomize-controller/api v0.6.2 h1:ntkak6WB+TZCCjqctZ6P8O3gFkwIlM3FqqLvMwH02ao=
github.com/fluxcd/kustomize-controller/api v0.6.1/go.mod h1:g9cE+lrH5xluslMvx9LqxY/rYg7c2XN/lOlsxDBnNdM= github.com/fluxcd/kustomize-controller/api v0.6.2/go.mod h1:g9cE+lrH5xluslMvx9LqxY/rYg7c2XN/lOlsxDBnNdM=
github.com/fluxcd/notification-controller/api v0.6.1 h1:l5mManb+Y8aT9uO9Y17Ifoo455zLyAbeZz4ltRUKK78= github.com/fluxcd/notification-controller/api v0.6.1 h1:l5mManb+Y8aT9uO9Y17Ifoo455zLyAbeZz4ltRUKK78=
github.com/fluxcd/notification-controller/api v0.6.1/go.mod h1:9BiC68i6eeQTERhrMo0dni51uKSlt/eMiRcMArcZ++Y= github.com/fluxcd/notification-controller/api v0.6.1/go.mod h1:9BiC68i6eeQTERhrMo0dni51uKSlt/eMiRcMArcZ++Y=
github.com/fluxcd/pkg/apis/meta v0.5.0 h1:FaU++mQY0g4sVVl+hG+vk0CXBLbb4EVfRuzs3IjLXvo= github.com/fluxcd/pkg/apis/meta v0.5.0 h1:FaU++mQY0g4sVVl+hG+vk0CXBLbb4EVfRuzs3IjLXvo=

View File

@@ -0,0 +1,55 @@
/*
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/v1beta1"
"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, ", "))
}

View File

@@ -0,0 +1,47 @@
/*
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/v1beta1"
)
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)
}
})
}
}

View File

@@ -1,8 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- https://github.com/fluxcd/kustomize-controller/archive/v0.6.1.zip//kustomize-controller-0.6.1/config/crd - https://github.com/fluxcd/kustomize-controller/archive/v0.6.2.zip//kustomize-controller-0.6.2/config/crd
- https://github.com/fluxcd/kustomize-controller/archive/v0.6.1.zip//kustomize-controller-0.6.1/config/manager - https://github.com/fluxcd/kustomize-controller/archive/v0.6.2.zip//kustomize-controller-0.6.2/config/manager
patchesJson6902: patchesJson6902:
- target: - target:
group: apps group: apps

View File

@@ -18,8 +18,6 @@ package sync
import ( import (
"time" "time"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
) )
type Options struct { type Options struct {
@@ -42,6 +40,6 @@ func MakeDefaultOptions() Options {
Branch: "main", Branch: "main",
ManifestFile: "gotk-sync.yaml", ManifestFile: "gotk-sync.yaml",
TargetPath: "", TargetPath: "",
GitImplementation: sourcev1.GoGitImplementation, GitImplementation: "",
} }
} }