Fix style errors

pull/446/head
jackgr 10 years ago
parent b61ff1a655
commit f2180cea92

@ -47,7 +47,7 @@ type expandyBirdOutput struct {
// ExpandChart passes the given configuration to the expander and returns the // ExpandChart passes the given configuration to the expander and returns the
// expanded configuration as a string on success. // expanded configuration as a string on success.
func (e *expander) ExpandChart(request *expansion.ExpansionRequest) (*expansion.ExpansionResponse, error) { func (e *expander) ExpandChart(request *expansion.ServiceRequest) (*expansion.ServiceResponse, error) {
if request.ChartInvocation == nil { if request.ChartInvocation == nil {
return nil, fmt.Errorf("Request does not have invocation field") return nil, fmt.Errorf("Request does not have invocation field")
} }
@ -155,5 +155,5 @@ func (e *expander) ExpandChart(request *expansion.ExpansionRequest) (*expansion.
return nil, fmt.Errorf("cannot unmarshal expansion result (%s):\n%s", err, output) return nil, fmt.Errorf("cannot unmarshal expansion result (%s):\n%s", err, output)
} }
return &expansion.ExpansionResponse{Resources: output.Config.Resources}, nil return &expansion.ServiceResponse{Resources: output.Config.Resources}, nil
} }

@ -32,8 +32,8 @@ var expanderName = "../../../expansion/expansion.py"
type testCase struct { type testCase struct {
Description string Description string
Request *expansion.ExpansionRequest Request *expansion.ServiceRequest
ExpectedResponse *expansion.ExpansionResponse ExpectedResponse *expansion.ServiceResponse
ExpectedError string ExpectedError string
} }
@ -48,8 +48,8 @@ func funcName() string {
return runtime.FuncForPC(pc).Name() return runtime.FuncForPC(pc).Name()
} }
func testExpansion(t *testing.T, req *expansion.ExpansionRequest, func testExpansion(t *testing.T, req *expansion.ServiceRequest,
expResponse *expansion.ExpansionResponse, expError string) { expResponse *expansion.ServiceResponse, expError string) {
backend := NewExpander(expanderName) backend := NewExpander(expanderName)
response, err := backend.ExpandChart(req) response, err := backend.ExpandChart(req)
if err != nil { if err != nil {
@ -82,7 +82,7 @@ var jinjaExpander = &chart.Expander{
func TestEmptyJinja(t *testing.T) { func TestEmptyJinja(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -100,7 +100,7 @@ func TestEmptyJinja(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{}, Resources: []interface{}{},
}, },
"", // Error "", // Error
@ -110,7 +110,7 @@ func TestEmptyJinja(t *testing.T) {
func TestEmptyPython(t *testing.T) { func TestEmptyPython(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -131,7 +131,7 @@ func TestEmptyPython(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{}, Resources: []interface{}{},
}, },
"", // Error "", // Error
@ -141,7 +141,7 @@ func TestEmptyPython(t *testing.T) {
func TestSimpleJinja(t *testing.T) { func TestSimpleJinja(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -163,7 +163,7 @@ func TestSimpleJinja(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -178,7 +178,7 @@ func TestSimpleJinja(t *testing.T) {
func TestSimplePython(t *testing.T) { func TestSimplePython(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -202,7 +202,7 @@ func TestSimplePython(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -217,7 +217,7 @@ func TestSimplePython(t *testing.T) {
func TestPropertiesJinja(t *testing.T) { func TestPropertiesJinja(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -245,7 +245,7 @@ func TestPropertiesJinja(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -263,7 +263,7 @@ func TestPropertiesJinja(t *testing.T) {
func TestPropertiesPython(t *testing.T) { func TestPropertiesPython(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -293,7 +293,7 @@ func TestPropertiesPython(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -311,7 +311,7 @@ func TestPropertiesPython(t *testing.T) {
func TestMultiFileJinja(t *testing.T) { func TestMultiFileJinja(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -337,7 +337,7 @@ func TestMultiFileJinja(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -369,7 +369,7 @@ var schemaContent = content([]string{
func TestSchema(t *testing.T) { func TestSchema(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -402,7 +402,7 @@ func TestSchema(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -420,7 +420,7 @@ func TestSchema(t *testing.T) {
func TestSchemaFail(t *testing.T) { func TestSchemaFail(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -461,7 +461,7 @@ func TestSchemaFail(t *testing.T) {
func TestMultiFileJinjaMissing(t *testing.T) { func TestMultiFileJinjaMissing(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -487,7 +487,7 @@ func TestMultiFileJinjaMissing(t *testing.T) {
func TestMultiFilePython(t *testing.T) { func TestMultiFilePython(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -532,7 +532,7 @@ func TestMultiFilePython(t *testing.T) {
}, },
}, },
}, },
&expansion.ExpansionResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "foo", "name": "foo",
@ -547,7 +547,7 @@ func TestMultiFilePython(t *testing.T) {
func TestMultiFilePythonMissing(t *testing.T) { func TestMultiFilePythonMissing(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -575,7 +575,7 @@ func TestMultiFilePythonMissing(t *testing.T) {
func TestWrongChartName(t *testing.T) { func TestWrongChartName(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -601,7 +601,7 @@ func TestWrongChartName(t *testing.T) {
func TestEntrypointNotFound(t *testing.T) { func TestEntrypointNotFound(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -622,7 +622,7 @@ func TestEntrypointNotFound(t *testing.T) {
func TestMalformedResource(t *testing.T) { func TestMalformedResource(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -651,7 +651,7 @@ func TestMalformedResource(t *testing.T) {
func TestResourceNoName(t *testing.T) { func TestResourceNoName(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),
@ -680,7 +680,7 @@ func TestResourceNoName(t *testing.T) {
func TestResourceNoType(t *testing.T) { func TestResourceNoType(t *testing.T) {
testExpansion( testExpansion(
t, t,
&expansion.ExpansionRequest{ &expansion.ServiceRequest{
ChartInvocation: &common.Resource{ ChartInvocation: &common.Resource{
Name: "test_invocation", Name: "test_invocation",
Type: funcName(), Type: funcName(),

@ -43,8 +43,8 @@ func NewService(handler restful.RouteFunction) *Service {
webService.Produces(restful.MIME_JSON, restful.MIME_XML) webService.Produces(restful.MIME_JSON, restful.MIME_XML)
webService.Route(webService.POST("/expand").To(handler). webService.Route(webService.POST("/expand").To(handler).
Doc("Expand a template."). Doc("Expand a template.").
Reads(&expansion.ExpansionRequest{}). Reads(&expansion.ServiceRequest{}).
Writes(&expansion.ExpansionResponse{})) Writes(&expansion.ServiceResponse{}))
return &Service{webService} return &Service{webService}
} }
@ -64,7 +64,7 @@ func (s *Service) Register(container *restful.Container) {
func NewExpansionHandler(backend expansion.Expander) restful.RouteFunction { func NewExpansionHandler(backend expansion.Expander) restful.RouteFunction {
return func(req *restful.Request, resp *restful.Response) { return func(req *restful.Request, resp *restful.Response) {
util.LogHandlerEntry("expandybird: expand", req.Request) util.LogHandlerEntry("expandybird: expand", req.Request)
request := &expansion.ExpansionRequest{} request := &expansion.ServiceRequest{}
if err := req.ReadEntity(&request); err != nil { if err := req.ReadEntity(&request); err != nil {
logAndReturnErrorFromHandler(http.StatusBadRequest, err.Error(), resp) logAndReturnErrorFromHandler(http.StatusBadRequest, err.Error(), resp)
return return

@ -21,18 +21,18 @@ import (
"github.com/kubernetes/helm/pkg/common" "github.com/kubernetes/helm/pkg/common"
) )
// ExpansionRequest defines the API to expander. // ServiceRequest defines the API to expander.
type ExpansionRequest struct { type ServiceRequest struct {
ChartInvocation *common.Resource `json:"chart_invocation"` ChartInvocation *common.Resource `json:"chart_invocation"`
Chart *chart.Content `json:"chart"` Chart *chart.Content `json:"chart"`
} }
// ExpansionResponse defines the API to expander. // ServiceResponse defines the API to expander.
type ExpansionResponse struct { type ServiceResponse struct {
Resources []interface{} `json:"resources"` Resources []interface{} `json:"resources"`
} }
// Expander abstracts interactions with the expander and deployer services. // Expander abstracts interactions with the expander and deployer services.
type Expander interface { type Expander interface {
ExpandChart(request *ExpansionRequest) (*ExpansionResponse, error) ExpandChart(request *ServiceRequest) (*ServiceResponse, error)
} }

Loading…
Cancel
Save