Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
f2180cea
Commit
f2180cea
authored
Mar 24, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix style errors
parent
b61ff1a6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
40 deletions
+40
-40
expander.go
cmd/expandybird/expander/expander.go
+2
-2
expander_test.go
cmd/expandybird/expander/expander_test.go
+30
-30
service.go
cmd/expandybird/service/service.go
+3
-3
types.go
pkg/expansion/types.go
+5
-5
No files found.
cmd/expandybird/expander/expander.go
View file @
f2180cea
...
@@ -47,7 +47,7 @@ type expandyBirdOutput struct {
...
@@ -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
.
Expansion
Response
,
error
)
{
func
(
e
*
expander
)
ExpandChart
(
request
*
expansion
.
ServiceRequest
)
(
*
expansion
.
Service
Response
,
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.
...
@@ -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
.
Expansion
Response
{
Resources
:
output
.
Config
.
Resources
},
nil
return
&
expansion
.
Service
Response
{
Resources
:
output
.
Config
.
Resources
},
nil
}
}
cmd/expandybird/expander/expander_test.go
View file @
f2180cea
...
@@ -32,8 +32,8 @@ var expanderName = "../../../expansion/expansion.py"
...
@@ -32,8 +32,8 @@ var expanderName = "../../../expansion/expansion.py"
type
testCase
struct
{
type
testCase
struct
{
Description
string
Description
string
Request
*
expansion
.
Expansion
Request
Request
*
expansion
.
Service
Request
ExpectedResponse
*
expansion
.
Expansion
Response
ExpectedResponse
*
expansion
.
Service
Response
ExpectedError
string
ExpectedError
string
}
}
...
@@ -48,8 +48,8 @@ func funcName() 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
.
Expansion
Request
,
func
testExpansion
(
t
*
testing
.
T
,
req
*
expansion
.
Service
Request
,
expResponse
*
expansion
.
Expansion
Response
,
expError
string
)
{
expResponse
*
expansion
.
Service
Response
,
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{
...
@@ -82,7 +82,7 @@ var jinjaExpander = &chart.Expander{
func
TestEmptyJinja
(
t
*
testing
.
T
)
{
func
TestEmptyJinja
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -100,7 +100,7 @@ func TestEmptyJinja(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{},
Resources
:
[]
interface
{}{},
},
},
""
,
// Error
""
,
// Error
...
@@ -110,7 +110,7 @@ func TestEmptyJinja(t *testing.T) {
...
@@ -110,7 +110,7 @@ func TestEmptyJinja(t *testing.T) {
func
TestEmptyPython
(
t
*
testing
.
T
)
{
func
TestEmptyPython
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -131,7 +131,7 @@ func TestEmptyPython(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{},
Resources
:
[]
interface
{}{},
},
},
""
,
// Error
""
,
// Error
...
@@ -141,7 +141,7 @@ func TestEmptyPython(t *testing.T) {
...
@@ -141,7 +141,7 @@ func TestEmptyPython(t *testing.T) {
func
TestSimpleJinja
(
t
*
testing
.
T
)
{
func
TestSimpleJinja
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -163,7 +163,7 @@ func TestSimpleJinja(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -178,7 +178,7 @@ func TestSimpleJinja(t *testing.T) {
...
@@ -178,7 +178,7 @@ func TestSimpleJinja(t *testing.T) {
func
TestSimplePython
(
t
*
testing
.
T
)
{
func
TestSimplePython
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -202,7 +202,7 @@ func TestSimplePython(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -217,7 +217,7 @@ func TestSimplePython(t *testing.T) {
...
@@ -217,7 +217,7 @@ func TestSimplePython(t *testing.T) {
func
TestPropertiesJinja
(
t
*
testing
.
T
)
{
func
TestPropertiesJinja
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -245,7 +245,7 @@ func TestPropertiesJinja(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -263,7 +263,7 @@ func TestPropertiesJinja(t *testing.T) {
...
@@ -263,7 +263,7 @@ func TestPropertiesJinja(t *testing.T) {
func
TestPropertiesPython
(
t
*
testing
.
T
)
{
func
TestPropertiesPython
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -293,7 +293,7 @@ func TestPropertiesPython(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -311,7 +311,7 @@ func TestPropertiesPython(t *testing.T) {
...
@@ -311,7 +311,7 @@ func TestPropertiesPython(t *testing.T) {
func
TestMultiFileJinja
(
t
*
testing
.
T
)
{
func
TestMultiFileJinja
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -337,7 +337,7 @@ func TestMultiFileJinja(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -369,7 +369,7 @@ var schemaContent = content([]string{
...
@@ -369,7 +369,7 @@ var schemaContent = content([]string{
func
TestSchema
(
t
*
testing
.
T
)
{
func
TestSchema
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -402,7 +402,7 @@ func TestSchema(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -420,7 +420,7 @@ func TestSchema(t *testing.T) {
...
@@ -420,7 +420,7 @@ func TestSchema(t *testing.T) {
func
TestSchemaFail
(
t
*
testing
.
T
)
{
func
TestSchemaFail
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -461,7 +461,7 @@ func TestSchemaFail(t *testing.T) {
func
TestMultiFileJinjaMissing
(
t
*
testing
.
T
)
{
func
TestMultiFileJinjaMissing
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -487,7 +487,7 @@ func TestMultiFileJinjaMissing(t *testing.T) {
func
TestMultiFilePython
(
t
*
testing
.
T
)
{
func
TestMultiFilePython
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -532,7 +532,7 @@ func TestMultiFilePython(t *testing.T) {
},
},
},
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
"name"
:
"foo"
,
...
@@ -547,7 +547,7 @@ func TestMultiFilePython(t *testing.T) {
...
@@ -547,7 +547,7 @@ func TestMultiFilePython(t *testing.T) {
func
TestMultiFilePythonMissing
(
t
*
testing
.
T
)
{
func
TestMultiFilePythonMissing
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -575,7 +575,7 @@ func TestMultiFilePythonMissing(t *testing.T) {
func
TestWrongChartName
(
t
*
testing
.
T
)
{
func
TestWrongChartName
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -601,7 +601,7 @@ func TestWrongChartName(t *testing.T) {
func
TestEntrypointNotFound
(
t
*
testing
.
T
)
{
func
TestEntrypointNotFound
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -622,7 +622,7 @@ func TestEntrypointNotFound(t *testing.T) {
func
TestMalformedResource
(
t
*
testing
.
T
)
{
func
TestMalformedResource
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -651,7 +651,7 @@ func TestMalformedResource(t *testing.T) {
func
TestResourceNoName
(
t
*
testing
.
T
)
{
func
TestResourceNoName
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
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) {
...
@@ -680,7 +680,7 @@ func TestResourceNoName(t *testing.T) {
func
TestResourceNoType
(
t
*
testing
.
T
)
{
func
TestResourceNoType
(
t
*
testing
.
T
)
{
testExpansion
(
testExpansion
(
t
,
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Name
:
"test_invocation"
,
Type
:
funcName
(),
Type
:
funcName
(),
...
...
cmd/expandybird/service/service.go
View file @
f2180cea
...
@@ -43,8 +43,8 @@ func NewService(handler restful.RouteFunction) *Service {
...
@@ -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
.
Expansion
Request
{})
.
Reads
(
&
expansion
.
Service
Request
{})
.
Writes
(
&
expansion
.
Expansion
Response
{}))
Writes
(
&
expansion
.
Service
Response
{}))
return
&
Service
{
webService
}
return
&
Service
{
webService
}
}
}
...
@@ -64,7 +64,7 @@ func (s *Service) Register(container *restful.Container) {
...
@@ -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
.
Expansion
Request
{}
request
:=
&
expansion
.
Service
Request
{}
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
...
...
pkg/expansion/types.go
View file @
f2180cea
...
@@ -21,18 +21,18 @@ import (
...
@@ -21,18 +21,18 @@ import (
"github.com/kubernetes/helm/pkg/common"
"github.com/kubernetes/helm/pkg/common"
)
)
//
Expansion
Request defines the API to expander.
//
Service
Request defines the API to expander.
type
Expansion
Request
struct
{
type
Service
Request
struct
{
ChartInvocation
*
common
.
Resource
`json:"chart_invocation"`
ChartInvocation
*
common
.
Resource
`json:"chart_invocation"`
Chart
*
chart
.
Content
`json:"chart"`
Chart
*
chart
.
Content
`json:"chart"`
}
}
//
Expansion
Response defines the API to expander.
//
Service
Response defines the API to expander.
type
Expansion
Response
struct
{
type
Service
Response
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
)
(
*
Expansion
Response
,
error
)
ExpandChart
(
request
*
ServiceRequest
)
(
*
Service
Response
,
error
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment