-
Notifications
You must be signed in to change notification settings - Fork 66
/
catalogsource.go
41 lines (36 loc) · 957 Bytes
/
catalogsource.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
package model
import (
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type CatalogSource struct {
metav1.TypeMeta `json:",inline"`
ObjectMeta *metav1.ObjectMeta `json:"metadata,omitempty"`
Spec CatalogSourceSpec `json:"spec,omitempty"`
}
type CatalogSourceSpec struct {
SourceType string `json:"sourceType"`
Image string `json:"image"`
DisplayName string `json:"displayName"`
Publisher string `json:"publisher"`
}
func NewCatalogSource(imageURL string) CatalogSource {
name := strings.Split(imageURL, ":")[1]
name = strings.ToLower(name)
return CatalogSource{
TypeMeta: metav1.TypeMeta{
APIVersion: "operators.coreos.com/v1alpha1",
Kind: "CatalogSource",
},
ObjectMeta: &metav1.ObjectMeta{
Name: name,
Namespace: "openshift-marketplace",
},
Spec: CatalogSourceSpec{
SourceType: "grpc",
Image: imageURL,
DisplayName: name,
Publisher: name,
},
}
}