mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-24 08:31:47 +00:00
Merge pull request #1240 from fluxcd/to-slash-to-rescue
This commit is contained in:
commit
d434575047
6 changed files with 17 additions and 8 deletions
|
|
@ -134,7 +134,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
NotificationController: rootArgs.defaults.NotificationController,
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
ManifestFile: rootArgs.defaults.ManifestFile,
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
Timeout: rootArgs.timeout,
|
Timeout: rootArgs.timeout,
|
||||||
TargetPath: gitArgs.path.String(),
|
TargetPath: gitArgs.path.ToSlash(),
|
||||||
ClusterDomain: bootstrapArgs.clusterDomain,
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
TolerationKeys: bootstrapArgs.tolerationKeys,
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
NotificationController: rootArgs.defaults.NotificationController,
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
ManifestFile: rootArgs.defaults.ManifestFile,
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
Timeout: rootArgs.timeout,
|
Timeout: rootArgs.timeout,
|
||||||
TargetPath: githubArgs.path.String(),
|
TargetPath: githubArgs.path.ToSlash(),
|
||||||
ClusterDomain: bootstrapArgs.clusterDomain,
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
TolerationKeys: bootstrapArgs.tolerationKeys,
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +180,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
secretOpts := sourcesecret.Options{
|
secretOpts := sourcesecret.Options{
|
||||||
Name: bootstrapArgs.secretName,
|
Name: bootstrapArgs.secretName,
|
||||||
Namespace: rootArgs.namespace,
|
Namespace: rootArgs.namespace,
|
||||||
TargetPath: githubArgs.path.String(),
|
TargetPath: githubArgs.path.ToSlash(),
|
||||||
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
|
||||||
}
|
}
|
||||||
if bootstrapArgs.tokenAuth {
|
if bootstrapArgs.tokenAuth {
|
||||||
|
|
@ -208,7 +208,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
Namespace: rootArgs.namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Branch: bootstrapArgs.branch,
|
Branch: bootstrapArgs.branch,
|
||||||
Secret: bootstrapArgs.secretName,
|
Secret: bootstrapArgs.secretName,
|
||||||
TargetPath: githubArgs.path.String(),
|
TargetPath: githubArgs.path.ToSlash(),
|
||||||
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
||||||
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
||||||
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
NotificationController: rootArgs.defaults.NotificationController,
|
NotificationController: rootArgs.defaults.NotificationController,
|
||||||
ManifestFile: rootArgs.defaults.ManifestFile,
|
ManifestFile: rootArgs.defaults.ManifestFile,
|
||||||
Timeout: rootArgs.timeout,
|
Timeout: rootArgs.timeout,
|
||||||
TargetPath: gitlabArgs.path.String(),
|
TargetPath: gitlabArgs.path.ToSlash(),
|
||||||
ClusterDomain: bootstrapArgs.clusterDomain,
|
ClusterDomain: bootstrapArgs.clusterDomain,
|
||||||
TolerationKeys: bootstrapArgs.tolerationKeys,
|
TolerationKeys: bootstrapArgs.tolerationKeys,
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
Namespace: rootArgs.namespace,
|
Namespace: rootArgs.namespace,
|
||||||
Branch: bootstrapArgs.branch,
|
Branch: bootstrapArgs.branch,
|
||||||
Secret: bootstrapArgs.secretName,
|
Secret: bootstrapArgs.secretName,
|
||||||
TargetPath: gitlabArgs.path.String(),
|
TargetPath: gitlabArgs.path.ToSlash(),
|
||||||
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
|
||||||
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
GitImplementation: sourceGitArgs.gitImplementation.String(),
|
||||||
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -151,7 +150,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
Interval: metav1.Duration{
|
Interval: metav1.Duration{
|
||||||
Duration: createArgs.interval,
|
Duration: createArgs.interval,
|
||||||
},
|
},
|
||||||
Path: filepath.ToSlash(kustomizationArgs.path.String()),
|
Path: kustomizationArgs.path.ToSlash(),
|
||||||
Prune: kustomizationArgs.prune,
|
Prune: kustomizationArgs.prune,
|
||||||
SourceRef: kustomizev1.CrossNamespaceSourceReference{
|
SourceRef: kustomizev1.CrossNamespaceSourceReference{
|
||||||
Kind: kustomizationArgs.source.Kind,
|
Kind: kustomizationArgs.source.Kind,
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,11 @@ func kustomizationReconciled(ctx context.Context, kube client.Client, objKey cli
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect suspended Kustomization, as this would result in an endless wait
|
||||||
|
if kustomization.Spec.Suspend {
|
||||||
|
return false, fmt.Errorf("Kustomization is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
// Confirm the state we are observing is for the current generation
|
// Confirm the state we are observing is for the current generation
|
||||||
if kustomization.Generation != kustomization.Status.ObservedGeneration {
|
if kustomization.Generation != kustomization.Status.ObservedGeneration {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package flags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
securejoin "github.com/cyphar/filepath-securejoin"
|
securejoin "github.com/cyphar/filepath-securejoin"
|
||||||
|
|
@ -29,6 +30,10 @@ func (p *SafeRelativePath) String() string {
|
||||||
return string(*p)
|
return string(*p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *SafeRelativePath) ToSlash() string {
|
||||||
|
return filepath.ToSlash(p.String())
|
||||||
|
}
|
||||||
|
|
||||||
func (p *SafeRelativePath) Set(str string) error {
|
func (p *SafeRelativePath) Set(str string) error {
|
||||||
// The result of secure joining on a relative base dir is a flattened relative path.
|
// The result of secure joining on a relative base dir is a flattened relative path.
|
||||||
cleanP, err := securejoin.SecureJoin("./", strings.TrimSpace(str))
|
cleanP, err := securejoin.SecureJoin("./", strings.TrimSpace(str))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue