forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signer_cert_args.go
39 lines (31 loc) · 1.15 KB
/
signer_cert_args.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package admin
import (
"errors"
"github.com/spf13/pflag"
"github.com/openshift/origin/pkg/cmd/server/crypto"
)
type GetSignerCertOptions struct {
CertFile string
KeyFile string
SerialFile string
}
func BindGetSignerCertOptions(options *GetSignerCertOptions, flags *pflag.FlagSet, prefix string) {
flags.StringVar(&options.CertFile, prefix+"signer-cert", "openshift.local.config/master/ca.crt", "The certificate file.")
flags.StringVar(&options.KeyFile, prefix+"signer-key", "openshift.local.config/master/ca.key", "The key file.")
flags.StringVar(&options.SerialFile, prefix+"signer-serial", "openshift.local.config/master/ca.serial.txt", "The serial file that keeps track of how many certs have been signed.")
}
func (o GetSignerCertOptions) Validate() error {
if len(o.CertFile) == 0 {
return errors.New("signer-cert must be provided")
}
if len(o.KeyFile) == 0 {
return errors.New("signer-key must be provided")
}
if len(o.SerialFile) == 0 {
return errors.New("signer-serial must be provided")
}
return nil
}
func (o GetSignerCertOptions) GetSignerCert() (*crypto.CA, error) {
return crypto.GetCA(o.CertFile, o.KeyFile, o.SerialFile)
}