-
Notifications
You must be signed in to change notification settings - Fork 209
/
config_refs.go
145 lines (118 loc) · 3.34 KB
/
config_refs.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package helpers
import (
"strings"
configv1 "github.com/openshift/api/config/v1"
)
func GetHTTPServingInfoFileReferences(config *configv1.HTTPServingInfo) []*string {
if config == nil {
return []*string{}
}
return GetServingInfoFileReferences(&config.ServingInfo)
}
func GetServingInfoFileReferences(config *configv1.ServingInfo) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, GetCertFileReferences(&config.CertInfo)...)
refs = append(refs, &config.ClientCA)
for i := range config.NamedCertificates {
refs = append(refs, &config.NamedCertificates[i].CertFile)
refs = append(refs, &config.NamedCertificates[i].KeyFile)
}
return refs
}
func GetCertFileReferences(config *configv1.CertInfo) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, &config.CertFile)
refs = append(refs, &config.KeyFile)
return refs
}
func GetRemoteConnectionInfoFileReferences(config *configv1.RemoteConnectionInfo) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, GetCertFileReferences(&config.CertInfo)...)
refs = append(refs, &config.CA)
return refs
}
func GetEtcdConnectionInfoFileReferences(config *configv1.EtcdConnectionInfo) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, GetCertFileReferences(&config.CertInfo)...)
refs = append(refs, &config.CA)
return refs
}
func GetStringSourceFileReferences(s *configv1.StringSource) []*string {
if s == nil {
return []*string{}
}
return []*string{
&s.File,
&s.KeyFile,
}
}
func GetAdmissionPluginConfigFileReferences(config *configv1.AdmissionPluginConfig) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, &config.Location)
return refs
}
func GetAuditConfigFileReferences(config *configv1.AuditConfig) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, &config.PolicyFile)
refs = append(refs, &config.AuditFilePath)
return refs
}
func GetKubeClientConfigFileReferences(config *configv1.KubeClientConfig) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, &config.KubeConfig)
return refs
}
func GetGenericAPIServerConfigFileReferences(config *configv1.GenericAPIServerConfig) []*string {
if config == nil {
return []*string{}
}
refs := []*string{}
refs = append(refs, GetHTTPServingInfoFileReferences(&config.ServingInfo)...)
refs = append(refs, GetEtcdConnectionInfoFileReferences(&config.StorageConfig.EtcdConnectionInfo)...)
refs = append(refs, GetAuditConfigFileReferences(&config.AuditConfig)...)
refs = append(refs, GetKubeClientConfigFileReferences(&config.KubeClientConfig)...)
// TODO admission config file resolution is currently broken.
//for k := range config.AdmissionPluginConfig {
// refs = append(refs, GetAdmissionPluginConfigReferences(&(config.AdmissionPluginConfig[k]))...)
//}
return refs
}
func GetFlagsWithFileExtensionsFileReferences(args map[string][]string) []*string {
if args == nil {
return []*string{}
}
refs := []*string{}
for key, s := range args {
if len(s) == 0 {
continue
}
if !strings.HasSuffix(key, "-file") && !strings.HasSuffix(key, "-dir") {
continue
}
for i := range s {
refs = append(refs, &s[i])
}
}
return refs
}