@@ -6,21 +6,22 @@ import (
6
6
"k8s.io/apimachinery/pkg/util/sets"
7
7
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
8
8
9
+ "github.com/openshift/origin/pkg/cmd/util/variable"
9
10
clientdiags "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/client"
10
11
networkdiags "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/network"
11
12
"github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/types"
12
13
)
13
14
14
- var (
15
- // availableClientDiagnostics contains the names of client diagnostics that can be executed
16
- // during a single run of diagnostics. Add more diagnostics to the list as they are defined.
17
- availableClientDiagnostics = sets . NewString ( clientdiags .ConfigContextsName , clientdiags .DiagnosticPodName , networkdiags .NetworkDiagnosticName )
18
- )
15
+ // availableClientDiagnostics returns definitions of client diagnostics that can be executed
16
+ // during a single run of diagnostics. Add more diagnostics to the list as they are defined.
17
+ func availableClientDiagnostics () types. DiagnosticList {
18
+ return types. DiagnosticList { clientdiags.ConfigContext {}, & clientdiags.DiagnosticPod {}, & networkdiags.NetworkDiagnostic {}}
19
+ }
19
20
20
21
// buildClientDiagnostics builds client Diagnostic objects based on the rawConfig passed in.
21
22
// Returns the Diagnostics built, "ok" bool for whether to proceed or abort, and an error if any was encountered during the building of diagnostics.) {
22
23
func (o DiagnosticsOptions ) buildClientDiagnostics (rawConfig * clientcmdapi.Config ) ([]types.Diagnostic , bool , error ) {
23
- available := availableClientDiagnostics
24
+ available := availableClientDiagnostics (). Names ()
24
25
25
26
networkClient , err := o .Factory .OpenshiftInternalNetworkClient ()
26
27
kubeClient , clientErr := o .Factory .ClientSet ()
@@ -30,7 +31,7 @@ func (o DiagnosticsOptions) buildClientDiagnostics(rawConfig *clientcmdapi.Confi
30
31
}
31
32
32
33
diagnostics := []types.Diagnostic {}
33
- requestedDiagnostics := available .Intersection (sets .NewString (o .RequestedDiagnostics ... )).List ()
34
+ requestedDiagnostics := available .Intersection (sets .NewString (o .RequestedDiagnostics .List () . .. )).List ()
34
35
for _ , diagnosticName := range requestedDiagnostics {
35
36
switch diagnosticName {
36
37
case clientdiags .ConfigContextsName :
@@ -52,23 +53,18 @@ func (o DiagnosticsOptions) buildClientDiagnostics(rawConfig *clientcmdapi.Confi
52
53
Level : o .LogOptions .Level ,
53
54
Factory : o .Factory ,
54
55
PreventModification : o .PreventModification ,
55
- ImageTemplate : o . ImageTemplate ,
56
+ ImageTemplate : variable . NewDefaultImageTemplate () ,
56
57
})
57
58
case networkdiags .NetworkDiagnosticName :
58
- diagnostics = append (diagnostics , & networkdiags.NetworkDiagnostic {
59
- KubeClient : kubeClient ,
60
- NetNamespacesClient : networkClient .Network (),
61
- ClusterNetworkClient : networkClient .Network (),
62
- ClientFlags : o .ClientFlags ,
63
- Level : o .LogOptions .Level ,
64
- Factory : o .Factory ,
65
- PreventModification : o .PreventModification ,
66
- LogDir : o .NetworkOptions .LogDir ,
67
- PodImage : o .NetworkOptions .PodImage ,
68
- TestPodImage : o .NetworkOptions .TestPodImage ,
69
- TestPodProtocol : o .NetworkOptions .TestPodProtocol ,
70
- TestPodPort : o .NetworkOptions .TestPodPort ,
71
- })
59
+ nd := o .ParameterizedDiagnostics [diagnosticName ].(* networkdiags.NetworkDiagnostic )
60
+ nd .KubeClient = kubeClient
61
+ nd .NetNamespacesClient = networkClient .Network ()
62
+ nd .ClusterNetworkClient = networkClient .Network ()
63
+ nd .ClientFlags = o .ClientFlags
64
+ nd .Level = o .LogOptions .Level
65
+ nd .Factory = o .Factory
66
+ nd .PreventModification = o .PreventModification
67
+ diagnostics = append (diagnostics , nd )
72
68
default :
73
69
return nil , false , fmt .Errorf ("unknown diagnostic: %v" , diagnosticName )
74
70
}
0 commit comments