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
77171c01
Commit
77171c01
authored
Aug 22, 2016
by
Matt Butcher
Committed by
GitHub
Aug 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1080 from technosophos/feat/1071-limit-rel-name-len
feat(tiller): limit the max len of Release.Name
parents
0e212b95
cafec120
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
release_server.go
cmd/tiller/release_server.go
+16
-0
release_server_test.go
cmd/tiller/release_server_test.go
+1
-0
No files found.
cmd/tiller/release_server.go
View file @
77171c01
...
...
@@ -39,6 +39,13 @@ import (
var
srv
*
releaseServer
// releaseNameMaxLen is the maximum length of a release name.
//
// This is designed to accomodate the usage of release name in the 'name:'
// field of Kubernetes resources. Many of those fields are limited to 24
// characters in length. See https://github.com/kubernetes/helm/issues/1071
const
releaseNameMaxLen
=
14
func
init
()
{
srv
=
&
releaseServer
{
env
:
env
,
...
...
@@ -290,6 +297,11 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
// is granted. If reuse is true and a deleted release with that name exists,
// we re-grant it. Otherwise, an error is returned.
if
start
!=
""
{
if
len
(
start
)
>
releaseNameMaxLen
{
return
""
,
fmt
.
Errorf
(
"release name %q exceeds max length of %d"
,
start
,
releaseNameMaxLen
)
}
if
rel
,
err
:=
s
.
env
.
Releases
.
Get
(
start
);
err
==
driver
.
ErrReleaseNotFound
{
return
start
,
nil
}
else
if
st
:=
rel
.
Info
.
Status
.
Code
;
reuse
&&
(
st
==
release
.
Status_DELETED
||
st
==
release
.
Status_FAILED
)
{
...
...
@@ -307,6 +319,10 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
for
i
:=
0
;
i
<
maxTries
;
i
++
{
namer
:=
moniker
.
New
()
name
:=
namer
.
NameSep
(
"-"
)
if
len
(
name
)
>
releaseNameMaxLen
{
log
.
Printf
(
"info: Candidate name %q exceeds maximum length %d. Skipping."
,
name
,
releaseNameMaxLen
)
continue
}
if
_
,
err
:=
s
.
env
.
Releases
.
Get
(
name
);
err
==
driver
.
ErrReleaseNotFound
{
return
name
,
nil
}
...
...
cmd/tiller/release_server_test.go
View file @
77171c01
...
...
@@ -130,6 +130,7 @@ func TestUniqName(t *testing.T) {
{
"angry-panda"
,
""
,
false
,
true
},
{
"happy-panda"
,
""
,
false
,
true
},
{
"happy-panda"
,
"happy-panda"
,
true
,
false
},
{
"hungry-hungry-hippos"
,
""
,
true
,
true
},
// Exceeds max name length
}
for
_
,
tt
:=
range
tests
{
...
...
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