Skip to content

Commit

Permalink
diagnostics: fix use of DiagnosticPod params
Browse files Browse the repository at this point in the history
When running DiagnosticPod, a new Diagnostic was built instead of using
the one created for the command that had parameters set from flags; thus
DiagnosticPod-specific flags had no effect. Fixed that.
  • Loading branch information
sosiouxme committed Jan 19, 2018
1 parent a9387ba commit 2c2b52a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pkg/oc/admin/diagnostics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"

"github.com/openshift/origin/pkg/cmd/util/variable"
clientdiags "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/client"
networkdiags "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/network"
"github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/types"
Expand Down Expand Up @@ -47,14 +46,13 @@ func (o DiagnosticsOptions) buildClientDiagnostics(rawConfig *clientcmdapi.Confi
}
}
case clientdiags.DiagnosticPodName:
diagnostics = append(diagnostics, &clientdiags.DiagnosticPod{
KubeClient: kubeClient,
Namespace: rawConfig.Contexts[rawConfig.CurrentContext].Namespace,
Level: o.LogOptions.Level,
Factory: o.Factory,
PreventModification: o.PreventModification,
ImageTemplate: variable.NewDefaultImageTemplate(),
})
dp := o.ParameterizedDiagnostics[diagnosticName].(*clientdiags.DiagnosticPod)
dp.KubeClient = kubeClient
dp.Namespace = rawConfig.Contexts[rawConfig.CurrentContext].Namespace
dp.Level = o.LogOptions.Level
dp.Factory = o.Factory
dp.PreventModification = dp.PreventModification || o.PreventModification
diagnostics = append(diagnostics, dp)
case networkdiags.NetworkDiagnosticName:
nd := o.ParameterizedDiagnostics[diagnosticName].(*networkdiags.NetworkDiagnostic)
nd.KubeClient = kubeClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type DiagnosticPod struct {
ImageTemplate variable.ImageTemplate
}

var _ types.ParameterizedDiagnostic = (*DiagnosticPod)(nil)

// Name is part of the Diagnostic interface and just returns name.
func (d *DiagnosticPod) Name() string {
return DiagnosticPodName
Expand Down

0 comments on commit 2c2b52a

Please sign in to comment.