diff --git a/pkg/client/testclient/fake.go b/pkg/client/testclient/fake.go index f8e235494bbd..f4470bad5eed 100644 --- a/pkg/client/testclient/fake.go +++ b/pkg/client/testclient/fake.go @@ -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)) diff --git a/pkg/cmd/cli/describe/projectstatus.go b/pkg/cmd/cli/describe/projectstatus.go index bb0a38c2c1f3..8ff63ce39d5f 100644 --- a/pkg/cmd/cli/describe/projectstatus.go +++ b/pkg/cmd/cli/describe/projectstatus.go @@ -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 ' or 'oc describe dc '.") + fmt.Fprintln(out, "To see more, use 'oc describe /'.") fmt.Fprintln(out, "You can use 'oc get all' to see a list of other objects.") } @@ -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 @@ -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))) } @@ -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() } @@ -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) } } @@ -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 %s", svc.Service.Name, port)} + return []string{fmt.Sprintf("service/%s %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)} } } diff --git a/pkg/cmd/cli/describe/projectstatus_test.go b/pkg/cmd/cli/describe/projectstatus_test.go index d9ba15aab40c..af9aeffb3927 100644 --- a/pkg/cmd/cli/describe/projectstatus_test.go +++ b/pkg/cmd/cli/describe/projectstatus_test.go @@ -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", ":5432", "To see more, use", }, @@ -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", @@ -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", }, @@ -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", @@ -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", @@ -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", @@ -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",