Fix duration default values
Signed-off-by: Philip Laine <philip.laine@xenit.se>
This commit is contained in:
parent
d67dd6cd58
commit
01d0053871
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||
package v1beta1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -26,7 +24,6 @@ import (
|
|||
|
||||
const (
|
||||
BucketKind = "Bucket"
|
||||
BucketTimeout = time.Second * 20
|
||||
)
|
||||
|
||||
// BucketSpec defines the desired state of an S3 compatible bucket
|
||||
|
@ -63,6 +60,7 @@ type BucketSpec struct {
|
|||
Interval metav1.Duration `json:"interval"`
|
||||
|
||||
// The timeout for download operations, defaults to 20s.
|
||||
// +kubebuilder:default="20s"
|
||||
// +optional
|
||||
Timeout *metav1.Duration `json:"timeout,omitempty"`
|
||||
|
||||
|
@ -159,14 +157,6 @@ func BucketReadyMessage(bucket Bucket) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// GetTimeout returns the configured timeout or the default.
|
||||
func (in *Bucket) GetTimeout() time.Duration {
|
||||
if in.Spec.Timeout != nil {
|
||||
return in.Spec.Timeout.Duration
|
||||
}
|
||||
return BucketTimeout
|
||||
}
|
||||
|
||||
// GetArtifact returns the latest artifact from the source if present in the
|
||||
// status sub-resource.
|
||||
func (in *Bucket) GetArtifact() *Artifact {
|
||||
|
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||
package v1beta1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -26,7 +24,6 @@ import (
|
|||
|
||||
const (
|
||||
GitRepositoryKind = "GitRepository"
|
||||
GitRepositoryTimeout = time.Second * 20
|
||||
)
|
||||
|
||||
// GitRepositorySpec defines the desired state of a Git repository.
|
||||
|
@ -49,13 +46,12 @@ type GitRepositorySpec struct {
|
|||
Interval metav1.Duration `json:"interval"`
|
||||
|
||||
// The timeout for remote Git operations like cloning, defaults to 20s.
|
||||
// +kubebuilder:default:=20
|
||||
// +kubebuilder:default="20s"
|
||||
// +optional
|
||||
Timeout *metav1.Duration `json:"timeout,omitempty"`
|
||||
|
||||
// The Git reference to checkout and monitor for changes, defaults to
|
||||
// master branch.
|
||||
// +kubebuilder:default:=master
|
||||
// +optional
|
||||
Reference *GitRepositoryRef `json:"ref,omitempty"`
|
||||
|
||||
|
@ -184,14 +180,6 @@ func GitRepositoryReadyMessage(repository GitRepository) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// GetTimeout returns the configured timeout or the default.
|
||||
func (in *GitRepository) GetTimeout() time.Duration {
|
||||
if in.Spec.Timeout != nil {
|
||||
return in.Spec.Timeout.Duration
|
||||
}
|
||||
return GitRepositoryTimeout
|
||||
}
|
||||
|
||||
// GetArtifact returns the latest artifact from the source if present in the
|
||||
// status sub-resource.
|
||||
func (in *GitRepository) GetArtifact() *Artifact {
|
||||
|
|
|
@ -32,7 +32,7 @@ type HelmChartSpec struct {
|
|||
|
||||
// The chart version semver expression, ignored for charts from GitRepository
|
||||
// and Bucket sources. Defaults to latest when omitted.
|
||||
// +kubebuilder:default:=latest
|
||||
// +kubebuilder:default:=*
|
||||
// +optional
|
||||
Version string `json:"version,omitempty"`
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||
package v1beta1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -27,9 +25,6 @@ import (
|
|||
const (
|
||||
// HelmRepositoryKind is the string representation of a HelmRepository.
|
||||
HelmRepositoryKind = "HelmRepository"
|
||||
// HelmRepositoryTimeout is the default timeout used for Helm repository
|
||||
// operations like fetching indexes, or downloading charts from a repository.
|
||||
HelmRepositoryTimeout = time.Second * 60
|
||||
// HelmRepositoryURLIndexKey is the key to use for indexing HelmRepository
|
||||
// resources by their HelmRepositorySpec.URL.
|
||||
HelmRepositoryURLIndexKey = ".metadata.helmRepositoryURL"
|
||||
|
@ -55,6 +50,7 @@ type HelmRepositorySpec struct {
|
|||
Interval metav1.Duration `json:"interval"`
|
||||
|
||||
// The timeout of index downloading, defaults to 60s.
|
||||
// +kubebuilder:default:="60s"
|
||||
// +optional
|
||||
Timeout *metav1.Duration `json:"timeout,omitempty"`
|
||||
}
|
||||
|
@ -153,14 +149,6 @@ func (in *HelmRepository) GetInterval() metav1.Duration {
|
|||
return in.Spec.Interval
|
||||
}
|
||||
|
||||
// GetTimeout returns the configured timeout or the default.
|
||||
func (in *HelmRepository) GetTimeout() time.Duration {
|
||||
if in.Spec.Timeout != nil {
|
||||
return in.Spec.Timeout.Duration
|
||||
}
|
||||
return HelmRepositoryTimeout
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:Namespaced
|
||||
// +kubebuilder:object:root=true
|
||||
|
|
|
@ -69,6 +69,7 @@ spec:
|
|||
description: The interval at which to check for bucket updates.
|
||||
type: string
|
||||
provider:
|
||||
default: generic
|
||||
description: The S3 compatible storage provider name, default ('generic').
|
||||
enum:
|
||||
- generic
|
||||
|
@ -87,7 +88,12 @@ spec:
|
|||
type: string
|
||||
type: object
|
||||
timeout:
|
||||
<<<<<<< HEAD
|
||||
description: The timeout for download operations, defaults to 20s.
|
||||
=======
|
||||
default: 20s
|
||||
description: The timeout for download operations, default ('20s').
|
||||
>>>>>>> 0948720 (Fix duration default values)
|
||||
type: string
|
||||
required:
|
||||
- bucketName
|
||||
|
|
|
@ -63,7 +63,12 @@ spec:
|
|||
defaults to master branch.
|
||||
properties:
|
||||
branch:
|
||||
<<<<<<< HEAD
|
||||
description: The Git branch to checkout, defaults to master.
|
||||
=======
|
||||
default: master
|
||||
description: The git branch to checkout, defaults to master.
|
||||
>>>>>>> 0948720 (Fix duration default values)
|
||||
type: string
|
||||
commit:
|
||||
description: The Git commit SHA to checkout, if specified Tag
|
||||
|
@ -89,7 +94,12 @@ spec:
|
|||
type: string
|
||||
type: object
|
||||
timeout:
|
||||
<<<<<<< HEAD
|
||||
description: The timeout for remote Git operations like cloning, defaults
|
||||
=======
|
||||
default: 20s
|
||||
description: The timeout for remote git operations like cloning, default
|
||||
>>>>>>> 0948720 (Fix duration default values)
|
||||
to 20s.
|
||||
type: string
|
||||
url:
|
||||
|
|
|
@ -91,6 +91,7 @@ spec:
|
|||
expected to be a relative path in the SourceRef. Ignored when omitted.
|
||||
type: string
|
||||
version:
|
||||
default: '*'
|
||||
description: The chart version semver expression, ignored for charts
|
||||
from GitRepository and Bucket sources. Defaults to latest when omitted.
|
||||
type: string
|
||||
|
|
|
@ -64,6 +64,7 @@ spec:
|
|||
type: string
|
||||
type: object
|
||||
timeout:
|
||||
default: 60s
|
||||
description: The timeout of index downloading, defaults to 60s.
|
||||
type: string
|
||||
url:
|
||||
|
|
|
@ -173,7 +173,7 @@ func (r *BucketReconciler) reconcile(ctx context.Context, bucket sourcev1.Bucket
|
|||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
ctxTimeout, cancel := context.WithTimeout(ctx, bucket.GetTimeout())
|
||||
ctxTimeout, cancel := context.WithTimeout(ctx, bucket.Spec.Timeout.Duration)
|
||||
defer cancel()
|
||||
|
||||
exists, err := s3Client.BucketExists(ctxTimeout, bucket.Spec.BucketName)
|
||||
|
|
|
@ -252,7 +252,7 @@ func (r *HelmChartReconciler) reconcileFromHelmRepository(ctx context.Context,
|
|||
|
||||
clientOpts = opts
|
||||
}
|
||||
clientOpts = append(clientOpts, getter.WithTimeout(repository.GetTimeout()))
|
||||
clientOpts = append(clientOpts, getter.WithTimeout(repository.Spec.Timeout.Duration))
|
||||
|
||||
// Initialize the chart repository and load the index file
|
||||
chartRepo, err := helm.NewChartRepository(repository.Spec.URL, r.Getters, clientOpts)
|
||||
|
|
|
@ -181,7 +181,7 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, repository sou
|
|||
defer cleanup()
|
||||
clientOpts = opts
|
||||
}
|
||||
clientOpts = append(clientOpts, getter.WithTimeout(repository.GetTimeout()))
|
||||
clientOpts = append(clientOpts, getter.WithTimeout(repository.Spec.Timeout.Duration))
|
||||
|
||||
chartRepo, err := helm.NewChartRepository(repository.Spec.URL, r.Getters, clientOpts)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue