-
Notifications
You must be signed in to change notification settings - Fork 787
/
quickstarts.go
47 lines (42 loc) · 1.26 KB
/
quickstarts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package kube
import (
"fmt"
"reflect"
v1 "github.com/jenkins-x/jx-api/pkg/apis/jenkins.io/v1"
"github.com/jenkins-x/jx-api/pkg/client/clientset/versioned"
"github.com/jenkins-x/jx/v2/pkg/gits"
)
var (
DefaultQuickstartLocations = []v1.QuickStartLocation{
{
GitURL: gits.GitHubURL,
GitKind: gits.KindGitHub,
Owner: "jenkins-x-quickstarts",
Includes: []string{"*"},
Excludes: []string{"WIP-*"},
},
}
)
// GetQuickstartLocations returns the current quickstart locations. If no locations are defined
// yet lets return the defaults
func GetQuickstartLocations(jxClient versioned.Interface, ns string) ([]v1.QuickStartLocation, error) {
var answer []v1.QuickStartLocation
env, err := EnsureDevEnvironmentSetup(jxClient, ns)
if err != nil {
return answer, err
}
if env == nil {
return answer, fmt.Errorf("No Development environment found for namespace %s", ns)
}
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
}