Skip to content

Commit

Permalink
openshift-diagnostics: package as oc alias
Browse files Browse the repository at this point in the history
Makes `openshift-diagnostics` a symlink to `oc` (like `kubectl`) so that
it can be packaged inside origin pods to be run from diagnostics.

fixes openshift#18141
  • Loading branch information
sosiouxme committed Jan 17, 2018
1 parent 78ddc10 commit 28acb7a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 47 deletions.
46 changes: 0 additions & 46 deletions cmd/openshift-diagnostics/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion hack/lib/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ readonly OS_CROSS_COMPILE_TARGETS=(
cmd/openshift
cmd/oc
cmd/oadm
cmd/openshift-diagnostics
cmd/template-service-broker
vendor/k8s.io/kubernetes/cmd/hyperkube
)
Expand Down Expand Up @@ -75,6 +74,7 @@ readonly OPENSHIFT_BINARY_SYMLINKS=(
)
readonly OC_BINARY_COPY=(
kubectl
openshift-diagnostics
)
readonly OS_BINARY_RELEASE_CLIENT_WINDOWS=(
oc.exe
Expand Down
2 changes: 2 additions & 0 deletions origin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ do
done

ln -s oc %{buildroot}%{_bindir}/kubectl
ln -s oc %{buildroot}%{_bindir}/openshift-diagnostics

install -d -m 0755 %{buildroot}%{_sysconfdir}/origin/{master,node}

Expand Down Expand Up @@ -533,6 +534,7 @@ fi
%license LICENSE
%{_bindir}/oc
%{_bindir}/kubectl
%{_bindir}/openshift-diagnostics
%{_bindir}/oadm
%{_sysconfdir}/bash_completion.d/oc
%{_mandir}/man1/oc*
Expand Down
26 changes: 26 additions & 0 deletions pkg/oc/admin/diagnostics/inpod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package diagnostics

import (
"io"

"github.com/spf13/cobra"
)

const (
DiagnosticsInPodRecommendedName = "openshift-diagnostics"
)

// NewCmdDiagnosticsInPod defines the base command that is used inside of a pod
// orchestrated by a regular diagnostic, to report from the in-pod vantage point.
func NewCmdDiagnosticsInPod(name string, fullName string, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: name,
Short: "Diagnose OpenShift from inside a pod",
}
cmd.AddCommand(
NewCommandPodDiagnostics("diagnostic-pod", out),
NewCommandNetworkPodDiagnostics("network-diagnostic-pod", out),
)

return cmd
}
2 changes: 2 additions & 0 deletions pkg/oc/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ func CommandFor(basename string) *cobra.Command {
switch basename {
case "kubectl":
cmd = kubecmd.NewKubectlCommand(kcmdutil.NewFactory(nil), in, out, errout)
case diagnostics.DiagnosticsInPodRecommendedName:
cmd = diagnostics.NewCmdDiagnosticsInPod(basename, basename, out)
default:
cmd = NewCommandCLI("oc", "oc", in, out, errout)
}
Expand Down

0 comments on commit 28acb7a

Please sign in to comment.