Skip to content
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
34 changes: 34 additions & 0 deletions pkg/client/buildlogs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package client

import (
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
)

// BuildLogsNamespacer has methods to work with BuildLogs resources in a namespace
type BuildLogsNamespacer interface {
BuildLogs(namespace string) BuildLogInterface
}

// BuildLogsInterface exposes methods on BuildLogs resources.
type BuildLogInterface interface {
Redirect(name string) *kclient.Request
}

// buildLogs implements BuildLogsNamespacer interface
type buildLogs struct {
r *Client
ns string
}

// newBuildLogs returns a buildLogs
func newBuildLogs(c *Client, namespace string) *buildLogs {
return &buildLogs{
r: c,
ns: namespace,
}
}

// Redirect builds and returns a buildLog request
func (c *buildLogs) Redirect(name string) *kclient.Request {
return c.r.Get().Namespace(c.ns).Prefix("redirect").Resource("buildLogs").Name(name)
}
20 changes: 19 additions & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
type Interface interface {
BuildsNamespacer
BuildConfigsNamespacer
BuildLogsNamespacer
ImagesNamespacer
ImageRepositoriesNamespacer
ImageRepositoryMappingsNamespacer
Expand All @@ -37,14 +38,22 @@ type Interface interface {
TemplatesNamespacer
}

// Builds provides a REST client for Builds
func (c *Client) Builds(namespace string) BuildInterface {
return newBuilds(c, namespace)
}

// BuildConfigs provides a REST client for BuildConfigs
func (c *Client) BuildConfigs(namespace string) BuildConfigInterface {
return newBuildConfigs(c, namespace)
}

// BuildLogs provides a REST client for BuildLogs
func (c *Client) BuildLogs(namespace string) BuildLogInterface {
return newBuildLogs(c, namespace)
}

// Images provides a REST client for Images
func (c *Client) Images(namespace string) ImageInterface {
return newImages(c, namespace)
}
Expand Down Expand Up @@ -99,35 +108,42 @@ func (c *Client) TemplateConfigs(namespace string) TemplateConfigInterface {
return newTemplateConfigs(c, namespace)
}

// TemplateConfigs provides a REST client for TemplateConfig
// Templates provides a REST client for Templates
func (c *Client) Templates(namespace string) TemplateInterface {
return newTemplates(c, namespace)
}

// Policies provides a REST client for Policies
func (c *Client) Policies(namespace string) PolicyInterface {
return newPolicies(c, namespace)
}

// PolicyBindings provides a REST client for PolicyBindings
func (c *Client) PolicyBindings(namespace string) PolicyBindingInterface {
return newPolicyBindings(c, namespace)
}

// Roles provides a REST client for Roles
func (c *Client) Roles(namespace string) RoleInterface {
return newRoles(c, namespace)
}

// RoleBindings provides a REST client for RoleBindings
func (c *Client) RoleBindings(namespace string) RoleBindingInterface {
return newRoleBindings(c, namespace)
}

// ResourceAccessReviews provides a REST client for ResourceAccessReviews
func (c *Client) ResourceAccessReviews(namespace string) ResourceAccessReviewInterface {
return newResourceAccessReviews(c, namespace)
}

// RootResourceAccessReviews provides a REST client for RootResourceAccessReviews
func (c *Client) RootResourceAccessReviews() ResourceAccessReviewInterface {
return newRootResourceAccessReviews(c)
}

// SubjectAccessReviews provides a REST client for SubjectAccessReviews
func (c *Client) SubjectAccessReviews(namespace string) SubjectAccessReviewInterface {
return newSubjectAccessReviews(c, namespace)
}
Expand All @@ -152,6 +168,8 @@ func New(c *kclient.Config) (*Client, error) {
return &Client{client}, nil
}

// SetOpenShiftDefaults sets the default settings on the passed
// client configuration
func SetOpenShiftDefaults(config *kclient.Config) error {
if config.Prefix == "" {
config.Prefix = "/osapi"
Expand Down
4 changes: 4 additions & 0 deletions pkg/client/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func (c *Fake) BuildConfigs(namespace string) BuildConfigInterface {
return &FakeBuildConfigs{Fake: c, Namespace: namespace}
}

func (c *Fake) BuildLogs(namespace string) BuildLogInterface {
return &FakeBuildLogs{Fake: c, Namespace: namespace}
}

func (c *Fake) Images(namespace string) ImageInterface {
return &FakeImages{Fake: c, Namespace: namespace}
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/client/fake_buildlogs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package client

import (
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
)

// FakeBuildLogs implements BuildLogInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
type FakeBuildLogs struct {
Fake *Fake
Namespace string
}

// Redirect builds and returns a buildLog request
func (c *FakeBuildLogs) Redirect(name string) *kclient.Request {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "redirect"})
return &kclient.Request{}
}
7 changes: 1 addition & 6 deletions pkg/cmd/cli/cmd/buildlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"io"

"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
"github.com/spf13/cobra"

"github.com/openshift/origin/pkg/cmd/util/clientcmd"
Expand All @@ -30,14 +29,10 @@ Examples:
namespace, err := f.DefaultNamespace(cmd)
checkErr(err)

mapper, _ := f.Object(cmd)
mapping, err := mapper.RESTMapping("BuildLog", util.GetFlagString(cmd, "api-version"))
checkErr(err)
c, _, err := f.Clients(cmd)
checkErr(err)

// TODO: This should be a method on the origin Client - BuildLogs(namespace).Redirect(args[0])
request := c.Get().Namespace(namespace).Prefix("redirect").Resource(mapping.Resource).Name(args[0])
request := c.BuildLogs(namespace).Redirect(args[0])

readCloser, err := request.Stream()
checkErr(err)
Expand Down
11 changes: 11 additions & 0 deletions pkg/cmd/cli/describe/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func DescriberFor(kind string, c *client.Client, kclient kclient.Interface, host
return &BuildDescriber{c}, true
case "BuildConfig":
return &BuildConfigDescriber{c, host}, true
case "BuildLog":
return &BuildLogDescriber{c}, true
case "Deployment":
return &DeploymentDescriber{c}, true
case "DeploymentConfig":
Expand Down Expand Up @@ -181,6 +183,15 @@ func (d *BuildConfigDescriber) Describe(namespace, name string) (string, error)
})
}

// BuildLogDescriber generates information about a BuildLog
type BuildLogDescriber struct {
client.Interface
}

func (d *BuildLogDescriber) Describe(namespace, name string) (string, error) {
return fmt.Sprintf("Name: %s/%s, Labels:", namespace, name), nil
}

// ImageDescriber generates information about a Image
type ImageDescriber struct {
client.Interface
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/cli/describe/describer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type describeClient struct {
func TestDescribeFor(t *testing.T) {
c := &client.Client{}
testTypesList := []string{
"Build", "BuildConfig", "Deployment", "DeploymentConfig",
"Build", "BuildConfig", "BuildLog", "Deployment", "DeploymentConfig",
"Image", "ImageRepository", "Route", "Project",
}
for _, o := range testTypesList {
Expand All @@ -43,6 +43,7 @@ func TestDescribers(t *testing.T) {
testDescriberList := []kubectl.Describer{
&BuildDescriber{c},
&BuildConfigDescriber{c, ""},
&BuildLogDescriber{c},
&DeploymentDescriber{c},
&ImageDescriber{c},
&ImageRepositoryDescriber{c},
Expand Down