devfile 0.0.4.pre.alpha1 → 0.0.5.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68fe0dafd8b89c774342888d1a56ee69357492ef1f7c800695c2cf0e160fc40d
4
- data.tar.gz: ed969d122de436b5d6ad9dec8385e92623921f888ee7ab7b29d882c3abb5dc6b
3
+ metadata.gz: 217f6ef16fae08c970f0deca2170388904be0dfa018009bd04720f5f151253f3
4
+ data.tar.gz: eb54d576b5a9765a21dd3281e12eb3e6698decb96bcc9c61cf09245f717b3536
5
5
  SHA512:
6
- metadata.gz: 914809b92174b11f397c3218ca2d7b12ffbad7abba4a6489864a90df0fcb13a72b9711c87dc538a560718db823ac8475fff3221bdd6137b5e477795d5c49b866
7
- data.tar.gz: a462a444b95b7cbe6fd76fb375a58384dbac3870fee69487273d8c46b61941f8b3cbabad844e3f6d1ec3deb25f3738f0fdb468f95ca99177c05becc2bf0b0674
6
+ metadata.gz: 840e63e69a28ad6db6e0a0db98cf09f1496afa36642e80fea7fcdd74e3b61356f1b50572d786029e23f6d90f21127db263f89cb100a5644841bb67e2beafa108
7
+ data.tar.gz: 396492fc86f1bade988e251f87ca06a4410bd2c2fa865d074d9734da9aedbf552975bac4d968a2cc6853e82d43f22b7ab48ae9612e25796dc20e6e6453f2908d
data/bin/devfile CHANGED
Binary file
data/ext/devfile.go CHANGED
@@ -3,7 +3,9 @@ package main
3
3
  import "C"
