diff --git a/pkg/cmd/opts/quickstarts.go b/pkg/cmd/opts/quickstarts.go index c6d37611be..a1b0e7ae28 100644 --- a/pkg/cmd/opts/quickstarts.go +++ b/pkg/cmd/opts/quickstarts.go @@ -64,7 +64,18 @@ func (o *CommonOptions) LoadQuickStartsFromLocations(locations []v1.QuickStartLo if kind == "" { kind = gits.KindGitHub } - gitProvider, err := o.GitProviderForGitServerURL(gitURL, kind, "") + + var gitProvider gits.GitProvider + var err error + + // If this is a default quickstart location but there's no github.com credentials, fall back to anonymous + server := config.GetOrCreateServer(gitURL) + userAuth := config.CurrentUser(server, o.InCluster()) + if kube.IsDefaultQuickstartLocation(location) && (userAuth == nil || userAuth.IsInvalid()) { + gitProvider, err = gits.NewAnonymousGitHubProvider(server, nil) + } else { + gitProvider, err = o.GitProviderForGitServerURL(gitURL, kind, "") + } if err != nil { return model, err } diff --git a/pkg/kube/quickstarts.go b/pkg/kube/quickstarts.go index 25d4b82bcc..0cb8fe5206 100644 --- a/pkg/kube/quickstarts.go +++ b/pkg/kube/quickstarts.go @@ -2,6 +2,7 @@ package kube import ( "fmt" + "reflect" v1 "github.com/jenkins-x/jx/pkg/apis/jenkins.io/v1" "github.com/jenkins-x/jx/pkg/client/clientset/versioned" @@ -34,3 +35,13 @@ func GetQuickstartLocations(jxClient versioned.Interface, ns string) ([]v1.Quick answer = env.Spec.TeamSettings.QuickstartLocations return answer, nil } + +// IsDefaultQuickstartLocation checks whether the given quickstart location is a default one, and if so returns true +func IsDefaultQuickstartLocation(location v1.QuickStartLocation) bool { + for _, l := range DefaultQuickstartLocations { + if reflect.DeepEqual(l, location) { + return true + } + } + return false +}