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
361fd36f
Commit
361fd36f
authored
May 10, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #658 from michelleN/helm-update
feat(helm): add helm update command
parents
33962aba
bf4b15c0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
2 deletions
+105
-2
repo.go
cmd/helm/repo.go
+8
-2
update.go
cmd/helm/update.go
+97
-0
No files found.
cmd/helm/repo.go
View file @
361fd36f
package
main
import
(
"errors"
"fmt"
"io/ioutil"
...
...
@@ -44,11 +45,16 @@ func runRepoAdd(cmd *cobra.Command, args []string) error {
if
err
:=
checkArgsLength
(
2
,
len
(
args
),
"name for the chart repository"
,
"the url of the chart repository"
);
err
!=
nil
{
return
err
}
name
,
url
:=
args
[
0
],
args
[
1
]
err
:=
insertRepoLine
(
args
[
0
],
args
[
1
])
if
err
!=
nil
{
if
err
:=
downloadCacheFile
(
name
,
url
);
err
!=
nil
{
return
errors
.
New
(
"Oops! Looks like "
+
url
+
" is not a valid chart repository or cannot be reached
\n
"
)
}
if
err
:=
insertRepoLine
(
name
,
url
);
err
!=
nil
{
return
err
}
fmt
.
Println
(
args
[
0
]
+
" has been added to your repositories"
)
return
nil
}
...
...
cmd/helm/update.go
0 → 100644
View file @
361fd36f
package
main
import
(
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
"github.com/kubernetes/helm/pkg/repo"
)
var
verboseUpdate
bool
var
updateCommand
=
&
cobra
.
Command
{
Use
:
"update"
,
Short
:
"Update information on available charts in the chart repositories."
,
RunE
:
runUpdate
,
}
func
init
()
{
updateCommand
.
Flags
()
.
BoolVar
(
&
verboseUpdate
,
"verbose"
,
false
,
"verbose error messages"
)
RootCommand
.
AddCommand
(
updateCommand
)
}
func
runUpdate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
f
,
err
:=
repo
.
LoadRepositoriesFile
(
repositoriesFile
())
if
err
!=
nil
{
return
err
}
updateCharts
(
f
.
Repositories
,
verboseUpdate
)
return
nil
}
func
updateCharts
(
repos
map
[
string
]
string
,
verbose
bool
)
{
fmt
.
Println
(
"Hang tight while we grab the latest from your chart repositories..."
)
var
wg
sync
.
WaitGroup
for
name
,
url
:=
range
repos
{
wg
.
Add
(
1
)
go
func
(
n
,
u
string
)
{
defer
wg
.
Done
()
err
:=
downloadCacheFile
(
n
,
u
)
if
err
!=
nil
{
updateErr
:=
"...Unable to get an update from the "
+
n
+
" chart repository"
if
verbose
{
updateErr
=
updateErr
+
": "
+
err
.
Error
()
}
fmt
.
Println
(
updateErr
)
}
else
{
fmt
.
Println
(
"...Successfully got an update from the "
+
n
+
" chart repository"
)
}
}(
name
,
url
)
}
wg
.
Wait
()
fmt
.
Println
(
"Update Complete. Happy Helming!"
)
}
func
downloadCacheFile
(
name
,
url
string
)
error
{
var
cacheURL
string
cacheURL
=
strings
.
TrimSuffix
(
url
,
"/"
)
+
"/cache.yaml"
resp
,
err
:=
http
.
Get
(
cacheURL
)
if
err
!=
nil
{
return
err
}
defer
resp
.
Body
.
Close
()
var
cacheFile
*
os
.
File
var
r
repo
.
RepoFile
b
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
err
}
if
err
:=
yaml
.
Unmarshal
(
b
,
&
r
);
err
!=
nil
{
return
err
}
cacheFile
,
err
=
os
.
Create
(
cacheDirectory
(
name
+
"-cache.yaml"
))
if
err
!=
nil
{
return
err
}
if
_
,
err
:=
io
.
Copy
(
cacheFile
,
resp
.
Body
);
err
!=
nil
{
return
err
}
return
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