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
6a1ba3d4
Commit
6a1ba3d4
authored
Nov 12, 2015
by
Jack Greenfield
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #40 from bmelville/master
Fixes multiple error propagation issues
parents
1cff534a
4965c3ac
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
24 deletions
+31
-24
service.go
expandybird/service/service.go
+2
-2
deployer.go
manager/manager/deployer.go
+6
-6
expander.go
manager/manager/expander.go
+16
-16
redis.yaml
types/redis/v1/redis.yaml
+7
-0
No files found.
expandybird/service/service.go
View file @
6a1ba3d4
...
...
@@ -68,14 +68,14 @@ func NewExpansionHandler(backend expander.Expander) restful.RouteFunction {
output
,
err
:=
backend
.
ExpandTemplate
(
template
)
if
err
!=
nil
{
message
:=
fmt
.
Sprintf
(
"error
(%s) expanding template:
\n
%v
\n
"
,
err
,
template
)
message
:=
fmt
.
Sprintf
(
"error
expanding template: %s"
,
err
)
logAndReturnErrorFromHandler
(
http
.
StatusBadRequest
,
message
,
resp
)
return
}
response
,
err
:=
expander
.
NewExpansionResponse
(
output
)
if
err
!=
nil
{
message
:=
fmt
.
Sprintf
(
"error
(%s) marshaling output:
\n
%v
\n
"
,
err
,
output
)
message
:=
fmt
.
Sprintf
(
"error
marshaling output: %s"
,
err
)
logAndReturnErrorFromHandler
(
http
.
StatusBadRequest
,
message
,
resp
)
return
}
...
...
manager/manager/deployer.go
View file @
6a1ba3d4
...
...
@@ -100,7 +100,7 @@ func (d *deployer) PutConfiguration(configuration *Configuration) error {
func
(
d
*
deployer
)
callServiceWithConfiguration
(
method
,
operation
string
,
configuration
*
Configuration
)
error
{
callback
:=
func
(
e
error
)
error
{
return
fmt
.
Errorf
(
"cannot %s configuration
(%s)
"
,
operation
,
e
)
return
fmt
.
Errorf
(
"cannot %s configuration
: %s
"
,
operation
,
e
)
}
y
,
err
:=
yaml
.
Marshal
(
configuration
)
...
...
@@ -129,14 +129,14 @@ func (d *deployer) callService(method, url string, reader io.Reader, callback fo
}
defer
response
.
Body
.
Close
()
if
response
.
StatusCode
<
http
.
StatusOK
||
response
.
StatusCode
>=
http
.
StatusMultipleChoices
{
err
:=
fmt
.
Errorf
(
"deployer service response:
\n
%v
\n
"
,
response
)
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
return
nil
,
callback
(
err
)
}
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
if
response
.
StatusCode
<
http
.
StatusOK
||
response
.
StatusCode
>=
http
.
StatusMultipleChoices
{
err
:=
fmt
.
Errorf
(
"resourcifier response:
\n
%s"
,
body
)
return
nil
,
callback
(
err
)
}
...
...
manager/manager/expander.go
View file @
6a1ba3d4
...
...
@@ -54,7 +54,7 @@ func (e *expander) getBaseURL() string {
}
func
expanderError
(
t
*
Template
,
err
error
)
error
{
return
fmt
.
Errorf
(
"cannot expand template named %s (%s):
\n
%s
\n
"
,
t
.
Name
,
err
,
t
.
Content
)
return
fmt
.
Errorf
(
"cannot expand template named %s (%s):
\n
%s"
,
t
.
Name
,
err
,
t
.
Content
)
}
// ExpanderResponse gives back a layout, which has nested structure
...
...
@@ -117,7 +117,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
// 4. If type resolution resulted in new imports being available, return to 2.
config
:=
&
Configuration
{}
if
err
:=
yaml
.
Unmarshal
([]
byte
(
t
.
Content
),
config
);
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"Unable to unmarshal configuration (%s): %s
\n
"
,
err
,
t
.
Content
)
e
:=
fmt
.
Errorf
(
"Unable to unmarshal configuration (%s): %s"
,
err
,
t
.
Content
)
return
nil
,
e
}
...
...
@@ -127,7 +127,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
// Start things off by attempting to resolve the templates in a first pass.
newImp
,
err
:=
e
.
typeResolver
.
ResolveTypes
(
config
,
t
.
Imports
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"type resolution failed:
%s
\n
"
,
err
)
e
:=
fmt
.
Errorf
(
"type resolution failed:
%s
"
,
err
)
return
nil
,
expanderError
(
&
t
,
e
)
}
...
...
@@ -137,7 +137,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
// Now expand with everything imported.
result
,
err
:=
e
.
expandTemplate
(
&
t
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"template expansion:
%s
\n
"
,
err
)
e
:=
fmt
.
Errorf
(
"template expansion:
%s
"
,
err
)
return
nil
,
expanderError
(
&
t
,
e
)
}
...
...
@@ -152,7 +152,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
newImp
,
err
=
e
.
typeResolver
.
ResolveTypes
(
result
.
Config
,
nil
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"type resolution failed:
%s
\n
"
,
err
)
e
:=
fmt
.
Errorf
(
"type resolution failed:
%s
"
,
err
)
return
nil
,
expanderError
(
&
t
,
e
)
}
...
...
@@ -167,7 +167,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
content
,
err
=
yaml
.
Marshal
(
result
.
Config
)
t
.
Content
=
string
(
content
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"Unable to unmarshal response from expander (%s): %s
\n
"
,
e
:=
fmt
.
Errorf
(
"Unable to unmarshal response from expander (%s): %s"
,
err
,
result
.
Config
)
return
nil
,
expanderError
(
&
t
,
e
)
}
...
...
@@ -183,31 +183,31 @@ func (e *expander) expandTemplate(t *Template) (*ExpandedTemplate, error) {
response
,
err
:=
http
.
Post
(
e
.
getBaseURL
(),
"application/json"
,
ioutil
.
NopCloser
(
bytes
.
NewReader
(
j
)))
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"http POST failed:
%s
\n
"
,
err
)
e
:=
fmt
.
Errorf
(
"http POST failed:
%s
"
,
err
)
return
nil
,
e
}
defer
response
.
Body
.
Close
()
if
response
.
StatusCode
!=
http
.
StatusOK
{
err
:=
fmt
.
Errorf
(
"expander service response:%v"
,
response
)
return
nil
,
err
}
defer
response
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"error reading response:
%s
\n
"
,
err
)
e
:=
fmt
.
Errorf
(
"error reading response:
%s
"
,
err
)
return
nil
,
e
}
if
response
.
StatusCode
!=
http
.
StatusOK
{
err
:=
fmt
.
Errorf
(
"expandybird response:
\n
%s"
,
body
)
return
nil
,
err
}
er
:=
&
ExpansionResponse
{}
if
err
:=
json
.
Unmarshal
(
body
,
er
);
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"cannot unmarshal response body (%s):%s
\n
"
,
err
,
body
)
e
:=
fmt
.
Errorf
(
"cannot unmarshal response body (%s):%s"
,
err
,
body
)
return
nil
,
e
}
template
,
err
:=
er
.
Unmarshal
()
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"cannot unmarshal response yaml (%s):%v
\n
"
,
err
,
er
)
e
:=
fmt
.
Errorf
(
"cannot unmarshal response yaml (%s):%v"
,
err
,
er
)
return
nil
,
e
}
...
...
types/redis/v1/redis.yaml
0 → 100644
View file @
6a1ba3d4
imports
:
-
path
:
redis.jinja
resources
:
-
name
:
redis
type
:
redis.jinja
properties
:
null
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