@@ -25,22 +25,21 @@ package v1alpha
2525import (
2626 "fmt"
2727 "net"
28- "time"
2928
3029 "github.com/arangodb/kube-arangodb/pkg/util"
3130 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3231 "github.com/arangodb/kube-arangodb/pkg/util/validation"
3332)
3433
3534const (
36- defaultTLSTTL = time . Hour * 2160 // About 3 month
35+ defaultTLSTTL = Duration ( "2610h" ) // About 3 month
3736)
3837
3938// TLSSpec holds TLS specific configuration settings
4039type TLSSpec struct {
41- CASecretName * string `json:"caSecretName,omitempty"`
42- AltNames []string `json:"altNames,omitempty"`
43- TTL * time. Duration `json:"ttl,omitempty"`
40+ CASecretName * string `json:"caSecretName,omitempty"`
41+ AltNames []string `json:"altNames,omitempty"`
42+ TTL * Duration `json:"ttl,omitempty"`
4443}
4544
4645const (
@@ -59,8 +58,8 @@ func (s TLSSpec) GetAltNames() []string {
5958}
6059
6160// GetTTL returns the value of ttl.
62- func (s TLSSpec ) GetTTL () time. Duration {
63- return util . DurationOrDefault (s .TTL )
61+ func (s TLSSpec ) GetTTL () Duration {
62+ return DurationOrDefault (s .TTL )
6463}
6564
6665// IsSecure returns true when a CA secret has been set, false otherwise.
@@ -94,6 +93,9 @@ func (s TLSSpec) Validate() error {
9493 if _ , _ , _ , err := s .GetParsedAltNames (); err != nil {
9594 return maskAny (err )
9695 }
96+ if err := s .GetTTL ().Validate (); err != nil {
97+ return maskAny (err )
98+ }
9799 }
98100 return nil
99101}
@@ -105,10 +107,10 @@ func (s *TLSSpec) SetDefaults(defaultCASecretName string) {
105107 // string should result in the default value.
106108 s .CASecretName = util .NewString (defaultCASecretName )
107109 }
108- if s .GetTTL () == 0 {
110+ if s .GetTTL () == "" {
109111 // Note that we don't check for nil here, since even a specified, but zero
110112 // should result in the default value.
111- s .TTL = util . NewDuration (defaultTLSTTL )
113+ s .TTL = NewDuration (defaultTLSTTL )
112114 }
113115}
114116
@@ -121,6 +123,6 @@ func (s *TLSSpec) SetDefaultsFrom(source TLSSpec) {
121123 s .AltNames = source .AltNames
122124 }
123125 if s .TTL == nil {
124- s .TTL = util . NewDurationOrNil (source .TTL )
126+ s .TTL = NewDurationOrNil (source .TTL )
125127 }
126128}
0 commit comments