Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c29a7a72 | ||
|
|
e243df93f1 | ||
|
|
388642d9dd | ||
|
|
9e1db06936 | ||
|
|
a260403334 | ||
|
|
6396b25886 | ||
|
|
ca480164b7 | ||
|
|
714f9df3cf |
@@ -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)
|
||||||
|
|||||||
@@ -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 != "" {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
2
go.mod
@@ -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
4
go.sum
@@ -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=
|
||||||
|
|||||||
55
internal/flags/git_implementation.go
Normal file
55
internal/flags/git_implementation.go
Normal 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, ", "))
|
||||||
|
}
|
||||||
47
internal/flags/git_implementation_test.go
Normal file
47
internal/flags/git_implementation_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user