@@ -25,22 +25,21 @@ package v1alpha
25
25
import (
26
26
"fmt"
27
27
"net"
28
- "time"
29
28
30
29
"github.com/arangodb/kube-arangodb/pkg/util"
31
30
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
32
31
"github.com/arangodb/kube-arangodb/pkg/util/validation"
33
32
)
34
33
35
34
const (
36
- defaultTLSTTL = time . Hour * 2160 // About 3 month
35
+ defaultTLSTTL = Duration ( "2610h" ) // About 3 month
37
36
)
38
37
39
38
// TLSSpec holds TLS specific configuration settings
40
39
type 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"`
44
43
}
45
44
46
45
const (
@@ -59,8 +58,8 @@ func (s TLSSpec) GetAltNames() []string {
59
58
}
60
59
61
60
// 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 )
64
63
}
65
64
66
65
// IsSecure returns true when a CA secret has been set, false otherwise.
@@ -94,6 +93,9 @@ func (s TLSSpec) Validate() error {
94
93
if _ , _ , _ , err := s .GetParsedAltNames (); err != nil {
95
94
return maskAny (err )
96
95
}
96
+ if err := s .GetTTL ().Validate (); err != nil {
97
+ return maskAny (err )
98
+ }
97
99
}
98
100
return nil
99
101
}
@@ -105,10 +107,10 @@ func (s *TLSSpec) SetDefaults(defaultCASecretName string) {
105
107
// string should result in the default value.
106
108
s .CASecretName = util .NewString (defaultCASecretName )
107
109
}
108
- if s .GetTTL () == 0 {
110
+ if s .GetTTL () == "" {
109
111
// Note that we don't check for nil here, since even a specified, but zero
110
112
// should result in the default value.
111
- s .TTL = util . NewDuration (defaultTLSTTL )
113
+ s .TTL = NewDuration (defaultTLSTTL )
112
114
}
113
115
}
114
116
@@ -121,6 +123,6 @@ func (s *TLSSpec) SetDefaultsFrom(source TLSSpec) {
121
123
s .AltNames = source .AltNames
122
124
}
123
125
if s .TTL == nil {
124
- s .TTL = util . NewDurationOrNil (source .TTL )
126
+ s .TTL = NewDurationOrNil (source .TTL )
125
127
}
126
128
}
0 commit comments