Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status: Report tls routes with unspecified termination type #6078

Merged
merged 2 commits into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ _oc_status()

flags+=("--output=")
two_word_flags+=("-o")
flags+=("--verbose")
flags+=("-v")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -5336,6 +5336,8 @@ _openshift_cli_status()

flags+=("--output=")
two_word_flags+=("-o")
flags+=("--verbose")
flags+=("-v")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--boot-id-file=")
Expand Down
8 changes: 7 additions & 1 deletion docs/generated/oc_by_example_content.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,14 @@ Show an overview of the current project

[options="nowrap"]
----
# Show an overview of the current project
# See an overview of the current project.
$ oc status

# Export the overview of the current project in an svg file.
$ oc status -o dot | dot -T svg -o project.svg

# See an overview of the current project including details for any identified issues.
$ oc status -v
----
====

Expand Down
12 changes: 12 additions & 0 deletions pkg/api/graph/interfaces.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package graph

import (
"fmt"

"github.com/gonum/graph"
)

Expand All @@ -15,8 +17,12 @@ type Marker struct {
Severity Severity
// Key is a short string to identify this message
Key string

// Message is a human-readable string that describes what is interesting
Message string
// Suggestion is a human-readable string that holds advice for resolving this
// marker.
Suggestion Suggestion
}

// Severity indicates how important this problem is.
Expand Down Expand Up @@ -97,3 +103,9 @@ func (m ByKey) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
func (m ByKey) Less(i, j int) bool {
return m[i].Key < m[j].Key
}

type Suggestion string

func (s Suggestion) String() string {
return fmt.Sprintf("try: %s", string(s))
}
91 changes: 91 additions & 0 deletions pkg/api/graph/test/route-cruft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
apiVersion: v1
items:
- apiVersion: v1
kind: Route
metadata:
name: etcd-cruft
spec:
host: www.example.com
tls:
caCertificate: |-
-----BEGIN CERTIFICATE-----
MIIEFzCCAv+gAwIBAgIJALK1iUpF2VQLMA0GCSqGSIb3DQEBBQUAMIGhMQswCQYD
VQQGEwJVUzELMAkGA1UECAwCU0MxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoG
A1UECgwTRGVmYXVsdCBDb21wYW55IEx0ZDEQMA4GA1UECwwHVGVzdCBDQTEaMBgG
A1UEAwwRd3d3LmV4YW1wbGVjYS5jb20xIjAgBgkqhkiG9w0BCQEWE2V4YW1wbGVA
ZXhhbXBsZS5jb20wHhcNMTUwMTEyMTQxNTAxWhcNMjUwMTA5MTQxNTAxWjCBoTEL
MAkGA1UEBhMCVVMxCzAJBgNVBAgMAlNDMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkx
HDAaBgNVBAoME0RlZmF1bHQgQ29tcGFueSBMdGQxEDAOBgNVBAsMB1Rlc3QgQ0Ex
GjAYBgNVBAMMEXd3dy5leGFtcGxlY2EuY29tMSIwIAYJKoZIhvcNAQkBFhNleGFt
cGxlQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
w2rK1J2NMtQj0KDug7g7HRKl5jbf0QMkMKyTU1fBtZ0cCzvsF4CqV11LK4BSVWaK
rzkaXe99IVJnH8KdOlDl5Dh/+cJ3xdkClSyeUT4zgb6CCBqg78ePp+nN11JKuJlV
IG1qdJpB1J5O/kCLsGcTf7RS74MtqMFo96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3ZdjxHwkvf//aQnuxS5yX2Rnf37BS/TZu+TIkK4373CfHomSx
UTAn2FsLmOJljupgGcoeLx5K5nu7B7rY5L1NHvdpxZ4YjeISrRtEPvRakllENU5y
gJE8c2eQOx08ZSRE4TkCQQD7dws2/FldqwdjJucYijsJVuUdoTqxP8gWL6bB251q
elP2/a6W2elqOcWId28560jG9ZS3cuKvnmu/4LG88vZFAkEAzphrH3673oTsHN+d
uBd5uyrlnGjWjuiMKv2TPITZcWBjB8nJDSvLneHF59MYwejNNEof2tRjgFSdImFH
mi995wJBAMtPjW6wiqRz0i41VuT9ZgwACJBzOdvzQJfHgSD9qgFb1CU/J/hpSRIM
kYvrXK9MbvQFvG6x4VuyT1W8mpe1LK0CQAo8VPpffhFdRpF7psXLK/XQ/0VLkG3O
KburipLyBg/u9ZkaL0Ley5zL5dFBjTV2Qkx367Ic2b0u9AYTCcgi2DsCQQD3zZ7B
v7BOm7MkylKokY2MduFFXU0Bxg6pfZ7q3rvg8gqhUFbaMStPRYg6myiDiW/JfLhF
TcFT4touIo7oriFJ
-----END PRIVATE KEY-----
to:
kind: Service
name: doesntmatter
status: {}
- apiVersion: v1
kind: Service
metadata:
name: doesntmatter
spec:
ports:
- name: whatever
port: 5432
protocol: TCP
targetPort: 8080
selector:
name: whatever
sessionAffinity: None
type: ClusterIP
kind: List
metadata: {}
14 changes: 7 additions & 7 deletions pkg/build/graph/analysis/bc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
)

