mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-08 00:37:27 +00:00
Merge pull request #2035 from fluxcd/source-fetch-timeout
Add fetch timeout arg to create source commands
This commit is contained in:
commit
b8a85b809a
4 changed files with 23 additions and 0 deletions
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
|
@ -26,6 +28,14 @@ var createSourceCmd = &cobra.Command{
|
|||
Long: "The create source sub-commands generate sources.",
|
||||
}
|
||||
|
||||
type createSourceFlags struct {
|
||||
fetchTimeout time.Duration
|
||||
}
|
||||
|
||||
var createSourceArgs createSourceFlags
|
||||
|
||||
func init() {
|
||||
createSourceCmd.PersistentFlags().DurationVar(&createSourceArgs.fetchTimeout, "fetch-timeout", createSourceArgs.fetchTimeout,
|
||||
"set a timeout for fetch operations performed by source-controller (e.g. 'git clone' or 'helm repo update')")
|
||||
createCmd.AddCommand(createSourceCmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,11 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
if createSourceArgs.fetchTimeout > 0 {
|
||||
bucket.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
|
||||
}
|
||||
|
||||
if sourceBucketArgs.secretRef != "" {
|
||||
bucket.Spec.SecretRef = &meta.LocalObjectReference{
|
||||
Name: sourceBucketArgs.secretRef,
|
||||
|
|
|
|||
|
|
@ -206,6 +206,10 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||
},
|
||||
}
|
||||
|
||||
if createSourceArgs.fetchTimeout > 0 {
|
||||
gitRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
|
||||
}
|
||||
|
||||
if sourceGitArgs.gitImplementation != "" {
|
||||
gitRepository.Spec.GitImplementation = sourceGitArgs.gitImplementation.String()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,10 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
|||
},
|
||||
}
|
||||
|
||||
if createSourceArgs.fetchTimeout > 0 {
|
||||
helmRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
|
||||
}
|
||||
|
||||
if sourceHelmArgs.secretRef != "" {
|
||||
helmRepository.Spec.SecretRef = &meta.LocalObjectReference{
|
||||
Name: sourceHelmArgs.secretRef,
|
||||
|
|
|
|||
Loading…
Reference in a new issue