Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid service from catsrc with periods in name #3024

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/controller/registry/reconciler/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"hash/fnv"
"strings"
"time"

"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
Expand Down Expand Up @@ -72,7 +73,7 @@ func (s *grpcCatalogSourceDecorator) Annotations() map[string]string {
func (s *grpcCatalogSourceDecorator) Service() *corev1.Service {
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: s.GetName(),
Name: strings.ReplaceAll(s.GetName(), ".", "-"),
Namespace: s.GetNamespace(),
},
Spec: corev1.ServiceSpec{
Expand Down
22 changes: 22 additions & 0 deletions pkg/controller/registry/reconciler/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func grpcCatalogSourceWithAnnotations(annotations map[string]string) *v1alpha1.C
return catsrc
}

func grpcCatalogSourceWithName(name string) *v1alpha1.CatalogSource {
catsrc := validGrpcCatalogSource("image", "")
catsrc.SetName(name)
catsrc.ObjectMeta.Labels["olm.catalogSource"] = name
return catsrc
}

func TestGrpcRegistryReconciler(t *testing.T) {
now := func() metav1.Time { return metav1.Date(2018, time.January, 26, 20, 40, 0, 0, time.UTC) }
blockOwnerDeletion := true
Expand Down Expand Up @@ -103,6 +110,21 @@ func TestGrpcRegistryReconciler(t *testing.T) {
},
},
},
{
testName: "Grpc/NoExistingRegistry/CreateSuccessful/CatalogSourceWithPeriodInNameCreatesValidServiceName",
in: in{
catsrc: grpcCatalogSourceWithName("img.catalog"),
},
out: out{
status: &v1alpha1.RegistryServiceStatus{
CreatedAt: now(),
Protocol: "grpc",
ServiceName: "img-catalog",
ServiceNamespace: testNamespace,
Port: "50051",
},
},
},
{
testName: "Grpc/ExistingRegistry/CreateSuccessful",
in: in{
Expand Down
Loading