const (
MissingRequiredRegistryWarning = "MissingRequiredRegistry"
MissingImageStreamWarning = "MissingImageStream"
CyclicBuildConfigWarning = "CyclicBuildConfig"
MissingRequiredRegistryErr = "MissingRequiredRegistry"
MissingImageStreamErr = "MissingImageStream"
CyclicBuildConfigWarning = "CyclicBuildConfig"
)

// FindUnpushableBuildConfigs checks all build configs that will output to an IST backed by an ImageStream and checks to make sure their builds can push.
Expand All @@ -35,8 +35,8 @@ bc:
Node: bcNode,
RelatedNodes: []graph.Node{istNode},

Severity: osgraph.WarningSeverity,
Key: MissingImageStreamWarning,
Severity: osgraph.ErrorSeverity,
Key: MissingImageStreamErr,
Message: fmt.Sprintf("%s is pushing to %s that is using %s, but that image stream does not exist.",
bcNode.(*buildgraph.BuildConfigNode).ResourceString(), istNode.(*imagegraph.ImageStreamTagNode).ResourceString(), imageStreamNode.ResourceString()),
})
Expand All @@ -49,8 +49,8 @@ bc:
Node: bcNode,
RelatedNodes: []graph.Node{istNode},

Severity: osgraph.WarningSeverity,
Key: MissingRequiredRegistryWarning,
Severity: osgraph.ErrorSeverity,
Key: MissingRequiredRegistryErr,
Message: fmt.Sprintf("%s is pushing to %s that is using %s, but the administrator has not configured the integrated Docker registry. (oadm registry)",
bcNode.(*buildgraph.BuildConfigNode).ResourceString(), istNode.(*imagegraph.ImageStreamTagNode).ResourceString(), imageStreamNode.ResourceString()),
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/build/graph/analysis/bc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestUnpushableBuild(t *testing.T) {
t.Fatalf("expected %v, got %v", e, a)
}

if got, expected := markers[0].Key, MissingRequiredRegistryWarning; got != expected {
if got, expected := markers[0].Key, MissingRequiredRegistryErr; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}

Expand Down Expand Up @@ -53,7 +53,7 @@ func TestUnpushableBuild(t *testing.T) {
t.Fatalf("expected %v, got %v", e, a)
}

if got, expected := markers[0].Key, MissingImageStreamWarning; got != expected {
if got, expected := markers[0].Key, MissingImageStreamErr; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}
}
Expand Down
122 changes: 77 additions & 45 deletions pkg/cmd/cli/cmd/status.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cmd

