Skip to content

Commit

Permalink
Merge pull request #3687 from deads2k/status-make-copiable
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Jul 21, 2015
2 parents 8562ec4 + 7cdc994 commit 00d54b4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
3 changes: 3 additions & 0 deletions pkg/client/testclient/fake.go
Expand Up @@ -42,6 +42,9 @@ func NewSimpleFake(objects ...runtime.Object) *Fake {
// Invokes registers the passed fake action and reacts on it if a ReactFn
// has been defined
func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, error) {
c.Lock.Lock()
defer c.Lock.Unlock()

c.Actions = append(c.Actions, action)
if c.ReactFn != nil {
return c.ReactFn(ktestclient.FakeAction(action))
Expand Down
45 changes: 27 additions & 18 deletions pkg/cmd/cli/describe/projectstatus.go
Expand Up @@ -186,7 +186,7 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
fmt.Fprintln(out, "Run 'oc new-app' to create an application.")

} else {
fmt.Fprintln(out, "To see more, use 'oc describe service <name>' or 'oc describe dc <name>'.")
fmt.Fprintln(out, "To see more, use 'oc describe <resource>/<name>'.")
fmt.Fprintln(out, "You can use 'oc get all' to see a list of other objects.")
}

Expand Down Expand Up @@ -214,24 +214,33 @@ func printLines(out io.Writer, indent string, depth int, lines ...string) {
}
}

func indentLines(indent string, lines ...string) []string {
ret := make([]string, 0, len(lines))
for _, line := range lines {
ret = append(ret, indent+line)
}

return ret
}

