-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
54 lines (38 loc) · 1.15 KB
/
options.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2022 Fujitsu Limited
package options
import (
"github.com/spf13/pflag"
datastoreconfig "github.com/FujitsuResearch/data-sharing-controllers-on-k8s/pkg/datastore/config"
)
const (
defaultEndpoint = ":8443"
defaultPath = "/lcm/policy"
)
type PolicyValidatorOptions struct {
Endpoint string
Path string
TlsConfig *WebhookTlsOptions
DataStore *datastoreconfig.DataStoreOptions
KubernetesConfig *KubernetesOptions
}
func NewPolicyValidatorOptions() *PolicyValidatorOptions {
return &PolicyValidatorOptions{
Endpoint: defaultEndpoint,
Path: defaultPath,
TlsConfig: newWebhookTlsOptions(),
DataStore: datastoreconfig.NewDataStoreOptions(),
KubernetesConfig: newKubernetesOptions(),
}
}
func (pvo *PolicyValidatorOptions) AddFlags(flagSet *pflag.FlagSet) {
flagSet.StringVar(
&pvo.Endpoint, "endpoint", pvo.Endpoint,
"Endpoint of the policy validator. "+
"The endpoint format is URL or k8s 'service' name.")
flagSet.StringVar(
&pvo.Path, "api-path", pvo.Path,
"API path for the policy validator.")
pvo.TlsConfig.addFlags(flagSet)
pvo.DataStore.AddFlags(flagSet)
pvo.KubernetesConfig.AddFlags(flagSet)
}