import (
"errors"
"fmt"
"io"
"strings"

"github.com/gonum/graph/encoding/dot"
"github.com/spf13/cobra"
Expand All @@ -14,9 +14,10 @@ import (
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)

const (
StatusRecommendedName = "status"
// StatusRecommendedName is the recommended command name.
const StatusRecommendedName = "status"

const (
statusLong = `
Show a high level overview of the current project

Expand All @@ -28,36 +29,59 @@ oc describe deploymentConfig, oc describe service).
You can specify an output format of "-o dot" to have this command output the generated status
graph in DOT format that is suitable for use by the "dot" command.`

statusExample = ` # Show an overview of the current project
$ %[1]s`
statusExample = ` # See an overview of the current project.
$ %[1]s

# Export the overview of the current project in an svg file.
$ %[1]s -o dot | dot -T svg -o project.svg

# See an overview of the current project including details for any identified issues.
$ %[1]s -v`
)

// NewCmdStatus implements the OpenShift cli status command
// StatusOptions contains all the necessary options for the Openshift cli status command.
type StatusOptions struct {
namespace string
outputFormat string
describer *describe.ProjectStatusDescriber
out io.Writer
verbose bool
}

// NewCmdStatus implements the OpenShift cli status command.
func NewCmdStatus(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
outputFormat := ""
opts := &StatusOptions{}

cmd := &cobra.Command{
Use: "status",
Use: fmt.Sprintf("%s [-o dot | -v ]", StatusRecommendedName),
Short: "Show an overview of the current project",
Long: statusLong,
Example: fmt.Sprintf(statusExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
if strings.ToLower(outputFormat) == "dot" {
cmdutil.CheckErr(RunGraph(f, out))
return
err := opts.Complete(f, cmd, args, out)
cmdutil.CheckErr(err)

if err := opts.Validate(); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error()))
}

cmdutil.CheckErr(RunStatus(f, out))
err = opts.RunStatus()
cmdutil.CheckErr(err)
},
}

cmd.Flags().StringVarP(&outputFormat, "output", "o", outputFormat, "Output format. One of: dot.")
cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", opts.outputFormat, "Output format. One of: dot.")
cmd.Flags().BoolVarP(&opts.verbose, "verbose", "v", opts.verbose, "See details for resolving issues.")

return cmd
}

// RunStatus contains all the necessary functionality for the OpenShift cli status command
func RunStatus(f *clientcmd.Factory, out io.Writer) error {
// Complete completes the options for the Openshift cli status command.
func (o *StatusOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string, out io.Writer) error {
if len(args) > 0 {
return cmdutil.UsageError(cmd, "no arguments should be provided")
}

client, kclient, err := f.Clients()
if err != nil {
return err
Expand All @@ -72,45 +96,53 @@ func RunStatus(f *clientcmd.Factory, out io.Writer) error {
if err != nil {
return err
}
o.namespace = namespace

describer := &describe.ProjectStatusDescriber{K: kclient, C: client, Server: config.Host}
s, err := describer.Describe(namespace, "")
if err != nil {
return err
}
o.describer = &describe.ProjectStatusDescriber{K: kclient, C: client, Server: config.Host, Suggest: o.verbose}

o.out = out

fmt.Fprintf(out, s)
return nil
}

// RunGraph contains all the necessary functionality for the OpenShift cli graph command
func RunGraph(f *clientcmd.Factory, out io.Writer) error {
client, kclient, err := f.Clients()
if err != nil {
return err
// Validate validates the options for the Openshift cli status command.
func (o StatusOptions) Validate() error {
if len(o.outputFormat) != 0 && o.outputFormat != "dot" {
return fmt.Errorf("invalid output format provided: %s", o.outputFormat)
}

config, err := f.OpenShiftClientConfig.ClientConfig()
if err != nil {
return err
}

namespace, _, err := f.DefaultNamespace()
if err != nil {
return err
}

describer := &describe.ProjectStatusDescriber{K: kclient, C: client, Server: config.Host}
g, _, err := describer.MakeGraph(namespace)
if err != nil {
return err
if len(o.outputFormat) > 0 && o.verbose {
return errors.New("cannot provide suggestions when output format is dot")
}
return nil
}

data, err := dot.Marshal(g, namespace, "", " ", false)
if err != nil {
return err
// RunStatus contains all the necessary functionality for the OpenShift cli status command.
func (o StatusOptions) RunStatus() error {
var (
s string
err error
)

switch o.outputFormat {
case "":
s, err = o.describer.Describe(o.namespace, "")
if err != nil {
return err
}
case "dot":
g, _, err := o.describer.MakeGraph(o.namespace)
if err != nil {
return err
}
data, err := dot.Marshal(g, o.namespace, "", " ", false)
if err != nil {
return err
}
s = string(data)
default:
return fmt.Errorf("invalid output format provided: %s", o.outputFormat)
}

fmt.Fprintf(out, "%s", string(data))
fmt.Fprintf(o.out, s)
return nil
}
Loading