func describeDeploymentInServiceGroup(deploy graphview.DeploymentConfigPipeline) []string {
includeLastPass := deploy.ActiveDeployment == nil
if len(deploy.Images) == 1 {
lines := []string{fmt.Sprintf("%s deploys %s %s", deploy.Deployment.Name, describeImageInPipeline(deploy.Images[0], deploy.Deployment.Namespace), describeDeploymentConfigTrigger(deploy.Deployment.DeploymentConfig))}
lines := []string{fmt.Sprintf("dc/%s deploys %s %s", deploy.Deployment.Name, describeImageInPipeline(deploy.Images[0], deploy.Deployment.Namespace), describeDeploymentConfigTrigger(deploy.Deployment.DeploymentConfig))}
if len(lines[0]) > 120 && strings.Contains(lines[0], " <- ") {
segments := strings.SplitN(lines[0], " <- ", 2)
lines[0] = segments[0] + " <-"
lines = append(lines, segments[1])
}
lines = append(lines, describeAdditionalBuildDetail(deploy.Images[0].Build, deploy.Images[0].LastSuccessfulBuild, deploy.Images[0].LastUnsuccessfulBuild, deploy.Images[0].ActiveBuilds, deploy.Images[0].DestinationResolved, includeLastPass)...)
lines = append(lines, indentLines(" ", describeAdditionalBuildDetail(deploy.Images[0].Build, deploy.Images[0].LastSuccessfulBuild, deploy.Images[0].LastUnsuccessfulBuild, deploy.Images[0].ActiveBuilds, deploy.Images[0].DestinationResolved, includeLastPass)...)...)
lines = append(lines, describeDeployments(deploy.Deployment, deploy.ActiveDeployment, deploy.InactiveDeployments, 3)...)
return lines
}

lines := []string{fmt.Sprintf("%s deploys: %s", deploy.Deployment.Name, describeDeploymentConfigTrigger(deploy.Deployment.DeploymentConfig))}
lines := []string{fmt.Sprintf("dc/%s deploys: %s", deploy.Deployment.Name, describeDeploymentConfigTrigger(deploy.Deployment.DeploymentConfig))}
for _, image := range deploy.Images {
lines = append(lines, describeImageInPipeline(image, deploy.Deployment.Namespace))
lines = append(lines, describeAdditionalBuildDetail(image.Build, image.LastSuccessfulBuild, image.LastUnsuccessfulBuild, image.ActiveBuilds, image.DestinationResolved, includeLastPass)...)
lines = append(lines, indentLines(" ", describeAdditionalBuildDetail(image.Build, image.LastSuccessfulBuild, image.LastUnsuccessfulBuild, image.ActiveBuilds, image.DestinationResolved, includeLastPass)...)...)
lines = append(lines, describeDeployments(deploy.Deployment, deploy.ActiveDeployment, deploy.InactiveDeployments, 3)...)
}
return lines
Expand Down Expand Up @@ -274,7 +283,7 @@ func describeDeploymentConfigTrigger(dc *deployapi.DeploymentConfig) string {
func describeStandaloneBuildGroup(pipeline graphview.ImagePipeline, namespace string) []string {
switch {
case pipeline.Build != nil:
lines := []string{fmt.Sprintf("%s %s", pipeline.Build.BuildConfig.Name, describeBuildInPipeline(pipeline.Build.BuildConfig, pipeline.BaseImage))}
lines := []string{fmt.Sprintf("bc/%s %s", pipeline.Build.BuildConfig.Name, describeBuildInPipeline(pipeline.Build.BuildConfig, pipeline.BaseImage))}
if pipeline.Image != nil {
lines = append(lines, fmt.Sprintf("pushes to %s", describeImageTagInPipeline(pipeline.Image, namespace)))
}
Expand Down Expand Up @@ -305,7 +314,7 @@ func describeImageTagInPipeline(image graphview.ImageTagLocation, namespace stri
if t.ImageStreamTag.Namespace != namespace {
return image.ImageSpec()
}
return t.ImageStreamTag.Name
return "istag/" + t.ImageStreamTag.Name
default:
return image.ImageSpec()
}
Expand All @@ -317,26 +326,26 @@ func describeBuildInPipeline(build *buildapi.BuildConfig, baseImage graphview.Im
// TODO: handle case where no source repo
source, ok := describeSourceInPipeline(&build.Spec.Source)
if !ok {
return "docker build; no source set"
return fmt.Sprintf("unconfigured docker build bc/%s - no source set", build.Name)
}
return fmt.Sprintf("docker build of %s", source)
return fmt.Sprintf("docker build of %s through bc/%s", source, build.Name)
case buildapi.SourceBuildStrategyType:
source, ok := describeSourceInPipeline(&build.Spec.Source)
if !ok {
return fmt.Sprintf("unconfigured source build %s", build.Name)
return fmt.Sprintf("unconfigured source build bc/%s", build.Name)
}
if baseImage == nil {
return fmt.Sprintf("%s; no image set", source)
return fmt.Sprintf("%s through bc/%s; no image set", source, build.Name)
}
return fmt.Sprintf("builds %s with %s", source, baseImage.ImageSpec())
return fmt.Sprintf("builds %s with %s through bc/%s", source, baseImage.ImageSpec(), build.Name)
case buildapi.CustomBuildStrategyType:
source, ok := describeSourceInPipeline(&build.Spec.Source)
if !ok {
return fmt.Sprintf("custom build %s", build.Name)
return fmt.Sprintf("custom build bc/%s ", build.Name)
}
return fmt.Sprintf("custom build of %s", source)
return fmt.Sprintf("custom build of %s through bc/%s", source, build.Name)
default:
return fmt.Sprintf("unrecognized build %s", build.Name)
return fmt.Sprintf("unrecognized build bc/%s", build.Name)
}
}

Expand Down Expand Up @@ -606,11 +615,11 @@ func describeServiceInServiceGroup(svc graphview.ServiceGroup) []string {
port := describeServicePorts(spec)
switch {
case ip == "None":
return []string{fmt.Sprintf("service %s (headless)%s", svc.Service.Name, port)}
return []string{fmt.Sprintf("service/%s (headless)%s", svc.Service.Name, port)}
case len(ip) == 0:
return []string{fmt.Sprintf("service %s <initializing>%s", svc.Service.Name, port)}
return []string{fmt.Sprintf("service/%s <initializing>%s", svc.Service.Name, port)}
default:
return []string{fmt.Sprintf("service %s - %s%s", svc.Service.Name, ip, port)}
return []string{fmt.Sprintf("service/%s - %s%s", svc.Service.Name, ip, port)}
}
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/cli/describe/projectstatus_test.go
Expand Up @@ -61,7 +61,7 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service empty-service",
"service/empty-service",
"<initializing>:5432",
"To see more, use",
},
Expand All @@ -76,7 +76,7 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service database-rc",
"service/database-rc",
"rc/database-rc-1 runs mysql",
"0/1 pods growing to 1",
"To see more, use",
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service frontend-app",
"service/frontend-app",
"pod/frontend-app-1-bjwh8 runs openshift/ruby-hello-world",
"To see more, use",
},
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service sinatra-example-2 - 172.30.17.48:8080",
"service/sinatra-example-2 - 172.30.17.48:8080",
"builds git://github.com",
"with docker.io/openshift/ruby-20-centos7:latest",
"not built yet",
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service sinatra-example-1 - 172.30.17.47:8080",
"service/sinatra-example-1 - 172.30.17.47:8080",
"builds git://github.com",
"with docker.io/openshift/ruby-20-centos7:latest",
"build 1 running for about a minute",
Expand All @@ -212,7 +212,7 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service sinatra-app-example - 172.30.17.49:8080",
"service/sinatra-app-example - 172.30.17.49:8080",
"sinatra-app-example-a deploys",
"sinatra-app-example-b deploys",
"with docker.io/openshift/ruby-20-centos7:latest",
Expand All @@ -232,8 +232,8 @@ func TestProjectStatus(t *testing.T) {
ErrFn: func(err error) bool { return err == nil },
Contains: []string{
"In project example\n",
"service database - 172.30.17.240:5434 -> 3306",
"service frontend - 172.30.17.154:5432 -> 8080",
"service/database - 172.30.17.240:5434 -> 3306",
"service/frontend - 172.30.17.154:5432 -> 8080",
"database deploys",
"frontend deploys",
"with docker.io/openshift/ruby-20-centos7:latest",
Expand Down

0 comments on commit 00d54b4

Please sign in to comment.