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
7800a3c8
Commit
7800a3c8
authored
Aug 03, 2016
by
Matt Butcher
Committed by
GitHub
Aug 03, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1021 from technosophos/ref/1020-change-getstring-get
ref(templates): change GetString to Get
parents
2521ce7b
b7945d05
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
10 deletions
+15
-10
files.go
pkg/chartutil/files.go
+12
-7
files_test.go
pkg/chartutil/files_test.go
+2
-2
engine_test.go
pkg/engine/engine_test.go
+1
-1
No files found.
pkg/chartutil/files.go
View file @
7800a3c8
...
...
@@ -32,11 +32,14 @@ func NewFiles(from []*any.Any) Files {
return
files
}
// Get a file by path.
// GetBytes gets a file by path.
//
// The returned data is raw. In a template context, this is identical to calling
// {{index .Files $path}}.
//
// This is intended to be accessed from within a template, so a missed key returns
// an empty []byte.
func
(
f
Files
)
Get
(
name
string
)
[]
byte
{
func
(
f
Files
)
Get
Bytes
(
name
string
)
[]
byte
{
v
,
ok
:=
f
[
name
]
if
!
ok
{
return
[]
byte
{}
...
...
@@ -44,10 +47,12 @@ func (f Files) Get(name string) []byte {
return
v
}
// GetString returns a string representation of the given file.
// Get returns a string representation of the given file.
//
// Fetch the contents of a file as a string. It is designed to be called in a
// template.
//
// This is a convenience for the otherwise cumbersome template logic
// for '{{.Files.Get "foo" | printf "%s"}}'.
func
(
f
Files
)
GetString
(
name
string
)
string
{
return
string
(
f
.
Get
(
name
))
// {{.Files.Get "foo"}}
func
(
f
Files
)
Get
(
name
string
)
string
{
return
string
(
f
.
GetBytes
(
name
))
}
pkg/chartutil/files_test.go
View file @
7800a3c8
...
...
@@ -43,10 +43,10 @@ func TestNewFiles(t *testing.T) {
}
for
i
,
f
:=
range
cases
{
if
got
:=
string
(
files
.
Get
(
f
.
path
));
got
!=
f
.
data
{
if
got
:=
string
(
files
.
Get
Bytes
(
f
.
path
));
got
!=
f
.
data
{
t
.
Errorf
(
"%d: expected %q, got %q"
,
i
,
f
.
data
,
got
)
}
if
got
:=
files
.
Get
String
(
f
.
path
);
got
!=
f
.
data
{
if
got
:=
files
.
Get
(
f
.
path
);
got
!=
f
.
data
{
t
.
Errorf
(
"%d: expected %q, got %q"
,
i
,
f
.
data
,
got
)
}
}
...
...
pkg/engine/engine_test.go
View file @
7800a3c8
...
...
@@ -312,7 +312,7 @@ func TestRenderBuiltinValues(t *testing.T) {
Metadata
:
&
chart
.
Metadata
{
Name
:
"Latium"
},
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"Lavinia"
,
Data
:
[]
byte
(
`{{.Template.Name}}{{.Chart.Name}}{{.Release.Name}}`
)},
{
Name
:
"From"
,
Data
:
[]
byte
(
`{{.Files.author | printf "%s"}} {{.Files.Get
String
"book/title.txt"}}`
)},
{
Name
:
"From"
,
Data
:
[]
byte
(
`{{.Files.author | printf "%s"}} {{.Files.Get "book/title.txt"}}`
)},
},
Values
:
&
chart
.
Config
{
Raw
:
``
},
Dependencies
:
[]
*
chart
.
Chart
{},
...
...
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