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
39a9eab1
Commit
39a9eab1
authored
Apr 20, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(helm): comment + err cleanup on helm
parent
9e05956e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
15 deletions
+16
-15
init.go
cmd/helm/init.go
+3
-2
search.go
cmd/helm/search.go
+2
-2
local.go
pkg/repo/local.go
+11
-11
No files found.
cmd/helm/init.go
View file @
39a9eab1
...
@@ -97,7 +97,7 @@ func ensureHome(home string) error {
...
@@ -97,7 +97,7 @@ func ensureHome(home string) error {
repoPath
:=
repositoriesFile
(
home
)
repoPath
:=
repositoriesFile
(
home
)
if
fi
,
err
:=
os
.
Stat
(
repoPath
);
err
!=
nil
{
if
fi
,
err
:=
os
.
Stat
(
repoPath
);
err
!=
nil
{
fmt
.
Printf
(
"Creating %s
\n
"
,
repoPath
)
fmt
.
Printf
(
"Creating %s
\n
"
,
repoPath
)
if
err
:=
ioutil
.
WriteFile
(
repoPath
,
[]
byte
(
"local: localhost:8879/charts"
),
0644
);
err
!=
nil
{
if
err
:=
ioutil
.
WriteFile
(
repoPath
,
[]
byte
(
"local: localhost:8879/charts
\n
"
),
0644
);
err
!=
nil
{
return
err
return
err
}
}
}
else
if
fi
.
IsDir
()
{
}
else
if
fi
.
IsDir
()
{
...
@@ -112,7 +112,8 @@ func ensureHome(home string) error {
...
@@ -112,7 +112,8 @@ func ensureHome(home string) error {
return
err
return
err
}
}
os
.
Symlink
(
localCacheFile
,
CacheDirectory
(
home
)
+
"/local-cache.txt"
)
//TODO: take this out and replace with helm update functionality
os
.
Symlink
(
localCacheFile
,
CacheDirectory
(
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
)
}
}
...
...
cmd/helm/search.go
View file @
39a9eab1
...
@@ -18,7 +18,7 @@ func init() {
...
@@ -18,7 +18,7 @@ func init() {
var
searchCmd
=
&
cobra
.
Command
{
var
searchCmd
=
&
cobra
.
Command
{
Use
:
"search [CHART]"
,
Use
:
"search [CHART]"
,
Short
:
"Search for charts"
,
Short
:
"Search for charts"
,
Long
:
""
,
Long
:
""
,
//TODO: add search command description
RunE
:
Search
,
RunE
:
Search
,
}
}
...
@@ -51,7 +51,7 @@ func searchCacheForPattern(name string) ([]string, error) {
...
@@ -51,7 +51,7 @@ func searchCacheForPattern(name string) ([]string, error) {
for
_
,
f
:=
range
fileList
{
for
_
,
f
:=
range
fileList
{
cache
,
_
:=
repo
.
LoadCacheFile
(
f
)
cache
,
_
:=
repo
.
LoadCacheFile
(
f
)
repoName
:=
filepath
.
Base
(
strings
.
TrimRight
(
f
,
"-cache.txt"
))
repoName
:=
filepath
.
Base
(
strings
.
TrimRight
(
f
,
"-cache.txt"
))
for
k
,
_
:=
range
cache
.
Entries
{
for
k
:=
range
cache
.
Entries
{
if
strings
.
Contains
(
k
,
name
)
{
if
strings
.
Contains
(
k
,
name
)
{
matches
=
append
(
matches
,
repoName
+
"/"
+
k
)
matches
=
append
(
matches
,
repoName
+
"/"
+
k
)
}
}
...
...
pkg/repo/local.go
View file @
39a9eab1
...
@@ -18,18 +18,18 @@ type CacheFile struct {
...
@@ -18,18 +18,18 @@ type CacheFile struct {
}
}
type
ChartRef
struct
{
type
ChartRef
struct
{
Name
string
`yaml:name`
Name
string
Url
string
`yaml:url`
Url
string
}
}
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
http
.
HandleFunc
(
"/"
,
home
Handler
)
http
.
HandleFunc
(
"/"
,
root
Handler
)
http
.
HandleFunc
(
"/charts/"
,
indexHandler
)
http
.
HandleFunc
(
"/charts/"
,
indexHandler
)
http
.
ListenAndServe
(
":8879"
,
nil
)
http
.
ListenAndServe
(
":8879"
,
nil
)
}
}
func
home
Handler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
root
Handler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
fmt
.
Fprintf
(
w
,
"Welcome to the Kubernetes Package manager!
\n
Browse charts on localhost:8879/charts!"
)
fmt
.
Fprintf
(
w
,
"Welcome to the Kubernetes Package manager!
\n
Browse charts on localhost:8879/charts!"
)
}
}
func
indexHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
indexHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
@@ -56,7 +56,7 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error {
...
@@ -56,7 +56,7 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error {
}
}
err
=
ReindexCacheFile
(
ch
,
path
+
"/cache.yaml"
)
err
=
ReindexCacheFile
(
ch
,
path
+
"/cache.yaml"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
return
err
}
}
fmt
.
Printf
(
"Saved %s to $HELM_HOME/local"
,
name
)
fmt
.
Printf
(
"Saved %s to $HELM_HOME/local"
,
name
)
return
nil
return
nil
...
@@ -65,16 +65,13 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error {
...
@@ -65,16 +65,13 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error {
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
{
fmt
.
Println
(
"read file err"
)
fmt
.
Printf
(
"err, %s"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
//TODO: change variable name - y is not helpful :P
var
y
CacheFile
var
y
CacheFile
err
=
yaml
.
Unmarshal
(
b
,
&
y
)
err
=
yaml
.
Unmarshal
(
b
,
&
y
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"error unmarshaling"
)
fmt
.
Println
(
"err, %s"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
return
&
y
,
nil
return
&
y
,
nil
...
@@ -82,9 +79,12 @@ func LoadCacheFile(path string) (*CacheFile, error) {
...
@@ -82,9 +79,12 @@ func LoadCacheFile(path string) (*CacheFile, error) {
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
,
_
:=
LoadCacheFile
(
path
)
//TODO: handle err later
y
,
err
:=
LoadCacheFile
(
path
)
if
err
!=
nil
{
return
err
}
found
:=
false
found
:=
false
for
k
,
_
:=
range
y
.
Entries
{
for
k
:=
range
y
.
Entries
{
if
k
==
name
{
if
k
==
name
{
found
=
true
found
=
true
break
break
...
...
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