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
ae720981
Commit
ae720981
authored
Apr 22, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(repo): fix style errors in cmd/helm & pkg/repo
parent
39a9eab1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
24 deletions
+32
-24
fetch.go
cmd/helm/fetch.go
+2
-2
init.go
cmd/helm/init.go
+6
-6
init_test.go
cmd/helm/init_test.go
+1
-1
package.go
cmd/helm/package.go
+1
-1
search.go
cmd/helm/search.go
+3
-3
serve.go
cmd/helm/serve.go
+3
-3
local.go
pkg/repo/local.go
+16
-8
No files found.
cmd/helm/fetch.go
View file @
ae720981
...
@@ -17,10 +17,10 @@ var fetchCmd = &cobra.Command{
...
@@ -17,10 +17,10 @@ var fetchCmd = &cobra.Command{
Use
:
"fetch"
,
Use
:
"fetch"
,
Short
:
"Download a chart from a repository and unpack it in local directory."
,
Short
:
"Download a chart from a repository and unpack it in local directory."
,
Long
:
""
,
Long
:
""
,
RunE
:
F
etch
,
RunE
:
f
etch
,
}
}
func
F
etch
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
f
etch
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
// parse args
// parse args
// get download url
// get download url
// call download url
// call download url
...
...
cmd/helm/init.go
View file @
ae720981
...
@@ -81,7 +81,7 @@ func buildKubectlRunner(kubectlPath string) kubectl.Runner {
...
@@ -81,7 +81,7 @@ func buildKubectlRunner(kubectlPath string) kubectl.Runner {
//
//
// If $HELM_HOME does not exist, this function will create it.
// If $HELM_HOME does not exist, this function will create it.
func
ensureHome
(
home
string
)
error
{
func
ensureHome
(
home
string
)
error
{
configDirectories
:=
[]
string
{
home
,
CacheDirectory
(
home
),
L
ocalDirectory
(
home
)}
configDirectories
:=
[]
string
{
home
,
cacheDirectory
(
home
),
l
ocalDirectory
(
home
)}
for
_
,
p
:=
range
configDirectories
{
for
_
,
p
:=
range
configDirectories
{
if
fi
,
err
:=
os
.
Stat
(
p
);
err
!=
nil
{
if
fi
,
err
:=
os
.
Stat
(
p
);
err
!=
nil
{
...
@@ -104,7 +104,7 @@ func ensureHome(home string) error {
...
@@ -104,7 +104,7 @@ func ensureHome(home string) error {
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
repoPath
)
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
repoPath
)
}
}
localCacheFile
:=
L
ocalDirCacheFile
(
home
)
localCacheFile
:=
l
ocalDirCacheFile
(
home
)
if
fi
,
err
:=
os
.
Stat
(
localCacheFile
);
err
!=
nil
{
if
fi
,
err
:=
os
.
Stat
(
localCacheFile
);
err
!=
nil
{
fmt
.
Printf
(
"Creating %s
\n
"
,
localCacheFile
)
fmt
.
Printf
(
"Creating %s
\n
"
,
localCacheFile
)
_
,
err
:=
os
.
Create
(
localCacheFile
)
_
,
err
:=
os
.
Create
(
localCacheFile
)
...
@@ -113,9 +113,9 @@ func ensureHome(home string) error {
...
@@ -113,9 +113,9 @@ func ensureHome(home string) error {
}
}
//TODO: take this out and replace with helm update functionality
//TODO: take this out and replace with helm update functionality
os
.
Symlink
(
localCacheFile
,
C
acheDirectory
(
home
)
+
"/local-cache.yaml"
)
os
.
Symlink
(
localCacheFile
,
c
acheDirectory
(
home
)
+
"/local-cache.yaml"
)
}
else
if
fi
.
IsDir
()
{
}
else
if
fi
.
IsDir
()
{
return
fmt
.
Errorf
(
"%s must be a file, not a directory
.
"
,
repoPath
)
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
repoPath
)
}
}
return
nil
return
nil
}
}
...
@@ -128,10 +128,10 @@ func repositoriesFile(home string) string {
...
@@ -128,10 +128,10 @@ func repositoriesFile(home string) string {
return
filepath
.
Join
(
home
,
repositoriesPath
)
return
filepath
.
Join
(
home
,
repositoriesPath
)
}
}
func
L
ocalDirectory
(
home
string
)
string
{
func
l
ocalDirectory
(
home
string
)
string
{
return
filepath
.
Join
(
home
,
localPath
)
return
filepath
.
Join
(
home
,
localPath
)
}
}
func
L
ocalDirCacheFile
(
home
string
)
string
{
func
l
ocalDirCacheFile
(
home
string
)
string
{
return
filepath
.
Join
(
home
,
localCacheFilePath
)
return
filepath
.
Join
(
home
,
localCacheFilePath
)
}
}
cmd/helm/init_test.go
View file @
ae720981
...
@@ -12,7 +12,7 @@ func TestEnsureHome(t *testing.T) {
...
@@ -12,7 +12,7 @@ func TestEnsureHome(t *testing.T) {
t
.
Errorf
(
"%s"
,
err
)
t
.
Errorf
(
"%s"
,
err
)
}
}
dirs
:=
[]
string
{
home
,
CacheDirectory
(
home
),
L
ocalDirectory
(
home
)}
dirs
:=
[]
string
{
home
,
cacheDirectory
(
home
),
l
ocalDirectory
(
home
)}
for
_
,
dir
:=
range
dirs
{
for
_
,
dir
:=
range
dirs
{
if
fi
,
err
:=
os
.
Stat
(
dir
);
err
!=
nil
{
if
fi
,
err
:=
os
.
Stat
(
dir
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
t
.
Errorf
(
"%s"
,
err
)
...
...
cmd/helm/package.go
View file @
ae720981
...
@@ -56,7 +56,7 @@ func runPackage(cmd *cobra.Command, args []string) error {
...
@@ -56,7 +56,7 @@ func runPackage(cmd *cobra.Command, args []string) error {
// Save to $HELM_HOME/local directory.
// Save to $HELM_HOME/local directory.
if
save
{
if
save
{
if
err
:=
repo
.
AddChartToLocalRepo
(
ch
,
L
ocalDirectory
(
os
.
ExpandEnv
(
helmHome
)));
err
!=
nil
{
if
err
:=
repo
.
AddChartToLocalRepo
(
ch
,
l
ocalDirectory
(
os
.
ExpandEnv
(
helmHome
)));
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
cmd/helm/search.go
View file @
ae720981
...
@@ -19,10 +19,10 @@ var searchCmd = &cobra.Command{
...
@@ -19,10 +19,10 @@ var searchCmd = &cobra.Command{
Use
:
"search [CHART]"
,
Use
:
"search [CHART]"
,
Short
:
"Search for charts"
,
Short
:
"Search for charts"
,
Long
:
""
,
//TODO: add search command description
Long
:
""
,
//TODO: add search command description
RunE
:
S
earch
,
RunE
:
s
earch
,
}
}
func
S
earch
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
s
earch
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
return
errors
.
New
(
"This command needs at least one argument"
)
return
errors
.
New
(
"This command needs at least one argument"
)
}
}
...
@@ -39,7 +39,7 @@ func Search(cmd *cobra.Command, args []string) error {
...
@@ -39,7 +39,7 @@ func Search(cmd *cobra.Command, args []string) error {
}
}
func
searchCacheForPattern
(
name
string
)
([]
string
,
error
)
{
func
searchCacheForPattern
(
name
string
)
([]
string
,
error
)
{
dir
:=
C
acheDirectory
(
os
.
ExpandEnv
(
helmHome
))
dir
:=
c
acheDirectory
(
os
.
ExpandEnv
(
helmHome
))
fileList
:=
[]
string
{}
fileList
:=
[]
string
{}
filepath
.
Walk
(
dir
,
func
(
path
string
,
f
os
.
FileInfo
,
err
error
)
error
{
filepath
.
Walk
(
dir
,
func
(
path
string
,
f
os
.
FileInfo
,
err
error
)
error
{
if
!
f
.
IsDir
()
{
if
!
f
.
IsDir
()
{
...
...
cmd/helm/serve.go
View file @
ae720981
...
@@ -20,9 +20,9 @@ var serveCmd = &cobra.Command{
...
@@ -20,9 +20,9 @@ var serveCmd = &cobra.Command{
Use
:
"serve"
,
Use
:
"serve"
,
Short
:
"Start a local http web server"
,
Short
:
"Start a local http web server"
,
Long
:
serveDesc
,
Long
:
serveDesc
,
Run
:
ServeLocal
,
Run
:
serve
,
}
}
func
ServeLocal
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
serve
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
repo
.
StartLocalRepo
(
L
ocalDirectory
(
os
.
ExpandEnv
(
helmHome
)))
repo
.
StartLocalRepo
(
l
ocalDirectory
(
os
.
ExpandEnv
(
helmHome
)))
}
}
pkg/repo/local.go
View file @
ae720981
...
@@ -13,15 +13,18 @@ import (
...
@@ -13,15 +13,18 @@ import (
var
localRepoPath
string
var
localRepoPath
string
// CacheFile represents the cache file in a chart repository
type
CacheFile
struct
{
type
CacheFile
struct
{
Entries
map
[
string
]
*
ChartRef
Entries
map
[
string
]
*
ChartRef
}
}
// ChartRef represents a chart entry in the CacheFile
type
ChartRef
struct
{
type
ChartRef
struct
{
Name
string
Name
string
U
rl
string
U
RL
string
}
}
// StartLocalRepo starts a web server and serves files from the given path
func
StartLocalRepo
(
path
string
)
{
func
StartLocalRepo
(
path
string
)
{
fmt
.
Println
(
"Now serving you on localhost:8879..."
)
fmt
.
Println
(
"Now serving you on localhost:8879..."
)
localRepoPath
=
path
localRepoPath
=
path
...
@@ -49,6 +52,7 @@ func serveFile(w http.ResponseWriter, r *http.Request, file string) {
...
@@ -49,6 +52,7 @@ func serveFile(w http.ResponseWriter, r *http.Request, file string) {
http
.
ServeFile
(
w
,
r
,
filepath
.
Join
(
localRepoPath
,
file
))
http
.
ServeFile
(
w
,
r
,
filepath
.
Join
(
localRepoPath
,
file
))
}
}
// AddChartToLocalRepo saves a chart in the given path and then reindexes the cache file
func
AddChartToLocalRepo
(
ch
*
chart
.
Chart
,
path
string
)
error
{
func
AddChartToLocalRepo
(
ch
*
chart
.
Chart
,
path
string
)
error
{
name
,
err
:=
chart
.
Save
(
ch
,
path
)
name
,
err
:=
chart
.
Save
(
ch
,
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -62,6 +66,7 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error {
...
@@ -62,6 +66,7 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error {
return
nil
return
nil
}
}
// LoadCacheFile takes a file at the given path and returns a CacheFile object
func
LoadCacheFile
(
path
string
)
(
*
CacheFile
,
error
)
{
func
LoadCacheFile
(
path
string
)
(
*
CacheFile
,
error
)
{
b
,
err
:=
ioutil
.
ReadFile
(
path
)
b
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -77,6 +82,7 @@ func LoadCacheFile(path string) (*CacheFile, error) {
...
@@ -77,6 +82,7 @@ func LoadCacheFile(path string) (*CacheFile, error) {
return
&
y
,
nil
return
&
y
,
nil
}
}
// ReindexCacheFile adds an entry to the cache file at the given path
func
ReindexCacheFile
(
ch
*
chart
.
Chart
,
path
string
)
error
{
func
ReindexCacheFile
(
ch
*
chart
.
Chart
,
path
string
)
error
{
name
:=
ch
.
Chartfile
()
.
Name
+
"-"
+
ch
.
Chartfile
()
.
Version
name
:=
ch
.
Chartfile
()
.
Name
+
"-"
+
ch
.
Chartfile
()
.
Version
y
,
err
:=
LoadCacheFile
(
path
)
y
,
err
:=
LoadCacheFile
(
path
)
...
@@ -93,7 +99,7 @@ func ReindexCacheFile(ch *chart.Chart, path string) error {
...
@@ -93,7 +99,7 @@ func ReindexCacheFile(ch *chart.Chart, path string) error {
if
!
found
{
if
!
found
{
url
:=
"localhost:8879/charts/"
+
name
+
".tgz"
url
:=
"localhost:8879/charts/"
+
name
+
".tgz"
out
,
err
:=
y
.
I
nsertChartEntry
(
name
,
url
)
out
,
err
:=
y
.
i
nsertChartEntry
(
name
,
url
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -102,6 +108,8 @@ func ReindexCacheFile(ch *chart.Chart, path string) error {
...
@@ -102,6 +108,8 @@ func ReindexCacheFile(ch *chart.Chart, path string) error {
}
}
return
nil
return
nil
}
}
// UnmarshalYAML unmarshals the cache file
func
(
c
*
CacheFile
)
UnmarshalYAML
(
unmarshal
func
(
interface
{})
error
)
error
{
func
(
c
*
CacheFile
)
UnmarshalYAML
(
unmarshal
func
(
interface
{})
error
)
error
{
var
refs
map
[
string
]
*
ChartRef
var
refs
map
[
string
]
*
ChartRef
if
err
:=
unmarshal
(
&
refs
);
err
!=
nil
{
if
err
:=
unmarshal
(
&
refs
);
err
!=
nil
{
...
@@ -113,13 +121,13 @@ func (c *CacheFile) UnmarshalYAML(unmarshal func(interface{}) error) error {
...
@@ -113,13 +121,13 @@ func (c *CacheFile) UnmarshalYAML(unmarshal func(interface{}) error) error {
return
nil
return
nil
}
}
func
(
c
ache
*
CacheFile
)
I
nsertChartEntry
(
name
string
,
url
string
)
([]
byte
,
error
)
{
func
(
c
*
CacheFile
)
i
nsertChartEntry
(
name
string
,
url
string
)
([]
byte
,
error
)
{
if
c
ache
.
Entries
==
nil
{
if
c
.
Entries
==
nil
{
c
ache
.
Entries
=
make
(
map
[
string
]
*
ChartRef
)
c
.
Entries
=
make
(
map
[
string
]
*
ChartRef
)
}
}
entry
:=
ChartRef
{
Name
:
name
,
U
rl
:
url
}
entry
:=
ChartRef
{
Name
:
name
,
U
RL
:
url
}
c
ache
.
Entries
[
name
]
=
&
entry
c
.
Entries
[
name
]
=
&
entry
out
,
err
:=
yaml
.
Marshal
(
&
c
ache
.
Entries
)
out
,
err
:=
yaml
.
Marshal
(
&
c
.
Entries
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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