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
Hide 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 {
// ExpandChart passes the given configuration to the expander and returns the
// 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
{
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
&
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"
type
testCase
struct
{
Description
string
Request
*
expansion
.
Expansion
Request
ExpectedResponse
*
expansion
.
Expansion
Response
Request
*
expansion
.
Service
Request
ExpectedResponse
*
expansion
.
Service
Response
ExpectedError
string
}
...
...
@@ -48,8 +48,8 @@ func funcName() string {
return
runtime
.
FuncForPC
(
pc
)
.
Name
()
}
func
testExpansion
(
t
*
testing
.
T
,
req
*
expansion
.
Expansion
Request
,
expResponse
*
expansion
.
Expansion
Response
,
expError
string
)
{
func
testExpansion
(
t
*
testing
.
T
,
req
*
expansion
.
Service
Request
,
expResponse
*
expansion
.
Service
Response
,
expError
string
)
{
backend
:=
NewExpander
(
expanderName
)
response
,
err
:=
backend
.
ExpandChart
(
req
)
if
err
!=
nil
{
...
...
@@ -82,7 +82,7 @@ var jinjaExpander = &chart.Expander{
func
TestEmptyJinja
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -100,7 +100,7 @@ func TestEmptyJinja(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{},
},
""
,
// Error
...
...
@@ -110,7 +110,7 @@ func TestEmptyJinja(t *testing.T) {
func
TestEmptyPython
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -131,7 +131,7 @@ func TestEmptyPython(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{},
},
""
,
// Error
...
...
@@ -141,7 +141,7 @@ func TestEmptyPython(t *testing.T) {
func
TestSimpleJinja
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -163,7 +163,7 @@ func TestSimpleJinja(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -178,7 +178,7 @@ func TestSimpleJinja(t *testing.T) {
func
TestSimplePython
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -202,7 +202,7 @@ func TestSimplePython(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -217,7 +217,7 @@ func TestSimplePython(t *testing.T) {
func
TestPropertiesJinja
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -245,7 +245,7 @@ func TestPropertiesJinja(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -263,7 +263,7 @@ func TestPropertiesJinja(t *testing.T) {
func
TestPropertiesPython
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -293,7 +293,7 @@ func TestPropertiesPython(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -311,7 +311,7 @@ func TestPropertiesPython(t *testing.T) {
func
TestMultiFileJinja
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -337,7 +337,7 @@ func TestMultiFileJinja(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -369,7 +369,7 @@ var schemaContent = content([]string{
func
TestSchema
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -402,7 +402,7 @@ func TestSchema(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -420,7 +420,7 @@ func TestSchema(t *testing.T) {
func
TestSchemaFail
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -461,7 +461,7 @@ func TestSchemaFail(t *testing.T) {
func
TestMultiFileJinjaMissing
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -487,7 +487,7 @@ func TestMultiFileJinjaMissing(t *testing.T) {
func
TestMultiFilePython
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -532,7 +532,7 @@ func TestMultiFilePython(t *testing.T) {
},
},
},
&
expansion
.
Expansion
Response
{
&
expansion
.
Service
Response
{
Resources
:
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"foo"
,
...
...
@@ -547,7 +547,7 @@ func TestMultiFilePython(t *testing.T) {
func
TestMultiFilePythonMissing
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -575,7 +575,7 @@ func TestMultiFilePythonMissing(t *testing.T) {
func
TestWrongChartName
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -601,7 +601,7 @@ func TestWrongChartName(t *testing.T) {
func
TestEntrypointNotFound
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -622,7 +622,7 @@ func TestEntrypointNotFound(t *testing.T) {
func
TestMalformedResource
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -651,7 +651,7 @@ func TestMalformedResource(t *testing.T) {
func
TestResourceNoName
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
@@ -680,7 +680,7 @@ func TestResourceNoName(t *testing.T) {
func
TestResourceNoType
(
t
*
testing
.
T
)
{
testExpansion
(
t
,
&
expansion
.
Expansion
Request
{
&
expansion
.
Service
Request
{
ChartInvocation
:
&
common
.
Resource
{
Name
:
"test_invocation"
,
Type
:
funcName
(),
...
...
cmd/expandybird/service/service.go
View file @
f2180cea
...
...
@@ -43,8 +43,8 @@ func NewService(handler restful.RouteFunction) *Service {
webService
.
Produces
(
restful
.
MIME_JSON
,
restful
.
MIME_XML
)
webService
.
Route
(
webService
.
POST
(
"/expand"
)
.
To
(
handler
)
.
Doc
(
"Expand a template."
)
.
Reads
(
&
expansion
.
Expansion
Request
{})
.
Writes
(
&
expansion
.
Expansion
Response
{}))
Reads
(
&
expansion
.
Service
Request
{})
.
Writes
(
&
expansion
.
Service
Response
{}))
return
&
Service
{
webService
}
}
...
...
@@ -64,7 +64,7 @@ func (s *Service) Register(container *restful.Container) {
func
NewExpansionHandler
(
backend
expansion
.
Expander
)
restful
.
RouteFunction
{
return
func
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
util
.
LogHandlerEntry
(
"expandybird: expand"
,
req
.
Request
)
request
:=
&
expansion
.
Expansion
Request
{}
request
:=
&
expansion
.
Service
Request
{}
if
err
:=
req
.
ReadEntity
(
&
request
);
err
!=
nil
{
logAndReturnErrorFromHandler
(
http
.
StatusBadRequest
,
err
.
Error
(),
resp
)
return
...
...
pkg/expansion/types.go
View file @
f2180cea
...
...
@@ -21,18 +21,18 @@ import (
"github.com/kubernetes/helm/pkg/common"
)
//
Expansion
Request defines the API to expander.
type
Expansion
Request
struct
{
//
Service
Request defines the API to expander.
type
Service
Request
struct
{
ChartInvocation
*
common
.
Resource
`json:"chart_invocation"`
Chart
*
chart
.
Content
`json:"chart"`
}
//
Expansion
Response defines the API to expander.
type
Expansion
Response
struct
{
//
Service
Response defines the API to expander.
type
Service
Response
struct
{
Resources
[]
interface
{}
`json:"resources"`
}
// Expander abstracts interactions with the expander and deployer services.
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