@@ -25,27 +25,27 @@ import (
25
25
"k8s.io/kubernetes/pkg/apis/authorization"
26
26
)
27
27
28
- var (
29
- // availableClusterDiagnostics contains the names of cluster diagnostics that can be executed
30
- // during a single run of diagnostics. Add more diagnostics to the list as they are defined.
31
- availableClusterDiagnostics = sets . NewString (
32
- agldiags .AggregatedLoggingName ,
33
- clustdiags .ClusterRegistryName ,
34
- clustdiags .ClusterRouterName ,
35
- clustdiags .ClusterRolesName ,
36
- clustdiags .ClusterRoleBindingsName ,
37
- clustdiags .MasterNodeName ,
38
- clustdiags .MetricsApiProxyName ,
39
- clustdiags .NodeDefinitionsName ,
40
- clustdiags .RouteCertificateValidationName ,
41
- clustdiags .ServiceExternalIPsName ,
42
- )
43
- )
28
+ // availableClusterDiagnostics contains the names of cluster diagnostics that can be executed
29
+ // during a single run of diagnostics. Add more diagnostics to the list as they are defined.
30
+ func availableClusterDiagnostics () types. DiagnosticList {
31
+ return types. DiagnosticList {
32
+ & agldiags.AggregatedLogging {} ,
33
+ & clustdiags.ClusterRegistry {} ,
34
+ & clustdiags.ClusterRouter {} ,
35
+ & clustdiags.ClusterRoles {} ,
36
+ & clustdiags.ClusterRoleBindings {} ,
37
+ & clustdiags.MasterNode {} ,
38
+ & clustdiags.MetricsApiProxy {} ,
39
+ & clustdiags.NodeDefinitions {} ,
40
+ & clustdiags.RouteCertificateValidation {} ,
41
+ & clustdiags.ServiceExternalIPs {} ,
42
+ }
43
+ }
44
44
45
45
// buildClusterDiagnostics builds cluster Diagnostic objects if a cluster-admin client can be extracted from the rawConfig passed in.
46
46
// Returns the Diagnostics built, "ok" bool for whether to proceed or abort, and an error if any was encountered during the building of diagnostics.) {
47
- func (o DiagnosticsOptions ) buildClusterDiagnostics (rawConfig * clientcmdapi.Config ) ([]types.Diagnostic , bool , error ) {
48
- requestedDiagnostics := availableClusterDiagnostics . Intersection (sets .NewString (o .RequestedDiagnostics ... )).List ()
47
+ func (o DiagnosticsConfig ) buildClusterDiagnostics (rawConfig * clientcmdapi.Config ) ([]types.Diagnostic , bool , error ) {
48
+ requestedDiagnostics := availableClusterDiagnostics (). Names (). Intersection (sets .NewString (o .RequestedDiagnostics . List () ... )).List ()
49
49
if len (requestedDiagnostics ) == 0 { // no diagnostics to run here
50
50
return nil , true , nil // don't waste time on discovery
51
51
}
@@ -124,7 +124,7 @@ func (o DiagnosticsOptions) buildClusterDiagnostics(rawConfig *clientcmdapi.Conf
124
124
}
125
125
126
126
// attempts to find which context in the config might be a cluster-admin for the server in the current context.
127
- func (o DiagnosticsOptions ) findClusterClients (rawConfig * clientcmdapi.Config ) (* rest.Config , kclientset.Interface , bool , string , error ) {
127
+ func (o DiagnosticsConfig ) findClusterClients (rawConfig * clientcmdapi.Config ) (* rest.Config , kclientset.Interface , bool , string , error ) {
128
128
if o .ClientClusterContext != "" { // user has specified cluster context to use
129
129
if context , exists := rawConfig .Contexts [o .ClientClusterContext ]; ! exists {
130
130
configErr := fmt .Errorf ("Specified '%s' as cluster-admin context, but it was not found in your client configuration." , o .ClientClusterContext )
@@ -160,7 +160,7 @@ func (o DiagnosticsOptions) findClusterClients(rawConfig *clientcmdapi.Config) (
160
160
}
161
161
162
162
// makes the client from the specified context and determines whether it is a cluster-admin.
163
- func (o DiagnosticsOptions ) makeClusterClients (rawConfig * clientcmdapi.Config , contextName string , context * clientcmdapi.Context ) (* rest.Config , kclientset.Interface , bool , string , error ) {
163
+ func (o DiagnosticsConfig ) makeClusterClients (rawConfig * clientcmdapi.Config , contextName string , context * clientcmdapi.Context ) (* rest.Config , kclientset.Interface , bool , string , error ) {
164
164
overrides := & clientcmd.ConfigOverrides {Context : * context }
165
165
clientConfig := clientcmd .NewDefaultClientConfig (* rawConfig , overrides )
166
166
serverUrl := rawConfig .Clusters [context .Cluster ].Server
0 commit comments