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
10aa6ff7
Commit
10aa6ff7
authored
Nov 17, 2015
by
Brendan Melville
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Expand to the manager.
parent
1befa70c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
8 deletions
+48
-8
manager.go
manager/manager/manager.go
+25
-8
manager_test.go
manager/manager/manager_test.go
+23
-0
No files found.
manager/manager/manager.go
View file @
10aa6ff7
...
...
@@ -28,6 +28,7 @@ type Manager interface {
PutDeployment
(
name
string
,
t
*
Template
)
(
*
Deployment
,
error
)
ListManifests
(
deploymentName
string
)
(
map
[
string
]
*
Manifest
,
error
)
GetManifest
(
deploymentName
string
,
manifest
string
)
(
*
Manifest
,
error
)
Expand
(
t
*
Template
)
(
*
Manifest
,
error
)
ListTypes
()
[]
string
ListInstances
(
typeName
string
)
[]
*
TypeInstance
}
...
...
@@ -96,7 +97,7 @@ func (m *manager) CreateDeployment(t *Template) (*Deployment, error) {
return
nil
,
err
}
manifest
,
err
:=
createManifest
(
t
)
manifest
,
err
:=
m
.
createManifest
(
t
)
if
err
!=
nil
{
log
.
Printf
(
"Manifest creation failed: %v"
,
err
)
m
.
repository
.
SetDeploymentStatus
(
t
.
Name
,
FailedStatus
)
...
...
@@ -110,7 +111,7 @@ func (m *manager) CreateDeployment(t *Template) (*Deployment, error) {
return
nil
,
err
}
if
err
:=
m
.
deployer
.
CreateConfiguration
(
et
.
Config
);
err
!=
nil
{
if
err
:=
m
.
deployer
.
CreateConfiguration
(
manifest
.
Expanded
Config
);
err
!=
nil
{
// Deployment failed, mark as deleted
log
.
Printf
(
"CreateConfiguration failed: %v"
,
err
)
m
.
repository
.
SetDeploymentStatus
(
t
.
Name
,
FailedStatus
)
...
...
@@ -136,7 +137,7 @@ func (m *manager) createManifest(t *Template) (*Manifest, error) {
InputConfig
:
t
,
ExpandedConfig
:
et
.
Config
,
Layout
:
et
.
Layout
,
}
}
,
nil
}
func
(
m
*
manager
)
addTypeInstances
(
deploymentName
string
,
manifestName
string
,
layout
*
Layout
)
{
...
...
@@ -188,7 +189,7 @@ func (m *manager) DeleteDeployment(name string, forget bool) (*Deployment, error
}
// Create an empty manifest since resources have been deleted.
err
=
m
.
repository
.
AddManifest
(
name
,
NewManifest
(
name
,
generateManifestName
())
)
err
=
m
.
repository
.
AddManifest
(
name
,
&
Manifest
{
Deployment
:
name
,
Name
:
generateManifestName
()}
)
if
err
!=
nil
{
log
.
Printf
(
"Failed to add empty manifest"
)
return
nil
,
err
...
...
@@ -224,10 +225,13 @@ func (m *manager) PutDeployment(name string, t *Template) (*Deployment, error) {
return
nil
,
err
}
manifest
:=
NewManifest
(
t
.
Name
,
generateManifestName
())
manifest
.
InputConfig
=
t
manifest
.
ExpandedConfig
=
et
.
Config
manifest
.
Layout
=
et
.
Layout
manifest
:=
&
Manifest
{
Deployment
:
t
.
Name
,
Name
:
generateManifestName
(),
InputConfig
:
t
,
ExpandedConfig
:
et
.
Config
,
Layout
:
et
.
Layout
,
}
err
=
m
.
repository
.
AddManifest
(
t
.
Name
,
manifest
)
if
err
!=
nil
{
...
...
@@ -240,6 +244,19 @@ func (m *manager) PutDeployment(name string, t *Template) (*Deployment, error) {
return
m
.
repository
.
GetValidDeployment
(
t
.
Name
)
}
func
(
m
*
manager
)
Expand
(
t
*
Template
)
(
*
Manifest
,
error
)
{
et
,
err
:=
m
.
expander
.
ExpandTemplate
(
*
t
)
if
err
!=
nil
{
log
.
Printf
(
"Expansion failed %v"
,
err
)
return
nil
,
err
}
return
&
Manifest
{
ExpandedConfig
:
et
.
Config
,
Layout
:
et
.
Layout
,
},
nil
}
func
(
m
*
manager
)
ListTypes
()
[]
string
{
return
m
.
repository
.
ListTypes
()
}
...
...
manager/manager/manager_test.go
View file @
10aa6ff7
...
...
@@ -394,6 +394,29 @@ func TestDeleteDeploymentForget(t *testing.T) {
}
}
func
TestExpand
(
t
*
testing
.
T
)
{
m
,
err
:=
testManager
.
Expand
(
&
template
)
if
err
!=
nil
{
t
.
Error
(
"Failed to expand template into manifest."
)
}
if
m
.
InputConfig
!=
nil
{
t
.
Errorf
(
"Input config not nil: %v"
,
*
m
)
}
if
m
.
InputConfig
!=
nil
{
t
.
Errorf
(
"Input config not nil: %v"
,
*
m
)
}
if
!
reflect
.
DeepEqual
(
*
m
.
ExpandedConfig
,
configuration
)
{
t
.
Errorf
(
"Expanded config not correct in output manifest: %v"
,
*
m
)
}
if
!
reflect
.
DeepEqual
(
*
m
.
Layout
,
layout
)
{
t
.
Errorf
(
"Layout not correct in output manifest: %v"
,
*
m
)
}
}
func
TestListTypes
(
t
*
testing
.
T
)
{
testRepository
.
reset
()
...
...
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