Skip to content
Snippets Groups Projects
Commit 2575c387 authored by Jessica Yuen's avatar Jessica Yuen
Browse files

pkg install: Use 'master' as refSpec where version isn't provided

Currently, if a version is not provided to the following `pkg install`
command

`../ks pkg install incubator/redis`

, the following error will occur:

`ERROR GET
https://api.github.com/repos/ksonnet/parts/commits/incubator/redis

: 404
Not Found []`

This commit will pull in the latest package from master where the
version is not specified.

Also set the default repository ref to 'master' instead of 'test-reg'.

Signed-off-by: default avatarJessica Yuen <im.jessicayuen@gmail.com>
parent 23e984e8
No related branches found
No related tags found
No related merge requests found
......@@ -249,7 +249,10 @@ func parseDepSpec(cmd *cobra.Command, spec string) (registry, libID, name, versi
if len(split) > 2 {
return "", "", "", "", fmt.Errorf("Symbol '@' is only allowed once, at the end of the argument of the form <registry>/<library>@<version>")
}
version = split[len(split)-1]
version = ""
if len(split) == 2 {
version = split[1]
}
name, err = cmd.Flags().GetString(flagName)
if err != nil {
......
......@@ -96,7 +96,7 @@ func Init(name string, rootPath AbsPath, spec ClusterSpec, serverURI, namespace
// directory tree, in case the network call fails.
const (
defaultIncubatorRegName = "incubator"
defaultIncubatorURI = "github.com/ksonnet/parts/tree/test-reg/" + defaultIncubatorRegName
defaultIncubatorURI = "github.com/ksonnet/parts/tree/master/" + defaultIncubatorRegName
)
gh, err := makeGitHubRegistryManager(&app.RegistryRefSpec{
......
......@@ -152,10 +152,17 @@ func (gh *gitHubRegistryManager) ResolveLibrarySpec(libID, libRefSpec string) (*
}
func (gh *gitHubRegistryManager) ResolveLibrary(libID, libAlias, libRefSpec string, onFile registry.ResolveFile, onDir registry.ResolveDirectory) (*parts.Spec, *app.LibraryRefSpec, error) {
const (
defaultRefSpec = "master"
)
client := github.NewClient(nil)
// Resolve `version` (a git refspec) to a specific SHA.
ctx := context.Background()
if len(libRefSpec) == 0 {
libRefSpec = defaultRefSpec
}
resolvedSHA, _, err := client.Repositories.GetCommitSHA1(ctx, gh.org, gh.repo, libRefSpec, "")
if err != nil {
return nil, nil, err
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment