Merge pull request #1029 from ammeon/serve-repo-path

Serve charts from specified local repository path
pull/1031/head
Matt Butcher 9 years ago committed by GitHub
commit 24e891ee6d

@ -17,17 +17,19 @@ limitations under the License.
package main package main
import ( import (
"os"
"path/filepath"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/repo"
) )
var serveDesc = `This command starts a local chart repository server that serves the charts saved in your $HELM_HOME/local/ directory.` var serveDesc = `This command starts a local chart repository server that serves charts from a local directory.`
var repoPath string
//TODO: add repoPath flag to be passed in in case you want
// to serve charts from a different local dir
func init() { func init() {
serveCmd.Flags().StringVar(&repoPath, "repo-path", localRepoDirectory(), "The local directory path from which to serve charts.")
RootCommand.AddCommand(serveCmd) RootCommand.AddCommand(serveCmd)
} }
@ -35,9 +37,19 @@ 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: serve, RunE: serve,
} }
func serve(cmd *cobra.Command, args []string) { func serve(cmd *cobra.Command, args []string) error {
repo.StartLocalRepo(localRepoDirectory())
repoPath, err := filepath.Abs(repoPath)
if err != nil {
return err
}
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
return err
}
repo.StartLocalRepo(repoPath)
return nil
} }

Loading…
Cancel
Save