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
c0850efe
Commit
c0850efe
authored
Nov 02, 2016
by
adieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate tiller into pkg and cmd so we can use tiller as a library.
parent
6b31664c
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
49 additions
and
48 deletions
+49
-48
tiller.go
cmd/tiller/tiller.go
+5
-1
tiller_test.go
cmd/tiller/tiller_test.go
+1
-1
environment.go
pkg/tiller/environment/environment.go
+0
-0
environment_test.go
pkg/tiller/environment/environment_test.go
+0
-0
hooks.go
pkg/tiller/hooks.go
+1
-1
hooks_test.go
pkg/tiller/hooks_test.go
+1
-1
kind_sorter.go
pkg/tiller/kind_sorter.go
+1
-1
kind_sorter_test.go
pkg/tiller/kind_sorter_test.go
+1
-1
release_history.go
pkg/tiller/release_history.go
+2
-2
release_history_test.go
pkg/tiller/release_history_test.go
+1
-1
release_server.go
pkg/tiller/release_server.go
+32
-35
release_server_test.go
pkg/tiller/release_server_test.go
+4
-4
No files found.
cmd/tiller/tiller.go
View file @
c0850efe
...
@@ -25,9 +25,11 @@ import (
...
@@ -25,9 +25,11 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc"
"k8s.io/helm/
cmd/tiller/environment
"
"k8s.io/helm/
pkg/proto/hapi/services
"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/tiller"
"k8s.io/helm/pkg/tiller/environment"
)
)
const
(
const
(
...
@@ -104,6 +106,8 @@ func start(c *cobra.Command, args []string) {
...
@@ -104,6 +106,8 @@ func start(c *cobra.Command, args []string) {
srvErrCh
:=
make
(
chan
error
)
srvErrCh
:=
make
(
chan
error
)
probeErrCh
:=
make
(
chan
error
)
probeErrCh
:=
make
(
chan
error
)
go
func
()
{
go
func
()
{
svc
:=
tiller
.
NewReleaseServer
(
env
)
services
.
RegisterReleaseServiceServer
(
rootServer
,
svc
)
if
err
:=
rootServer
.
Serve
(
lstn
);
err
!=
nil
{
if
err
:=
rootServer
.
Serve
(
lstn
);
err
!=
nil
{
srvErrCh
<-
err
srvErrCh
<-
err
}
}
...
...
cmd/tiller/tiller_test.go
View file @
c0850efe
...
@@ -19,8 +19,8 @@ package main
...
@@ -19,8 +19,8 @@ package main
import
(
import
(
"testing"
"testing"
"k8s.io/helm/cmd/tiller/environment"
"k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/tiller/environment"
)
)
// These are canary tests to make sure that the default server actually
// These are canary tests to make sure that the default server actually
...
...
cmd
/tiller/environment/environment.go
→
pkg
/tiller/environment/environment.go
View file @
c0850efe
File moved
cmd
/tiller/environment/environment_test.go
→
pkg
/tiller/environment/environment_test.go
View file @
c0850efe
File moved
cmd
/tiller/hooks.go
→
pkg
/tiller/hooks.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"fmt"
"fmt"
...
...
cmd
/tiller/hooks_test.go
→
pkg
/tiller/hooks_test.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"testing"
"testing"
...
...
cmd
/tiller/kind_sorter.go
→
pkg
/tiller/kind_sorter.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"sort"
"sort"
...
...
cmd
/tiller/kind_sorter_test.go
→
pkg
/tiller/kind_sorter_test.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"testing"
"testing"
...
...
cmd
/tiller/release_history.go
→
pkg
/tiller/release_history.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"golang.org/x/net/context"
"golang.org/x/net/context"
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
relutil
"k8s.io/helm/pkg/releaseutil"
relutil
"k8s.io/helm/pkg/releaseutil"
)
)
func
(
s
*
r
eleaseServer
)
GetHistory
(
ctx
context
.
Context
,
req
*
tpb
.
GetHistoryRequest
)
(
*
tpb
.
GetHistoryResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
GetHistory
(
ctx
context
.
Context
,
req
*
tpb
.
GetHistoryRequest
)
(
*
tpb
.
GetHistoryResponse
,
error
)
{
if
!
checkClientVersion
(
ctx
)
{
if
!
checkClientVersion
(
ctx
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
...
cmd
/tiller/release_history_test.go
→
pkg
/tiller/release_history_test.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"reflect"
"reflect"
...
...
cmd
/tiller/release_server.go
→
pkg
/tiller/release_server.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"bytes"
"bytes"
...
@@ -31,19 +31,17 @@ import (
...
@@ -31,19 +31,17 @@ import (
ctx
"golang.org/x/net/context"
ctx
"golang.org/x/net/context"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/helm/cmd/tiller/environment"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/proto/hapi/services"
relutil
"k8s.io/helm/pkg/releaseutil"
relutil
"k8s.io/helm/pkg/releaseutil"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/tiller/environment"
"k8s.io/helm/pkg/timeconv"
"k8s.io/helm/pkg/timeconv"
"k8s.io/helm/pkg/version"
"k8s.io/helm/pkg/version"
)
)
var
srv
*
releaseServer
// releaseNameMaxLen is the maximum length of a release name.
// releaseNameMaxLen is the maximum length of a release name.
//
//
// This is designed to accommodate the usage of release name in the 'name:'
// This is designed to accommodate the usage of release name in the 'name:'
...
@@ -57,13 +55,6 @@ const releaseNameMaxLen = 14
...
@@ -57,13 +55,6 @@ const releaseNameMaxLen = 14
// since there can be filepath in front of it.
// since there can be filepath in front of it.
const
notesFileSuffix
=
"NOTES.txt"
const
notesFileSuffix
=
"NOTES.txt"
func
init
()
{
srv
=
&
releaseServer
{
env
:
env
,
}
services
.
RegisterReleaseServiceServer
(
rootServer
,
srv
)
}
var
(
var
(
// errMissingChart indicates that a chart was not provided.
// errMissingChart indicates that a chart was not provided.
errMissingChart
=
errors
.
New
(
"no chart provided"
)
errMissingChart
=
errors
.
New
(
"no chart provided"
)
...
@@ -78,10 +69,16 @@ var (
...
@@ -78,10 +69,16 @@ var (
// ListDefaultLimit is the default limit for number of items returned in a list.
// ListDefaultLimit is the default limit for number of items returned in a list.
var
ListDefaultLimit
int64
=
512
var
ListDefaultLimit
int64
=
512
type
r
eleaseServer
struct
{
type
R
eleaseServer
struct
{
env
*
environment
.
Environment
env
*
environment
.
Environment
}
}
func
NewReleaseServer
(
env
*
environment
.
Environment
)
*
ReleaseServer
{
return
&
ReleaseServer
{
env
:
env
,
}
}
func
getVersion
(
c
ctx
.
Context
)
string
{
func
getVersion
(
c
ctx
.
Context
)
string
{
if
md
,
ok
:=
metadata
.
FromContext
(
c
);
ok
{
if
md
,
ok
:=
metadata
.
FromContext
(
c
);
ok
{
if
v
,
ok
:=
md
[
"x-helm-api-client"
];
ok
{
if
v
,
ok
:=
md
[
"x-helm-api-client"
];
ok
{
...
@@ -91,7 +88,7 @@ func getVersion(c ctx.Context) string {
...
@@ -91,7 +88,7 @@ func getVersion(c ctx.Context) string {
return
""
return
""
}
}
func
(
s
*
r
eleaseServer
)
ListReleases
(
req
*
services
.
ListReleasesRequest
,
stream
services
.
ReleaseService_ListReleasesServer
)
error
{
func
(
s
*
R
eleaseServer
)
ListReleases
(
req
*
services
.
ListReleasesRequest
,
stream
services
.
ReleaseService_ListReleasesServer
)
error
{
if
!
checkClientVersion
(
stream
.
Context
())
{
if
!
checkClientVersion
(
stream
.
Context
())
{
return
errIncompatibleVersion
return
errIncompatibleVersion
}
}
...
@@ -193,7 +190,7 @@ func filterReleases(filter string, rels []*release.Release) ([]*release.Release,
...
@@ -193,7 +190,7 @@ func filterReleases(filter string, rels []*release.Release) ([]*release.Release,
return
matches
,
nil
return
matches
,
nil
}
}
func
(
s
*
r
eleaseServer
)
GetVersion
(
c
ctx
.
Context
,
req
*
services
.
GetVersionRequest
)
(
*
services
.
GetVersionResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
GetVersion
(
c
ctx
.
Context
,
req
*
services
.
GetVersionRequest
)
(
*
services
.
GetVersionResponse
,
error
)
{
v
:=
version
.
GetVersionProto
()
v
:=
version
.
GetVersionProto
()
return
&
services
.
GetVersionResponse
{
Version
:
v
},
nil
return
&
services
.
GetVersionResponse
{
Version
:
v
},
nil
}
}
...
@@ -203,7 +200,7 @@ func checkClientVersion(c ctx.Context) bool {
...
@@ -203,7 +200,7 @@ func checkClientVersion(c ctx.Context) bool {
return
version
.
IsCompatible
(
v
,
version
.
Version
)
return
version
.
IsCompatible
(
v
,
version
.
Version
)
}
}
func
(
s
*
r
eleaseServer
)
GetReleaseStatus
(
c
ctx
.
Context
,
req
*
services
.
GetReleaseStatusRequest
)
(
*
services
.
GetReleaseStatusResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
GetReleaseStatus
(
c
ctx
.
Context
,
req
*
services
.
GetReleaseStatusRequest
)
(
*
services
.
GetReleaseStatusResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
@@ -258,7 +255,7 @@ func (s *releaseServer) GetReleaseStatus(c ctx.Context, req *services.GetRelease
...
@@ -258,7 +255,7 @@ func (s *releaseServer) GetReleaseStatus(c ctx.Context, req *services.GetRelease
return
statusResp
,
nil
return
statusResp
,
nil
}
}
func
(
s
*
r
eleaseServer
)
GetReleaseContent
(
c
ctx
.
Context
,
req
*
services
.
GetReleaseContentRequest
)
(
*
services
.
GetReleaseContentResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
GetReleaseContent
(
c
ctx
.
Context
,
req
*
services
.
GetReleaseContentRequest
)
(
*
services
.
GetReleaseContentResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
@@ -275,7 +272,7 @@ func (s *releaseServer) GetReleaseContent(c ctx.Context, req *services.GetReleas
...
@@ -275,7 +272,7 @@ func (s *releaseServer) GetReleaseContent(c ctx.Context, req *services.GetReleas
return
&
services
.
GetReleaseContentResponse
{
Release
:
rel
},
err
return
&
services
.
GetReleaseContentResponse
{
Release
:
rel
},
err
}
}
func
(
s
*
r
eleaseServer
)
UpdateRelease
(
c
ctx
.
Context
,
req
*
services
.
UpdateReleaseRequest
)
(
*
services
.
UpdateReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
UpdateRelease
(
c
ctx
.
Context
,
req
*
services
.
UpdateReleaseRequest
)
(
*
services
.
UpdateReleaseResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
@@ -299,7 +296,7 @@ func (s *releaseServer) UpdateRelease(c ctx.Context, req *services.UpdateRelease
...
@@ -299,7 +296,7 @@ func (s *releaseServer) UpdateRelease(c ctx.Context, req *services.UpdateRelease
return
res
,
nil
return
res
,
nil
}
}
func
(
s
*
r
eleaseServer
)
performUpdate
(
originalRelease
,
updatedRelease
*
release
.
Release
,
req
*
services
.
UpdateReleaseRequest
)
(
*
services
.
UpdateReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
performUpdate
(
originalRelease
,
updatedRelease
*
release
.
Release
,
req
*
services
.
UpdateReleaseRequest
)
(
*
services
.
UpdateReleaseResponse
,
error
)
{
res
:=
&
services
.
UpdateReleaseResponse
{
Release
:
updatedRelease
}
res
:=
&
services
.
UpdateReleaseResponse
{
Release
:
updatedRelease
}
if
req
.
DryRun
{
if
req
.
DryRun
{
...
@@ -341,7 +338,7 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R
...
@@ -341,7 +338,7 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R
// reuseValues copies values from the current release to a new release if the new release does not have any values.
// reuseValues copies values from the current release to a new release if the new release does not have any values.
//
//
// If the request already has values, or if there are no values in the current release, this does nothing.
// If the request already has values, or if there are no values in the current release, this does nothing.
func
(
s
*
r
eleaseServer
)
reuseValues
(
req
*
services
.
UpdateReleaseRequest
,
current
*
release
.
Release
)
{
func
(
s
*
R
eleaseServer
)
reuseValues
(
req
*
services
.
UpdateReleaseRequest
,
current
*
release
.
Release
)
{
if
(
req
.
Values
==
nil
||
req
.
Values
.
Raw
==
""
)
&&
current
.
Config
!=
nil
&&
current
.
Config
.
Raw
!=
""
{
if
(
req
.
Values
==
nil
||
req
.
Values
.
Raw
==
""
)
&&
current
.
Config
!=
nil
&&
current
.
Config
.
Raw
!=
""
{
log
.
Printf
(
"Copying values from %s (v%d) to new release."
,
current
.
Name
,
current
.
Version
)
log
.
Printf
(
"Copying values from %s (v%d) to new release."
,
current
.
Name
,
current
.
Version
)
req
.
Values
=
current
.
Config
req
.
Values
=
current
.
Config
...
@@ -349,7 +346,7 @@ func (s *releaseServer) reuseValues(req *services.UpdateReleaseRequest, current
...
@@ -349,7 +346,7 @@ func (s *releaseServer) reuseValues(req *services.UpdateReleaseRequest, current
}
}
// prepareUpdate builds an updated release for an update operation.
// prepareUpdate builds an updated release for an update operation.
func
(
s
*
r
eleaseServer
)
prepareUpdate
(
req
*
services
.
UpdateReleaseRequest
)
(
*
release
.
Release
,
*
release
.
Release
,
error
)
{
func
(
s
*
R
eleaseServer
)
prepareUpdate
(
req
*
services
.
UpdateReleaseRequest
)
(
*
release
.
Release
,
*
release
.
Release
,
error
)
{
if
req
.
Name
==
""
{
if
req
.
Name
==
""
{
return
nil
,
nil
,
errMissingRelease
return
nil
,
nil
,
errMissingRelease
}
}
...
@@ -406,7 +403,7 @@ func (s *releaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
...
@@ -406,7 +403,7 @@ func (s *releaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
return
currentRelease
,
updatedRelease
,
nil
return
currentRelease
,
updatedRelease
,
nil
}
}
func
(
s
*
r
eleaseServer
)
RollbackRelease
(
c
ctx
.
Context
,
req
*
services
.
RollbackReleaseRequest
)
(
*
services
.
RollbackReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
RollbackRelease
(
c
ctx
.
Context
,
req
*
services
.
RollbackReleaseRequest
)
(
*
services
.
RollbackReleaseResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
@@ -430,7 +427,7 @@ func (s *releaseServer) RollbackRelease(c ctx.Context, req *services.RollbackRel
...
@@ -430,7 +427,7 @@ func (s *releaseServer) RollbackRelease(c ctx.Context, req *services.RollbackRel
return
res
,
nil
return
res
,
nil
}
}
func
(
s
*
r
eleaseServer
)
performRollback
(
currentRelease
,
targetRelease
*
release
.
Release
,
req
*
services
.
RollbackReleaseRequest
)
(
*
services
.
RollbackReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
performRollback
(
currentRelease
,
targetRelease
*
release
.
Release
,
req
*
services
.
RollbackReleaseRequest
)
(
*
services
.
RollbackReleaseResponse
,
error
)
{
res
:=
&
services
.
RollbackReleaseResponse
{
Release
:
targetRelease
}
res
:=
&
services
.
RollbackReleaseResponse
{
Release
:
targetRelease
}
if
req
.
DryRun
{
if
req
.
DryRun
{
...
@@ -469,7 +466,7 @@ func (s *releaseServer) performRollback(currentRelease, targetRelease *release.R
...
@@ -469,7 +466,7 @@ func (s *releaseServer) performRollback(currentRelease, targetRelease *release.R
return
res
,
nil
return
res
,
nil
}
}
func
(
s
*
r
eleaseServer
)
performKubeUpdate
(
currentRelease
,
targetRelease
*
release
.
Release
)
error
{
func
(
s
*
R
eleaseServer
)
performKubeUpdate
(
currentRelease
,
targetRelease
*
release
.
Release
)
error
{
kubeCli
:=
s
.
env
.
KubeClient
kubeCli
:=
s
.
env
.
KubeClient
current
:=
bytes
.
NewBufferString
(
currentRelease
.
Manifest
)
current
:=
bytes
.
NewBufferString
(
currentRelease
.
Manifest
)
target
:=
bytes
.
NewBufferString
(
targetRelease
.
Manifest
)
target
:=
bytes
.
NewBufferString
(
targetRelease
.
Manifest
)
...
@@ -478,7 +475,7 @@ func (s *releaseServer) performKubeUpdate(currentRelease, targetRelease *release
...
@@ -478,7 +475,7 @@ func (s *releaseServer) performKubeUpdate(currentRelease, targetRelease *release
// prepareRollback finds the previous release and prepares a new release object with
// prepareRollback finds the previous release and prepares a new release object with
// the previous release's configuration
// the previous release's configuration
func
(
s
*
r
eleaseServer
)
prepareRollback
(
req
*
services
.
RollbackReleaseRequest
)
(
*
release
.
Release
,
*
release
.
Release
,
error
)
{
func
(
s
*
R
eleaseServer
)
prepareRollback
(
req
*
services
.
RollbackReleaseRequest
)
(
*
release
.
Release
,
*
release
.
Release
,
error
)
{
switch
{
switch
{
case
req
.
Name
==
""
:
case
req
.
Name
==
""
:
return
nil
,
nil
,
errMissingRelease
return
nil
,
nil
,
errMissingRelease
...
@@ -532,7 +529,7 @@ func (s *releaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
...
@@ -532,7 +529,7 @@ func (s *releaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
return
crls
,
target
,
nil
return
crls
,
target
,
nil
}
}
func
(
s
*
r
eleaseServer
)
uniqName
(
start
string
,
reuse
bool
)
(
string
,
error
)
{
func
(
s
*
R
eleaseServer
)
uniqName
(
start
string
,
reuse
bool
)
(
string
,
error
)
{
// If a name is supplied, we check to see if that name is taken. If not, it
// If a name is supplied, we check to see if that name is taken. If not, it
// is granted. If reuse is true and a deleted release with that name exists,
// is granted. If reuse is true and a deleted release with that name exists,
...
@@ -577,7 +574,7 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
...
@@ -577,7 +574,7 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
return
"ERROR"
,
errors
.
New
(
"no available release name found"
)
return
"ERROR"
,
errors
.
New
(
"no available release name found"
)
}
}
func
(
s
*
r
eleaseServer
)
engine
(
ch
*
chart
.
Chart
)
environment
.
Engine
{
func
(
s
*
R
eleaseServer
)
engine
(
ch
*
chart
.
Chart
)
environment
.
Engine
{
renderer
:=
s
.
env
.
EngineYard
.
Default
()
renderer
:=
s
.
env
.
EngineYard
.
Default
()
if
ch
.
Metadata
.
Engine
!=
""
{
if
ch
.
Metadata
.
Engine
!=
""
{
if
r
,
ok
:=
s
.
env
.
EngineYard
.
Get
(
ch
.
Metadata
.
Engine
);
ok
{
if
r
,
ok
:=
s
.
env
.
EngineYard
.
Get
(
ch
.
Metadata
.
Engine
);
ok
{
...
@@ -589,7 +586,7 @@ func (s *releaseServer) engine(ch *chart.Chart) environment.Engine {
...
@@ -589,7 +586,7 @@ func (s *releaseServer) engine(ch *chart.Chart) environment.Engine {
return
renderer
return
renderer
}
}
func
(
s
*
r
eleaseServer
)
InstallRelease
(
c
ctx
.
Context
,
req
*
services
.
InstallReleaseRequest
)
(
*
services
.
InstallReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
InstallRelease
(
c
ctx
.
Context
,
req
*
services
.
InstallReleaseRequest
)
(
*
services
.
InstallReleaseResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
@@ -608,7 +605,7 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
...
@@ -608,7 +605,7 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
}
}
// prepareRelease builds a release for an install operation.
// prepareRelease builds a release for an install operation.
func
(
s
*
r
eleaseServer
)
prepareRelease
(
req
*
services
.
InstallReleaseRequest
)
(
*
release
.
Release
,
error
)
{
func
(
s
*
R
eleaseServer
)
prepareRelease
(
req
*
services
.
InstallReleaseRequest
)
(
*
release
.
Release
,
error
)
{
if
req
.
Chart
==
nil
{
if
req
.
Chart
==
nil
{
return
nil
,
errMissingChart
return
nil
,
errMissingChart
}
}
...
@@ -651,7 +648,7 @@ func (s *releaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
...
@@ -651,7 +648,7 @@ func (s *releaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
return
rel
,
nil
return
rel
,
nil
}
}
func
(
s
*
r
eleaseServer
)
getVersionSet
()
(
versionSet
,
error
)
{
func
(
s
*
R
eleaseServer
)
getVersionSet
()
(
versionSet
,
error
)
{
defVersions
:=
newVersionSet
(
"v1"
)
defVersions
:=
newVersionSet
(
"v1"
)
cli
,
err
:=
s
.
env
.
KubeClient
.
APIClient
()
cli
,
err
:=
s
.
env
.
KubeClient
.
APIClient
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -676,7 +673,7 @@ func (s *releaseServer) getVersionSet() (versionSet, error) {
...
@@ -676,7 +673,7 @@ func (s *releaseServer) getVersionSet() (versionSet, error) {
return
newVersionSet
(
versions
...
),
nil
return
newVersionSet
(
versions
...
),
nil
}
}
func
(
s
*
r
eleaseServer
)
renderResources
(
ch
*
chart
.
Chart
,
values
chartutil
.
Values
)
([]
*
release
.
Hook
,
*
bytes
.
Buffer
,
string
,
error
)
{
func
(
s
*
R
eleaseServer
)
renderResources
(
ch
*
chart
.
Chart
,
values
chartutil
.
Values
)
([]
*
release
.
Hook
,
*
bytes
.
Buffer
,
string
,
error
)
{
renderer
:=
s
.
engine
(
ch
)
renderer
:=
s
.
engine
(
ch
)
files
,
err
:=
renderer
.
Render
(
ch
,
values
)
files
,
err
:=
renderer
.
Render
(
ch
,
values
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -723,7 +720,7 @@ func (s *releaseServer) renderResources(ch *chart.Chart, values chartutil.Values
...
@@ -723,7 +720,7 @@ func (s *releaseServer) renderResources(ch *chart.Chart, values chartutil.Values
return
hooks
,
b
,
notes
,
nil
return
hooks
,
b
,
notes
,
nil
}
}
func
(
s
*
r
eleaseServer
)
recordRelease
(
r
*
release
.
Release
,
reuse
bool
)
{
func
(
s
*
R
eleaseServer
)
recordRelease
(
r
*
release
.
Release
,
reuse
bool
)
{
if
reuse
{
if
reuse
{
if
err
:=
s
.
env
.
Releases
.
Update
(
r
);
err
!=
nil
{
if
err
:=
s
.
env
.
Releases
.
Update
(
r
);
err
!=
nil
{
log
.
Printf
(
"warning: Failed to update release %q: %s"
,
r
.
Name
,
err
)
log
.
Printf
(
"warning: Failed to update release %q: %s"
,
r
.
Name
,
err
)
...
@@ -734,7 +731,7 @@ func (s *releaseServer) recordRelease(r *release.Release, reuse bool) {
...
@@ -734,7 +731,7 @@ func (s *releaseServer) recordRelease(r *release.Release, reuse bool) {
}
}
// performRelease runs a release.
// performRelease runs a release.
func
(
s
*
r
eleaseServer
)
performRelease
(
r
*
release
.
Release
,
req
*
services
.
InstallReleaseRequest
)
(
*
services
.
InstallReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
performRelease
(
r
*
release
.
Release
,
req
*
services
.
InstallReleaseRequest
)
(
*
services
.
InstallReleaseResponse
,
error
)
{
res
:=
&
services
.
InstallReleaseResponse
{
Release
:
r
}
res
:=
&
services
.
InstallReleaseResponse
{
Release
:
r
}
if
req
.
DryRun
{
if
req
.
DryRun
{
...
@@ -810,7 +807,7 @@ func (s *releaseServer) performRelease(r *release.Release, req *services.Install
...
@@ -810,7 +807,7 @@ func (s *releaseServer) performRelease(r *release.Release, req *services.Install
return
res
,
nil
return
res
,
nil
}
}
func
(
s
*
r
eleaseServer
)
execHook
(
hs
[]
*
release
.
Hook
,
name
,
namespace
,
hook
string
)
error
{
func
(
s
*
R
eleaseServer
)
execHook
(
hs
[]
*
release
.
Hook
,
name
,
namespace
,
hook
string
)
error
{
kubeCli
:=
s
.
env
.
KubeClient
kubeCli
:=
s
.
env
.
KubeClient
code
,
ok
:=
events
[
hook
]
code
,
ok
:=
events
[
hook
]
if
!
ok
{
if
!
ok
{
...
@@ -848,7 +845,7 @@ func (s *releaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
...
@@ -848,7 +845,7 @@ func (s *releaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
return
nil
return
nil
}
}
func
(
s
*
r
eleaseServer
)
purgeReleases
(
rels
...*
release
.
Release
)
error
{
func
(
s
*
R
eleaseServer
)
purgeReleases
(
rels
...*
release
.
Release
)
error
{
for
_
,
rel
:=
range
rels
{
for
_
,
rel
:=
range
rels
{
if
_
,
err
:=
s
.
env
.
Releases
.
Delete
(
rel
.
Name
,
rel
.
Version
);
err
!=
nil
{
if
_
,
err
:=
s
.
env
.
Releases
.
Delete
(
rel
.
Name
,
rel
.
Version
);
err
!=
nil
{
return
err
return
err
...
@@ -857,7 +854,7 @@ func (s *releaseServer) purgeReleases(rels ...*release.Release) error {
...
@@ -857,7 +854,7 @@ func (s *releaseServer) purgeReleases(rels ...*release.Release) error {
return
nil
return
nil
}
}
func
(
s
*
r
eleaseServer
)
UninstallRelease
(
c
ctx
.
Context
,
req
*
services
.
UninstallReleaseRequest
)
(
*
services
.
UninstallReleaseResponse
,
error
)
{
func
(
s
*
R
eleaseServer
)
UninstallRelease
(
c
ctx
.
Context
,
req
*
services
.
UninstallReleaseRequest
)
(
*
services
.
UninstallReleaseResponse
,
error
)
{
if
!
checkClientVersion
(
c
)
{
if
!
checkClientVersion
(
c
)
{
return
nil
,
errIncompatibleVersion
return
nil
,
errIncompatibleVersion
}
}
...
...
cmd
/tiller/release_server_test.go
→
pkg
/tiller/release_server_test.go
View file @
c0850efe
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
main
package
tiller
import
(
import
(
"errors"
"errors"
...
@@ -29,13 +29,13 @@ import (
...
@@ -29,13 +29,13 @@ import (
"golang.org/x/net/context"
"golang.org/x/net/context"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/metadata"
"k8s.io/helm/cmd/tiller/environment"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/tiller/environment"
)
)
const
notesText
=
"my notes here"
const
notesText
=
"my notes here"
...
@@ -70,8 +70,8 @@ data:
...
@@ -70,8 +70,8 @@ data:
name: value
name: value
`
`
func
rsFixture
()
*
r
eleaseServer
{
func
rsFixture
()
*
R
eleaseServer
{
return
&
r
eleaseServer
{
return
&
R
eleaseServer
{
env
:
mockEnvironment
(),
env
:
mockEnvironment
(),
}
}
}
}
...
...
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