4
4
  import (
5
5
  "bytes"
6
- "fmt"
6
+ "strconv"
7
+ "text/template"
8
+
7
9
  "github.com/devfile/library/v2/pkg/devfile/generator"
8
10
  "github.com/devfile/library/v2/pkg/devfile/parser"
9
11
  "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common"
@@ -63,7 +65,7 @@ func (d Devfile) getService(name, namespace string, labels, annotations map[stri
63
65
  return service, err
64
66
  }
65
67
 
66
- func (d Devfile) getIngress(name, namespace string, labels, annotations map[string]string, domainSuffix, ingressClass string) (runtime.Object, error) {
68
+ func (d Devfile) getIngress(name, namespace string, labels, annotations map[string]string, domainTemplate, ingressClass string) (runtime.Object, error) {
67
69
  components, err := d.devfileObj.Data.GetDevfileContainerComponents(common.DevfileOptions{})
68
70
  if err != nil {
69
71
  return nil, err
@@ -72,12 +74,19 @@ func (d Devfile) getIngress(name, namespace string, labels, annotations map[stri
72
74
  var hosts []string
73
75
  var rules []networkingv1.IngressRule
74
76
 
77
+ // Create a new template and parse the letter into it.
78
+ t := template.Must(template.New("domainTemplate").Parse(domainTemplate))
79
+
75
80
  for _, component := range components {
76
81
  for _, endpoint := range component.Container.Endpoints {
77
- domain := fmt.Sprintf("%d-%s-%s.%s", endpoint.TargetPort, endpoint.Name, name, domainSuffix)
78
- hosts = append(hosts, domain)
82
+ var domain bytes.Buffer
83
+ err := t.Execute(&domain, map[string]string{"port": strconv.Itoa(endpoint.TargetPort)})
84
+ if err != nil {
85
+ return nil, err
86
+ }
87
+ hosts = append(hosts, domain.String())
79
88
  rules = append(rules, networkingv1.IngressRule{
80
- Host: domain,
89
+ Host: domain.String(),
81
90
  IngressRuleValue: networkingv1.IngressRuleValue{
82
91
  HTTP: &networkingv1.HTTPIngressRuleValue{
83
92
  Paths: []networkingv1.HTTPIngressPath{
@@ -134,7 +143,7 @@ func (d Devfile) getIngress(name, namespace string, labels, annotations map[stri
134
143
  return ingress, nil
135
144
  }
136
145
 
137
- func (d Devfile) getAll(name, namespace string, labels, annotations map[string]string, replicas int, domainSuffix, ingressClass string) ([]runtime.Object, error) {
146
+ func (d Devfile) getAll(name, namespace string, labels, annotations map[string]string, replicas int, domainTemplate, ingressClass string) ([]runtime.Object, error) {
138
147
  deployment, err := d.getDeployment(name, namespace, labels, annotations, replicas)
139
148
  if err != nil {
140
149
  return nil, err
@@ -143,7 +152,7 @@ func (d Devfile) getAll(name, namespace string, labels, annotations map[string]s
143
152
  if err != nil {
144
153
  return nil, err
145
154
  }
146
- ingress, err := d.getIngress(name, namespace, labels, annotations, domainSuffix, ingressClass)
155
+ ingress, err := d.getIngress(name, namespace, labels, annotations, domainTemplate, ingressClass)
147
156
  if err != nil {
148
157
  return nil, err
149
158
  }
data/ext/main.go CHANGED
@@ -123,7 +123,7 @@ func getService(devfile, name, namespace, labelsStr, annotationsStr string) Resu
123
123
  return Result{content, nil}
124
124
  }
125
125
 
126
- func getIngress(devfile, name, namespace, labelsStr, annotationsStr, domainSuffix, ingressClass string) Result {
126
+ func getIngress(devfile, name, namespace, labelsStr, annotationsStr, domainTemplate, ingressClass string) Result {
127
127
  d, err := parseDevfile(devfile)
128
128
  if err != nil {
129
129
  return Result{"", err}
@@ -143,7 +143,7 @@ func getIngress(devfile, name, namespace, labelsStr, annotationsStr, domainSuffi
143
143
  if err != nil {
144
144
  return Result{"", err}
145
145
  }
146
- ingress, err := d.getIngress(name, namespace, labels, annotations, domainSuffix, ingressClass)
146
+ ingress, err := d.getIngress(name, namespace, labels, annotations, domainTemplate, ingressClass)
147
147
  if err != nil {
148
148
  return Result{"", err}
149
149
  }
@@ -154,7 +154,7 @@ func getIngress(devfile, name, namespace, labelsStr, annotationsStr, domainSuffi
154
154
  return Result{content, nil}
155
155
  }
156
156
 
157
- func getAll(devfile string, name, namespace, labelsStr, annotationsStr, replicas, domainSuffix, ingressClass string) Result {
157
+ func getAll(devfile string, name, namespace, labelsStr, annotationsStr, replicas, domainTemplate, ingressClass string) Result {
158
158
  d, err := parseDevfile(devfile)
159
159
  if err != nil {
160
160
  return Result{"", err}
@@ -178,7 +178,7 @@ func getAll(devfile string, name, namespace, labelsStr, annotationsStr, replicas
178
178
  if err != nil {
179
179
  return Result{"", err}
180
180
  }
181
- resources, err := d.getAll(name, namespace, labels, annotations, replicasInt, domainSuffix, ingressClass)
181
+ resources, err := d.getAll(name, namespace, labels, annotations, replicasInt, domainTemplate, ingressClass)
182
182
  if err != nil {
183
183
  return Result{"", err}
184
184
  }
data/lib/devfile.rb CHANGED
@@ -10,7 +10,9 @@ module Devfile
10
10
 
11
11
  class << self
12
12
  def get_deployment(devfile, name, namespace, labels, annotations, replicas)
13
- stdout, stderr, status = Open3.capture3("#{FILE_PATH} deployment '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}' #{replicas}")
13
+ stdout, stderr, status = Open3.capture3(
14
+ "#{FILE_PATH} deployment '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}' #{replicas}"
15
+ )
14
16
 
15
17
  raise stderr unless status.success?
16
18
 
@@ -18,24 +20,28 @@ module Devfile
18
20
  end
19
21
 
20
22
  def get_service(devfile, name, namespace, labels, annotations)
21
- stdout, stderr, status = Open3.capture3("#{FILE_PATH} service '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}'")
23
+ stdout, stderr, status = Open3.capture3(
24
+ "#{FILE_PATH} service '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}'"
25
+ )
22
26
 
23
27
  raise stderr unless status.success?
24
28
 
25
29
  stdout
26
30
  end
27
31
 
28
- def get_ingress(devfile, name, namespace, labels, annotations, domain_suffix, ingress_class)
29
- stdout, stderr, status = Open3.capture3("#{FILE_PATH} ingress '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}' #{domain_suffix} #{ingress_class}")
32
+ def get_ingress(devfile, name, namespace, labels, annotations, domain_template, ingress_class)
33
+ stdout, stderr, status = Open3.capture3(
34
+ "#{FILE_PATH} ingress '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}' #{domain_template} #{ingress_class}"
35
+ )
30
36
 
31
37
  raise stderr unless status.success?
32
38
 
33
39
  stdout
34
40
  end
35
41
 
36
- def get_all(devfile, name, namespace, labels, annotations, replicas, domain_suffix, ingress_class)
42
+ def get_all(devfile, name, namespace, labels, annotations, replicas, domain_template, ingress_class)
37
43
  stdout, stderr, status = Open3.capture3(
38
- "#{FILE_PATH} all '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}' #{replicas} #{domain_suffix} #{ingress_class}"
44
+ "#{FILE_PATH} all '#{devfile}' #{name} #{namespace} '#{labels}' '#{annotations}' #{replicas} #{domain_template} #{ingress_class}"
39
45
  )
40
46
 
41
47
  raise stderr unless status.success?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre.alpha1
4
+ version: 0.0.5.pre.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-08 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Library used to generate kubernetes manifests from a Devfile.
14
14
  email: spatnaik@gitlab.com
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  - !ruby/object:Gem::Version
44
44
  version: 1.3.1
45
45
  requirements: []
46
- rubygems_version: 3.2.33
46
+ rubygems_version: 3.4.7
47
47
  signing_key:
48
48
  specification_version: 4
49
49
  summary: Parse and generate kubernetes manifests from a Devfile