devfile 0.0.5.pre.alpha1-arm64-darwin → 0.0.11.pre.alpha1-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/devfile +0 -0
- data/ext/devfile.go +27 -14
- data/ext/main.go +57 -56
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022c2013340f8ac58d39c78763e2820e5ecdbde4b4bfad366756a4c018ad610c
|
4
|
+
data.tar.gz: f3f50f92496f1361859f2140f264fc17817aa4f2d80c7608f12270a84a869c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78758a78eb281a2ed9e65230425a33fb43b1b0da61419351e73efe154a47aee552dee439d9b0ad45f6fb307bdb5f35dbf435925c3ac6add0f35534b25ba1c1a9
|
7
|
+
data.tar.gz: 06e0da12b3a91d20e53cfcc1d500cdc03c73e8121047b35af1ce5ca3d7e8ca62b72785c5f37ead01eadd181ad8d7078297744525c77b0dafae2abfea654884f3
|
data/bin/devfile
CHANGED
Binary file
|
data/ext/devfile.go
CHANGED
@@ -9,6 +9,8 @@ import (
|
|
9
9
|
"github.com/devfile/library/v2/pkg/devfile/generator"
|
10
10
|
"github.com/devfile/library/v2/pkg/devfile/parser"
|
11
11
|
"github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common"
|
12
|
+
appsv1 "k8s.io/api/apps/v1"
|
13
|
+
corev1 "k8s.io/api/core/v1"
|
12
14
|
networkingv1 "k8s.io/api/networking/v1"
|
13
15
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
14
16
|
"k8s.io/apimachinery/pkg/runtime"
|
@@ -20,7 +22,7 @@ type Devfile struct {
|
|
20
22
|
devfileObj parser.DevfileObj
|
21
23
|
}
|
22
24
|
|
23
|
-
func (d Devfile) getDeployment(name, namespace string, labels, annotations map[string]string, replicas int) (
|
25
|
+
func (d Devfile) getDeployment(name, namespace string, labels, annotations map[string]string, replicas int) (*appsv1.Deployment, error) {
|
24
26
|
containers, err := generator.GetContainers(d.devfileObj, common.DevfileOptions{})
|
25
27
|
if err != nil {
|
26
28
|
return nil, err
|
@@ -52,7 +54,7 @@ func (d Devfile) getDeployment(name, namespace string, labels, annotations map[s
|
|
52
54
|
return deployment, err
|
53
55
|
}
|
54
56
|
|
55
|
-
func (d Devfile) getService(name, namespace string, labels, annotations map[string]string) (
|
57
|
+
func (d Devfile) getService(name, namespace string, labels, annotations map[string]string) (*corev1.Service, error) {
|
56
58
|
service, err := generator.GetService(d.devfileObj, generator.ServiceParams{
|
57
59
|
TypeMeta: generator.GetTypeMeta("Service", "v1"),
|
58
60
|
ObjectMeta: generator.GetObjectMeta(name, namespace, labels, annotations),
|
@@ -65,7 +67,12 @@ func (d Devfile) getService(name, namespace string, labels, annotations map[stri
|
|
65
67
|
return service, err
|
66
68
|
}
|
67
69
|
|
68
|
-
func (d Devfile) getIngress(name, namespace string, labels, annotations map[string]string, domainTemplate, ingressClass string) (
|
70
|
+
func (d Devfile) getIngress(name, namespace string, labels, annotations map[string]string, domainTemplate, ingressClass string) (*networkingv1.Ingress, error) {
|
71
|
+
|
72
|
+
if ingressClass == "none" {
|
73
|
+
return nil, nil
|
74
|
+
}
|
75
|
+
|
69
76
|
components, err := d.devfileObj.Data.GetDevfileContainerComponents(common.DevfileOptions{})
|
70
77
|
if err != nil {
|
71
78
|
return nil, err
|
@@ -75,7 +82,10 @@ func (d Devfile) getIngress(name, namespace string, labels, annotations map[stri
|
|
75
82
|
var rules []networkingv1.IngressRule
|
76
83
|
|
77
84
|
// Create a new template and parse the letter into it.
|
78
|
-
t := template.
|
85
|
+
t, err := template.New("domainTemplate").Parse(domainTemplate)
|
86
|
+
if err != nil {
|
87
|
+
return nil, err
|
88
|
+
}
|
79
89
|
|
80
90
|
for _, component := range components {
|
81
91
|
for _, endpoint := range component.Container.Endpoints {
|
@@ -113,23 +123,16 @@ func (d Devfile) getIngress(name, namespace string, labels, annotations map[stri
|
|
113
123
|
return nil, nil
|
114
124
|
}
|
115
125
|
|
116
|
-
// since annotations is a map, it is passed by reference in go
|
117
|
-
// hence to modify it, create a new copy
|
118
|
-
ingressAnnotations := map[string]string{
|
119
|
-
"kubernetes.io/ingress.class": ingressClass,
|
120
|
-
}
|
121
|
-
for k, v := range annotations {
|
122
|
-
ingressAnnotations[k] = v
|
123
|
-
}
|
124
126
|
ingress := &networkingv1.Ingress{
|
125
127
|
TypeMeta: generator.GetTypeMeta("Ingress", "networking.k8s.io/v1"),
|
126
128
|
ObjectMeta: metav1.ObjectMeta{
|
127
129
|
Name: name,
|
128
130
|
Namespace: namespace,
|
129
131
|
Labels: labels,
|
130
|
-
Annotations:
|
132
|
+
Annotations: annotations,
|
131
133
|
},
|
132
134
|
Spec: networkingv1.IngressSpec{
|
135
|
+
IngressClassName: &ingressClass,
|
133
136
|
//TLS: []networkingv1.IngressTLS{
|
134
137
|
// {
|
135
138
|
// Hosts: hosts,
|
@@ -144,20 +147,30 @@ func (d Devfile) getIngress(name, namespace string, labels, annotations map[stri
|
|
144
147
|
}
|
145
148
|
|
146
149
|
func (d Devfile) getAll(name, namespace string, labels, annotations map[string]string, replicas int, domainTemplate, ingressClass string) ([]runtime.Object, error) {
|
150
|
+
|
151
|
+
var result []runtime.Object
|
152
|
+
|
147
153
|
deployment, err := d.getDeployment(name, namespace, labels, annotations, replicas)
|
148
154
|
if err != nil {
|
149
155
|
return nil, err
|
150
156
|
}
|
157
|
+
result = append(result, deployment)
|
158
|
+
|
151
159
|
service, err := d.getService(name, namespace, labels, annotations)
|
152
160
|
if err != nil {
|
153
161
|
return nil, err
|
154
162
|
}
|
163
|
+
result = append(result, service)
|
164
|
+
|
155
165
|
ingress, err := d.getIngress(name, namespace, labels, annotations, domainTemplate, ingressClass)
|
156
166
|
if err != nil {
|
157
167
|
return nil, err
|
158
168
|
}
|
169
|
+
if ingress != nil {
|
170
|
+
result = append(result, ingress)
|
171
|
+
}
|
159
172
|
|
160
|
-
return
|
173
|
+
return result, nil
|
161
174
|
}
|
162
175
|
|
163
176
|
func (d Devfile) hasContainerComponents() (bool, error) {
|
data/ext/main.go
CHANGED
@@ -9,11 +9,6 @@ import (
|
|
9
9
|
"k8s.io/apimachinery/pkg/runtime"
|
10
10
|
)
|
11
11
|
|
12
|
-
type Result struct {
|
13
|
-
content string
|
14
|
-
err error
|
15
|
-
}
|
16
|
-
|
17
12
|
func main() {
|
18
13
|
args := os.Args
|
19
14
|
|
@@ -25,27 +20,28 @@ func main() {
|
|
25
20
|
fnName := os.Args[1]
|
26
21
|
devfile := os.Args[2]
|
27
22
|
|
28
|
-
var
|
23
|
+
var content string
|
24
|
+
var err error
|
29
25
|
|
30
26
|
switch fnName {
|
31
27
|
case "deployment":
|
32
|
-
|
28
|
+
content, err = getDeployment(devfile, args[3], args[4], args[5], args[6], args[7])
|
33
29
|
case "service":
|
34
|
-
|
30
|
+
content, err = getService(devfile, args[3], args[4], args[5], args[6])
|
35
31
|
case "ingress":
|
36
|
-
|
32
|
+
content, err = getIngress(devfile, args[3], args[4], args[5], args[6], args[7], args[8])
|
37
33
|
case "all":
|
38
|
-
|
34
|
+
content, err = getAll(devfile, args[3], args[4], args[5], args[6], args[7], args[8], args[9])
|
39
35
|
case "flatten":
|
40
|
-
|
36
|
+
content, err = flatten(devfile)
|
41
37
|
}
|
42
38
|
|
43
|
-
if
|
44
|
-
fmt.Fprint(os.Stderr,
|
39
|
+
if err != nil {
|
40
|
+
fmt.Fprint(os.Stderr, err)
|
45
41
|
os.Exit(1)
|
46
42
|
}
|
47
43
|
|
48
|
-
fmt.Print(
|
44
|
+
fmt.Print(content)
|
49
45
|
}
|
50
46
|
|
51
47
|
func unmarshalKeyValuePair(data string) (map[string]string, error) {
|
@@ -57,147 +53,152 @@ func unmarshalKeyValuePair(data string) (map[string]string, error) {
|
|
57
53
|
return values, err
|
58
54
|
}
|
59
55
|
|
60
|
-
func getDeployment(devfile, name, namespace, labelsStr, annotationsStr, replicas string)
|
56
|
+
func getDeployment(devfile, name, namespace, labelsStr, annotationsStr, replicas string) (string, error) {
|
61
57
|
d, err := parseDevfile(devfile)
|
62
58
|
if err != nil {
|
63
|
-
return
|
59
|
+
return "", err
|
64
60
|
}
|
65
61
|
exists, err := d.hasContainerComponents()
|
66
62
|
if err != nil {
|
67
|
-
return
|
63
|
+
return "", err
|
68
64
|
}
|
69
65
|
if exists == false {
|
70
|
-
return
|
66
|
+
return "", err
|
71
67
|
}
|
72
68
|
labels, err := unmarshalKeyValuePair(labelsStr)
|
73
69
|
if err != nil {
|
74
|
-
return
|
70
|
+
return "", err
|
75
71
|
}
|
76
72
|
annotations, err := unmarshalKeyValuePair(annotationsStr)
|
77
73
|
if err != nil {
|
78
|
-
return
|
74
|
+
return "", err
|
79
75
|
}
|
80
76
|
replicasInt, err := strconv.Atoi(replicas)
|
81
77
|
if err != nil {
|
82
|
-
return
|
78
|
+
return "", err
|
83
79
|
}
|
84
80
|
deployment, err := d.getDeployment(name, namespace, labels, annotations, replicasInt)
|
85
81
|
if err != nil {
|
86
|
-
return
|
82
|
+
return "", err
|
87
83
|
}
|
88
84
|
content, err := marshalResources([]runtime.Object{deployment})
|
89
85
|
if err != nil {
|
90
|
-
return
|
86
|
+
return "", err
|
91
87
|
}
|
92
|
-
return
|
88
|
+
return content, nil
|
93
89
|
}
|
94
90
|
|
95
|
-
func getService(devfile, name, namespace, labelsStr, annotationsStr string)
|
91
|
+
func getService(devfile, name, namespace, labelsStr, annotationsStr string) (string, error) {
|
96
92
|
d, err := parseDevfile(devfile)
|
97
93
|
if err != nil {
|
98
|
-
return
|
94
|
+
return "", err
|
99
95
|
}
|
100
96
|
exists, err := d.hasContainerComponents()
|
101
97
|
if err != nil {
|
102
|
-
return
|
98
|
+
return "", err
|
103
99
|
}
|
104
100
|
if exists == false {
|
105
|
-
return
|
101
|
+
return "", err
|
106
102
|
}
|
107
103
|
labels, err := unmarshalKeyValuePair(labelsStr)
|
108
104
|
if err != nil {
|
109
|
-
return
|
105
|
+
return "", err
|
110
106
|
}
|
111
107
|
annotations, err := unmarshalKeyValuePair(annotationsStr)
|
112
108
|
if err != nil {
|
113
|
-
return
|
109
|
+
return "", err
|
114
110
|
}
|
115
111
|
service, err := d.getService(name, namespace, labels, annotations)
|
116
112
|
if err != nil {
|
117
|
-
return
|
113
|
+
return "", err
|
118
114
|
}
|
119
115
|
content, err := marshalResources([]runtime.Object{service})
|
120
116
|
if err != nil {
|
121
|
-
return
|
117
|
+
return "", err
|
122
118
|
}
|
123
|
-
return
|
119
|
+
return content, nil
|
124
120
|
}
|
125
121
|
|
126
|
-
func getIngress(devfile, name, namespace, labelsStr, annotationsStr, domainTemplate, ingressClass string)
|
122
|
+
func getIngress(devfile, name, namespace, labelsStr, annotationsStr, domainTemplate, ingressClass string) (string, error) {
|
127
123
|
d, err := parseDevfile(devfile)
|
128
124
|
if err != nil {
|
129
|
-
return
|
125
|
+
return "", err
|
130
126
|
}
|
131
127
|
exists, err := d.hasContainerComponents()
|
132
128
|
if err != nil {
|
133
|
-
return
|
129
|
+
return "", err
|
134
130
|
}
|
135
131
|
if exists == false {
|
136
|
-
return
|
132
|
+
return "", err
|
137
133
|
}
|
138
134
|
labels, err := unmarshalKeyValuePair(labelsStr)
|
139
135
|
if err != nil {
|
140
|
-
return
|
136
|
+
return "", err
|
141
137
|
}
|
142
138
|
annotations, err := unmarshalKeyValuePair(annotationsStr)
|
143
139
|
if err != nil {
|
144
|
-
return
|
140
|
+
return "", err
|
145
141
|
}
|
146
142
|
ingress, err := d.getIngress(name, namespace, labels, annotations, domainTemplate, ingressClass)
|
147
143
|
if err != nil {
|
148
|
-
return
|
144
|
+
return "", err
|
149
145
|
}
|
146
|
+
|
147
|
+
if ingress == nil {
|
148
|
+
return "", nil
|
149
|
+
}
|
150
|
+
|
150
151
|
content, err := marshalResources([]runtime.Object{ingress})
|
151
152
|
if err != nil {
|
152
|
-
return
|
153
|
+
return "", err
|
153
154
|
}
|
154
|
-
return
|
155
|
+
return content, nil
|
155
156
|
}
|
156
157
|
|
157
|
-
func getAll(devfile string, name, namespace, labelsStr, annotationsStr, replicas, domainTemplate, ingressClass string)
|
158
|
+
func getAll(devfile string, name, namespace, labelsStr, annotationsStr, replicas, domainTemplate, ingressClass string) (string, error) {
|
158
159
|
d, err := parseDevfile(devfile)
|
159
160
|
if err != nil {
|
160
|
-
return
|
161
|
+
return "", err
|
161
162
|
}
|
162
163
|
exists, err := d.hasContainerComponents()
|
163
164
|
if err != nil {
|
164
|
-
return
|
165
|
+
return "", err
|
165
166
|
}
|
166
167
|
if exists == false {
|
167
|
-
return
|
168
|
+
return "", err
|
168
169
|
}
|
169
170
|
labels, err := unmarshalKeyValuePair(labelsStr)
|
170
171
|
if err != nil {
|
171
|
-
return
|
172
|
+
return "", err
|
172
173
|
}
|
173
174
|
annotations, err := unmarshalKeyValuePair(annotationsStr)
|
174
175
|
if err != nil {
|
175
|
-
return
|
176
|
+
return "", err
|
176
177
|
}
|
177
178
|
replicasInt, err := strconv.Atoi(replicas)
|
178
179
|
if err != nil {
|
179
|
-
return
|
180
|
+
return "", err
|
180
181
|
}
|
181
182
|
resources, err := d.getAll(name, namespace, labels, annotations, replicasInt, domainTemplate, ingressClass)
|
182
183
|
if err != nil {
|
183
|
-
return
|
184
|
+
return "", err
|
184
185
|
}
|
185
186
|
content, err := marshalResources(resources)
|
186
187
|
if err != nil {
|
187
|
-
return
|
188
|
+
return "", err
|
188
189
|
}
|
189
|
-
return
|
190
|
+
return content, nil
|
190
191
|
}
|
191
192
|
|
192
|
-
func flatten(devfile string)
|
193
|
+
func flatten(devfile string) (string, error) {
|
193
194
|
d, err := parseDevfile(devfile)
|
194
195
|
if err != nil {
|
195
|
-
return
|
196
|
+
return "", err
|
196
197
|
}
|
197
198
|
flattenedDevfile := d.getFlattenedDevfileContent()
|
198
199
|
content, err := marshalDevfile(flattenedDevfile)
|
199
200
|
if err != nil {
|
200
|
-
return
|
201
|
+
return "", err
|
201
202
|
}
|
202
|
-
return
|
203
|
+
return content, err
|
203
204
|
}
|
metadata
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11.pre.alpha1
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Library used to generate kubernetes manifests from a Devfile.
|
14
|
-
email:
|
14
|
+
email:
|
15
|
+
- cwoolley@gitlab.com
|
16
|
+
- vtak@gitlab.com
|
17
|
+
- spatnaik@gitlab.com
|
15
18
|
executables: []
|
16
19
|
extensions: []
|
17
20
|
extra_rdoc_files: []
|
@@ -43,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
46
|
- !ruby/object:Gem::Version
|
44
47
|
version: 1.3.1
|
45
48
|
requirements: []
|
46
|
-
rubygems_version: 3.4.
|
49
|
+
rubygems_version: 3.4.10
|
47
50
|
signing_key:
|
48
51
|
specification_version: 4
|
49
52
|
summary: Parse and generate kubernetes manifests from a Devfile
|