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
43a6876a
Commit
43a6876a
authored
Mar 23, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor manager/manager
parent
e1afffbc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
47 deletions
+47
-47
manager.go
cmd/manager/manager/manager.go
+0
-0
manager_test.go
cmd/manager/manager/manager_test.go
+45
-45
types.go
pkg/common/types.go
+2
-2
No files found.
cmd/manager/manager/manager.go
View file @
43a6876a
This diff is collapsed.
Click to expand it.
cmd/manager/manager/manager_test.go
View file @
43a6876a
...
@@ -17,13 +17,13 @@ limitations under the License.
...
@@ -17,13 +17,13 @@ limitations under the License.
package
manager
package
manager
import
(
import
(
"github.com/kubernetes/helm/pkg/common"
"github.com/kubernetes/helm/pkg/repo"
"errors"
"errors"
"reflect"
"reflect"
"strings"
"strings"
"testing"
"testing"
"github.com/kubernetes/helm/pkg/common"
"github.com/kubernetes/helm/pkg/registry"
)
)
var
template
=
common
.
Template
{
Name
:
"test"
,
Content
:
"test"
}
var
template
=
common
.
Template
{
Name
:
"test"
,
Content
:
"test"
}
...
@@ -128,17 +128,17 @@ func (deployer *deployerStub) PutConfiguration(configuration *common.Configurati
...
@@ -128,17 +128,17 @@ func (deployer *deployerStub) PutConfiguration(configuration *common.Configurati
}
}
type
repositoryStub
struct
{
type
repositoryStub
struct
{
FailListDeployments
bool
FailListDeployments
bool
Created
[]
string
Created
[]
string
ManifestAdd
map
[
string
]
*
common
.
Manifest
ManifestAdd
map
[
string
]
*
common
.
Manifest
ManifestSet
map
[
string
]
*
common
.
Manifest
ManifestSet
map
[
string
]
*
common
.
Manifest
Deleted
[]
string
Deleted
[]
string
GetValid
[]
string
GetValid
[]
string
Type
Instances
map
[
string
][]
string
Chart
Instances
map
[
string
][]
string
Type
InstancesCleared
bool
Chart
InstancesCleared
bool
Get
Type
InstancesCalled
bool
Get
Chart
InstancesCalled
bool
ListTypesCalled
bool
ListTypesCalled
bool
DeploymentStates
[]
*
common
.
DeploymentState
DeploymentStates
[]
*
common
.
DeploymentState
}
}
func
(
repository
*
repositoryStub
)
reset
()
{
func
(
repository
*
repositoryStub
)
reset
()
{
...
@@ -148,9 +148,9 @@ func (repository *repositoryStub) reset() {
...
@@ -148,9 +148,9 @@ func (repository *repositoryStub) reset() {
repository
.
ManifestSet
=
make
(
map
[
string
]
*
common
.
Manifest
)
repository
.
ManifestSet
=
make
(
map
[
string
]
*
common
.
Manifest
)
repository
.
Deleted
=
make
([]
string
,
0
)
repository
.
Deleted
=
make
([]
string
,
0
)
repository
.
GetValid
=
make
([]
string
,
0
)
repository
.
GetValid
=
make
([]
string
,
0
)
repository
.
Type
Instances
=
make
(
map
[
string
][]
string
)
repository
.
Chart
Instances
=
make
(
map
[
string
][]
string
)
repository
.
Type
InstancesCleared
=
false
repository
.
Chart
InstancesCleared
=
false
repository
.
Get
Type
InstancesCalled
=
false
repository
.
Get
Chart
InstancesCalled
=
false
repository
.
ListTypesCalled
=
false
repository
.
ListTypesCalled
=
false
repository
.
DeploymentStates
=
[]
*
common
.
DeploymentState
{}
repository
.
DeploymentStates
=
[]
*
common
.
DeploymentState
{}
}
}
...
@@ -233,26 +233,26 @@ func (repository *repositoryStub) GetLatestManifest(d string) (*common.Manifest,
...
@@ -233,26 +233,26 @@ func (repository *repositoryStub) GetLatestManifest(d string) (*common.Manifest,
}
}
// Types.
// Types.
func
(
repository
*
repositoryStub
)
List
Type
s
()
([]
string
,
error
)
{
func
(
repository
*
repositoryStub
)
List
Chart
s
()
([]
string
,
error
)
{
repository
.
ListTypesCalled
=
true
repository
.
ListTypesCalled
=
true
return
[]
string
{},
nil
return
[]
string
{},
nil
}
}
func
(
repository
*
repositoryStub
)
Get
TypeInstances
(
t
string
)
([]
*
common
.
Type
Instance
,
error
)
{
func
(
repository
*
repositoryStub
)
Get
ChartInstances
(
t
string
)
([]
*
common
.
Chart
Instance
,
error
)
{
repository
.
Get
Type
InstancesCalled
=
true
repository
.
Get
Chart
InstancesCalled
=
true
return
[]
*
common
.
Type
Instance
{},
nil
return
[]
*
common
.
Chart
Instance
{},
nil
}
}
func
(
repository
*
repositoryStub
)
Clear
Type
InstancesForDeployment
(
d
string
)
error
{
func
(
repository
*
repositoryStub
)
Clear
Chart
InstancesForDeployment
(
d
string
)
error
{
repository
.
Type
InstancesCleared
=
true
repository
.
Chart
InstancesCleared
=
true
return
nil
return
nil
}
}
func
(
repository
*
repositoryStub
)
Add
TypeInstances
(
is
map
[
string
][]
*
common
.
Type
Instance
)
error
{
func
(
repository
*
repositoryStub
)
Add
ChartInstances
(
is
map
[
string
][]
*
common
.
Chart
Instance
)
error
{
for
t
,
instances
:=
range
is
{
for
t
,
instances
:=
range
is
{
for
_
,
instance
:=
range
instances
{
for
_
,
instance
:=
range
instances
{
d
:=
instance
.
Deployment
d
:=
instance
.
Deployment
repository
.
TypeInstances
[
d
]
=
append
(
repository
.
Type
Instances
[
d
],
t
)
repository
.
ChartInstances
[
d
]
=
append
(
repository
.
Chart
Instances
[
d
],
t
)
}
}
}
}
...
@@ -264,10 +264,10 @@ func (repository *repositoryStub) Close() {}
...
@@ -264,10 +264,10 @@ func (repository *repositoryStub) Close() {}
var
testExpander
=
&
expanderStub
{}
var
testExpander
=
&
expanderStub
{}
var
testRepository
=
newRepositoryStub
()
var
testRepository
=
newRepositoryStub
()
var
testDeployer
=
newDeployerStub
()
var
testDeployer
=
newDeployerStub
()
var
testRe
gistryService
=
registry
.
NewInmemRegistry
Service
()
var
testRe
poService
=
repo
.
NewInmemRepo
Service
()
var
testCredentialProvider
=
re
gistry
.
NewInmemCredentialProvider
()
var
testCredentialProvider
=
re
po
.
NewInmemCredentialProvider
()
var
testProvider
=
re
gistry
.
NewRegistryProvider
(
nil
,
registry
.
NewTestGithubRegistryProvider
(
""
,
nil
),
registry
.
NewTestGCSRegistryProvider
(
""
,
nil
),
testCredentialProvider
)
var
testProvider
=
re
po
.
NewRepoProvider
(
nil
,
repo
.
NewGCSRepoProvider
(
testCredentialProvider
),
testCredentialProvider
)
var
testManager
=
NewManager
(
testExpander
,
testDeployer
,
testRepository
,
testProvider
,
testRe
gistry
Service
,
testCredentialProvider
)
var
testManager
=
NewManager
(
testExpander
,
testDeployer
,
testRepository
,
testProvider
,
testRe
po
Service
,
testCredentialProvider
)
func
TestListDeployments
(
t
*
testing
.
T
)
{
func
TestListDeployments
(
t
*
testing
.
T
)
{
testRepository
.
reset
()
testRepository
.
reset
()
...
@@ -363,12 +363,12 @@ func TestCreateDeployment(t *testing.T) {
...
@@ -363,12 +363,12 @@ func TestCreateDeployment(t *testing.T) {
t
.
Fatal
(
"CreateDeployment success did not mark deployment as deployed"
)
t
.
Fatal
(
"CreateDeployment success did not mark deployment as deployed"
)
}
}
if
!
testRepository
.
Type
InstancesCleared
{
if
!
testRepository
.
Chart
InstancesCleared
{
t
.
Fatal
(
"Repository did not clear type instances during creation"
)
t
.
Fatal
(
"Repository did not clear type instances during creation"
)
}
}
if
!
reflect
.
DeepEqual
(
testRepository
.
Type
Instances
,
typeInstMap
)
{
if
!
reflect
.
DeepEqual
(
testRepository
.
Chart
Instances
,
typeInstMap
)
{
t
.
Fatalf
(
"Unexpected type instances after CreateDeployment: %s"
,
testRepository
.
Type
Instances
)
t
.
Fatalf
(
"Unexpected type instances after CreateDeployment: %s"
,
testRepository
.
Chart
Instances
)
}
}
}
}
...
@@ -397,7 +397,7 @@ func TestCreateDeploymentCreationFailure(t *testing.T) {
...
@@ -397,7 +397,7 @@ func TestCreateDeploymentCreationFailure(t *testing.T) {
"Received: %v, %s. Expected: %s, %s."
,
d
,
err
,
"nil"
,
errTest
)
"Received: %v, %s. Expected: %s, %s."
,
d
,
err
,
"nil"
,
errTest
)
}
}
if
testRepository
.
Type
InstancesCleared
{
if
testRepository
.
Chart
InstancesCleared
{
t
.
Fatal
(
"Unexpected change to type instances during CreateDeployment failure."
)
t
.
Fatal
(
"Unexpected change to type instances during CreateDeployment failure."
)
}
}
}
}
...
@@ -437,7 +437,7 @@ func TestCreateDeploymentCreationResourceFailure(t *testing.T) {
...
@@ -437,7 +437,7 @@ func TestCreateDeploymentCreationResourceFailure(t *testing.T) {
"Received: %v, %v. Expected: %v, %v."
,
d
,
err
,
&
deployment
,
"nil"
)
"Received: %v, %v. Expected: %v, %v."
,
d
,
err
,
&
deployment
,
"nil"
)
}
}
if
!
testRepository
.
Type
InstancesCleared
{
if
!
testRepository
.
Chart
InstancesCleared
{
t
.
Fatal
(
"Repository did not clear type instances during creation"
)
t
.
Fatal
(
"Repository did not clear type instances during creation"
)
}
}
}
}
...
@@ -486,7 +486,7 @@ func TestDeleteDeploymentForget(t *testing.T) {
...
@@ -486,7 +486,7 @@ func TestDeleteDeploymentForget(t *testing.T) {
}
}
}
}
if
!
testRepository
.
Type
InstancesCleared
{
if
!
testRepository
.
Chart
InstancesCleared
{
t
.
Fatal
(
"Expected type instances to be cleared during DeleteDeployment."
)
t
.
Fatal
(
"Expected type instances to be cleared during DeleteDeployment."
)
}
}
}
}
...
@@ -521,29 +521,29 @@ func TestExpand(t *testing.T) {
...
@@ -521,29 +521,29 @@ func TestExpand(t *testing.T) {
func
TestListTypes
(
t
*
testing
.
T
)
{
func
TestListTypes
(
t
*
testing
.
T
)
{
testRepository
.
reset
()
testRepository
.
reset
()
testManager
.
List
Type
s
()
testManager
.
List
Chart
s
()
if
!
testRepository
.
ListTypesCalled
{
if
!
testRepository
.
ListTypesCalled
{
t
.
Fatal
(
"expected repository List
Type
s() call."
)
t
.
Fatal
(
"expected repository List
Chart
s() call."
)
}
}
}
}
func
TestListInstances
(
t
*
testing
.
T
)
{
func
TestListInstances
(
t
*
testing
.
T
)
{
testRepository
.
reset
()
testRepository
.
reset
()
testManager
.
ListInstances
(
"all"
)
testManager
.
List
Chart
Instances
(
"all"
)
if
!
testRepository
.
Get
Type
InstancesCalled
{
if
!
testRepository
.
Get
Chart
InstancesCalled
{
t
.
Fatal
(
"expected repository Get
Type
Instances() call."
)
t
.
Fatal
(
"expected repository Get
Chart
Instances() call."
)
}
}
}
}
// TODO(jackgr): Implement TestListRe
gistryType
s
// TODO(jackgr): Implement TestListRe
poChart
s
func
TestListRe
gistryType
s
(
t
*
testing
.
T
)
{
func
TestListRe
poChart
s
(
t
*
testing
.
T
)
{
/*
/*
types, err := testManager.ListRe
gistryType
s("", nil)
types, err := testManager.ListRe
poChart
s("", nil)
if err != nil {
if err != nil {
t.Fatalf("cannot list re
gist
ry types: %s", err)
t.Fatalf("cannot list re
posito
ry types: %s", err)
}
}
*/
*/
}
}
...
@@ -551,7 +551,7 @@ func TestListRegistryTypes(t *testing.T) {
...
@@ -551,7 +551,7 @@ func TestListRegistryTypes(t *testing.T) {
// TODO(jackgr): Implement TestGetDownloadURLs
// TODO(jackgr): Implement TestGetDownloadURLs
func
TestGetDownloadURLs
(
t
*
testing
.
T
)
{
func
TestGetDownloadURLs
(
t
*
testing
.
T
)
{
/*
/*
urls, err := testManager.GetDownloadURLs("", re
gistry
.Type{})
urls, err := testManager.GetDownloadURLs("", re
po
.Type{})
if err != nil {
if err != nil {
t.Fatalf("cannot list get download urls: %s", err)
t.Fatalf("cannot list get download urls: %s", err)
}
}
...
...
pkg/common/types.go
View file @
43a6876a
...
@@ -170,9 +170,9 @@ type Resource struct {
...
@@ -170,9 +170,9 @@ type Resource struct {
State
*
ResourceState
`json:"state,omitempty"`
State
*
ResourceState
`json:"state,omitempty"`
}
}
//
Type
Instance defines the metadata for an instantiation of a template type
//
Chart
Instance defines the metadata for an instantiation of a template type
// in a deployment.
// in a deployment.
type
Type
Instance
struct
{
type
Chart
Instance
struct
{
Name
string
`json:"name"`
// instance name
Name
string
`json:"name"`
// instance name
Type
string
`json:"type"`
// instance type
Type
string
`json:"type"`
// instance type
Deployment
string
`json:"deployment"`
// deployment name
Deployment
string
`json:"deployment"`
// deployment name
...
...
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