1
1
package utils
2
2
3
3
import (
4
- "errors"
5
4
"fmt"
6
5
7
6
"github.com/securesign/operator/api/v1alpha1"
@@ -12,17 +11,23 @@ import (
12
11
)
13
12
14
13
func CreateRekorDeployment (instance * v1alpha1.Rekor , dpName string , sa string , labels map [string ]string ) (* apps.Deployment , error ) {
15
- if instance .Status .ServerConfigRef == nil {
16
- return nil , errors .New ("server config name not specified" )
17
- }
18
- if instance .Status .TreeID == nil {
19
- return nil , errors .New ("reference to trillian TreeID not set" )
14
+ switch {
15
+ case instance .Status .ServerConfigRef == nil :
16
+ return nil , fmt .Errorf ("CreateRekorDeployment: %w" , ServerConfigNotSpecified )
17
+ case instance .Status .TreeID == nil :
18
+ return nil , fmt .Errorf ("CreateRekorDeployment: %w" , TreeNotSpecified )
19
+ case instance .Spec .Trillian .Address == "" :
20
+ return nil , fmt .Errorf ("CreateRekorDeployment: %w" , TrillianAddressNotSpecified )
21
+ case instance .Spec .Trillian .Port == nil :
22
+ return nil , fmt .Errorf ("CreateRekorDeployment: %w" , TrillianPortNotSpecified )
20
23
}
24
+
21
25
env := make ([]core.EnvVar , 0 )
26
+
22
27
appArgs := []string {
23
28
"serve" ,
24
- "--trillian_log_server.address=trillian-logserver. " + instance .Namespace + ".svc" ,
25
- "--trillian_log_server.port=8091" ,
29
+ "--trillian_log_server.address=" + instance .Spec . Trillian . Address ,
30
+ fmt . Sprintf ( "--trillian_log_server.port=%d" , * instance . Spec . Trillian . Port ) ,
26
31
"--trillian_log_server.sharding_config=/sharding/sharding-config.yaml" ,
27
32
"--redis_server.address=rekor-redis" ,
28
33
"--redis_server.port=6379" ,
@@ -71,7 +76,7 @@ func CreateRekorDeployment(instance *v1alpha1.Rekor, dpName string, sa string, l
71
76
// KMS secret
72
77
if instance .Spec .Signer .KMS == "secret" || instance .Spec .Signer .KMS == "" {
73
78
if instance .Status .Signer .KeyRef == nil {
74
- return nil , errors . New ( "signer key ref not specified" )
79
+ return nil , SignerKeyNotSpecified
75
80
}
76
81
svsPrivate := & core.SecretVolumeSource {
77
82
SecretName : instance .Status .Signer .KeyRef .Name ,
0 commit comments