Add --url option to helm serve

This PR is to add --url flag for helm serve, so that
urls in index.yaml will be changed to the corresponding value.
pull/2002/head
Jian Qiu 8 years ago committed by Jian Qiu
parent f4b7eb5b01
commit 95cdc705af

@ -33,11 +33,12 @@ This command starts a local chart repository server that serves charts from a lo
The new server will provide HTTP access to a repository. By default, it will The new server will provide HTTP access to a repository. By default, it will
scan all of the charts in '$HELM_HOME/repository/local' and serve those over scan all of the charts in '$HELM_HOME/repository/local' and serve those over
the a local IPv4 TCP port (default '127.0.0.1:8879'). the local IPv4 TCP port (default '127.0.0.1:8879').
` `
type serveCmd struct { type serveCmd struct {
out io.Writer out io.Writer
url string
address string address string
repoPath string repoPath string
} }
@ -56,6 +57,7 @@ func newServeCmd(out io.Writer) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.StringVar(&srv.repoPath, "repo-path", helmpath.Home(homePath()).LocalRepository(), "local directory path from which to serve charts") f.StringVar(&srv.repoPath, "repo-path", helmpath.Home(homePath()).LocalRepository(), "local directory path from which to serve charts")
f.StringVar(&srv.address, "address", "127.0.0.1:8879", "address to listen on") f.StringVar(&srv.address, "address", "127.0.0.1:8879", "address to listen on")
f.StringVar(&srv.url, "url", "", "external URL of chart repository")
return cmd return cmd
} }
@ -70,7 +72,12 @@ func (s *serveCmd) run() error {
} }
fmt.Fprintln(s.out, "Regenerating index. This may take a moment.") fmt.Fprintln(s.out, "Regenerating index. This may take a moment.")
if err := index(repoPath, "http://"+s.address, ""); err != nil { if len(s.url) > 0 {
err = index(repoPath, s.url, "")
} else {
err = index(repoPath, "http://"+s.address, "")
}
if err != nil {
return err return err
} }

Loading…
Cancel
Save