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
45f9d32f
Commit
45f9d32f
authored
Feb 03, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LoadData() for server-side reading.
parent
476e71f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
chart.go
chart/chart.go
+24
-0
chart_test.go
chart/chart_test.go
+22
-1
No files found.
chart/chart.go
View file @
45f9d32f
...
...
@@ -18,6 +18,7 @@ package chart
import
(
"archive/tar"
"bytes"
"compress/gzip"
"errors"
"fmt"
...
...
@@ -240,6 +241,29 @@ func LoadDir(chart string) (*Chart, error) {
},
nil
}
// LoadData loads a chart from data, where data is a []byte containing a gzipped tar file.
func
LoadData
(
data
[]
byte
)
(
*
Chart
,
error
)
{
b
:=
bytes
.
NewBuffer
(
data
)
unzipped
,
err
:=
gzip
.
NewReader
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
defer
unzipped
.
Close
()
untarred
:=
tar
.
NewReader
(
unzipped
)
c
,
err
:=
loadTar
(
untarred
)
if
err
!=
nil
{
return
nil
,
err
}
cf
,
err
:=
LoadChartfile
(
filepath
.
Join
(
c
.
tmpDir
,
ChartfileName
))
if
err
!=
nil
{
return
nil
,
err
}
c
.
chartyaml
=
cf
return
&
Chart
{
loader
:
c
},
nil
}
// Load loads a chart from a chart archive.
//
// A chart archive is a gzipped tar archive that follows the Chart format
...
...
chart/chart_test.go
View file @
45f9d32f
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
chart
import
(
"io/ioutil"
"path/filepath"
"testing"
...
...
@@ -57,7 +58,6 @@ func TestLoadDir(t *testing.T) {
}
func
TestLoad
(
t
*
testing
.
T
)
{
c
,
err
:=
Load
(
testarchive
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to load chart: %s"
,
err
)
...
...
@@ -75,6 +75,27 @@ func TestLoad(t *testing.T) {
}
}
func
TestLoadData
(
t
*
testing
.
T
)
{
data
,
err
:=
ioutil
.
ReadFile
(
testarchive
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to read testarchive file: %s"
,
err
)
return
}
c
,
err
:=
LoadData
(
data
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to load chart: %s"
,
err
)
return
}
if
c
.
Chartfile
()
==
nil
{
t
.
Error
(
"No chartfile was loaded."
)
return
}
if
c
.
Chartfile
()
.
Name
!=
"frobnitz"
{
t
.
Errorf
(
"Expected name to be frobnitz, got %q"
,
c
.
Chartfile
()
.
Name
)
}
}
func
TestLoadIll
(
t
*
testing
.
T
)
{
c
,
err
:=
Load
(
testill
)
if
err
!=
nil
{
...
...
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