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