Skip to content

Commit 24724a1

Browse files
authored
Update Ingress and Hostname (#80)
* update ingress hostname Signed-off-by: Jordan Dubrick <jdubrick@redhat.com> * update known issues Signed-off-by: Jordan Dubrick <dubrickjordan@gmail.com> --------- Signed-off-by: Jordan Dubrick <jdubrick@redhat.com> Signed-off-by: Jordan Dubrick <dubrickjordan@gmail.com>
1 parent 29aef03 commit 24724a1

File tree

3 files changed

+97
-1
lines changed

3 files changed

+97
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,8 @@ make run ENABLE_WEBHOOKS=false
174174
## Contributing
175175

176176
Please see our [contributing.md](./CONTRIBUTING.md).
177+
178+
## Known Issues
179+
- [`make test-integration` times out when running in Minikube](https://github.com/devfile/api/issues/1313)
180+
- [Headless mode field does not update devfile registry state during reconcile](https://github.com/devfile/api/issues/1258)
181+
- [`make bundle` removes `alm-examples` for `DevfileRegistriesList` and `ClusterDevfileRegistriesList` CRDs due to bug with Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/5042)

pkg/registry/ingress.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package registry
1818

1919
import (
20+
"fmt"
21+
2022
registryv1alpha1 "github.com/devfile/registry-operator/api/v1alpha1"
2123
networkingv1 "k8s.io/api/networking/v1"
2224
"k8s.io/apimachinery/pkg/runtime"
@@ -70,5 +72,9 @@ func GenerateIngress(cr *registryv1alpha1.DevfileRegistry, host string, scheme *
7072
}
7173

7274
func GetDevfileRegistryIngress(cr *registryv1alpha1.DevfileRegistry) string {
73-
return cr.Name + "." + cr.Spec.K8s.IngressDomain
75+
return GetHostname(cr) + "." + cr.Spec.K8s.IngressDomain
76+
}
77+
78+
func GetHostname(cr *registryv1alpha1.DevfileRegistry) string {
79+
return fmt.Sprintf("%s-%s", cr.Name, cr.Namespace)
7480
}

pkg/registry/ingress_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//
2+
//
3+
// Copyright Red Hat
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package registry
18+
19+
import (
20+
"testing"
21+
22+
registryv1alpha1 "github.com/devfile/registry-operator/api/v1alpha1"
23+
)
24+
25+
func TestGetDevfileRegistryIngress(t *testing.T) {
26+
27+
tests := []struct {
28+
name string
29+
cr registryv1alpha1.DevfileRegistry
30+
want string
31+
}{
32+
{
33+
name: "Case 1: Correct Conjunction",
34+
cr: registryv1alpha1.DevfileRegistry{
35+
Spec: registryv1alpha1.DevfileRegistrySpec{
36+
K8s: registryv1alpha1.DevfileRegistrySpecK8sOnly{
37+
IngressDomain: "my-domain",
38+
},
39+
}},
40+
want: "test-name-test-namespace.my-domain",
41+
},
42+
}
43+
for _, tt := range tests {
44+
t.Run(tt.name, func(t *testing.T) {
45+
tt.cr.Name = "test-name"
46+
tt.cr.Namespace = "test-namespace"
47+
ingress := GetDevfileRegistryIngress(&tt.cr)
48+
if ingress != tt.want {
49+
t.Errorf("expected: %v got: %v", tt.want, ingress)
50+
}
51+
})
52+
}
53+
54+
}
55+
56+
func TestGetHostname(t *testing.T) {
57+
58+
tests := []struct {
59+
name string
60+
cr registryv1alpha1.DevfileRegistry
61+
want string
62+
}{
63+
{
64+
name: "Case 1: Correct Hostname",
65+
cr: registryv1alpha1.DevfileRegistry{
66+
Spec: registryv1alpha1.DevfileRegistrySpec{
67+
K8s: registryv1alpha1.DevfileRegistrySpecK8sOnly{
68+
IngressDomain: "my-domain",
69+
},
70+
}},
71+
want: "test-name-test-namespace",
72+
},
73+
}
74+
for _, tt := range tests {
75+
t.Run(tt.name, func(t *testing.T) {
76+
tt.cr.Name = "test-name"
77+
tt.cr.Namespace = "test-namespace"
78+
hostname := GetHostname(&tt.cr)
79+
if hostname != tt.want {
80+
t.Errorf("expected: %v got: %v", tt.want, hostname)
81+
}
82+
})
83+
}
84+
85+
}

0 commit comments

Comments
 (0)