Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 515019c

Browse files
committed
add cm and log when complete
Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
1 parent 75ae7a5 commit 515019c

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

controllers/types.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
)
1212

13+
const (
14+
PorterNamespace = "porter-operator-system"
15+
)
16+
1317
type PorterClient interface {
1418
ListInstallations(ctx context.Context, in *installationv1.ListInstallationsRequest, opts ...grpc.CallOption) (*installationv1.ListInstallationsResponse, error)
1519
ListInstallationLatestOutputs(ctx context.Context, in *installationv1.ListInstallationLatestOutputRequest, opts ...grpc.CallOption) (*installationv1.ListInstallationLatestOutputResponse, error)
@@ -20,9 +24,22 @@ type ClientConn interface {
2024
}
2125

2226
var GrpcDeployment = &appsv1.Deployment{
23-
ObjectMeta: metav1.ObjectMeta{},
27+
ObjectMeta: metav1.ObjectMeta{
28+
Name: "",
29+
Namespace: PorterNamespace,
30+
},
2431
}
2532

2633
var GrpcService = &corev1.Service{
27-
ObjectMeta: metav1.ObjectMeta{},
34+
ObjectMeta: metav1.ObjectMeta{
35+
Name: "",
36+
Namespace: PorterNamespace,
37+
},
38+
}
39+
40+
var GrpcConfigMap = &corev1.ConfigMap{
41+
ObjectMeta: metav1.ObjectMeta{
42+
Name: "",
43+
Namespace: PorterNamespace,
44+
},
2845
}

main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func main() {
127127
}
128128

129129
if createGrpc {
130+
// TODO: should this be one go routine or several?
130131
g, ctx := errgroup.WithContext(ctx)
131132
g.Go(func() error {
132133
k8sClient := mgr.GetClient()
@@ -135,6 +136,7 @@ func main() {
135136
err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcDeployment.Name, Namespace: controllers.GrpcDeployment.Namespace}, deployment)
136137
if err != nil {
137138
if apierrors.IsNotFound(err) {
139+
setupLog.Info("creating grpc deployment")
138140
return k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{})
139141
}
140142
}
@@ -148,18 +150,34 @@ func main() {
148150
err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcService.Name, Namespace: controllers.GrpcService.Namespace}, service)
149151
if err != nil {
150152
if apierrors.IsNotFound(err) {
153+
setupLog.Info("creating grpc service")
151154
return k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{})
152155
}
153156
}
154157
// NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found
155158
return nil
156159
})
157160

161+
g.Go(func() error {
162+
k8sClient := mgr.GetClient()
163+
cm := &corev1.ConfigMap{}
164+
err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcConfigMap.Name, Namespace: controllers.GrpcConfigMap.Namespace}, cm)
165+
if err != nil {
166+
if apierrors.IsNotFound(err) {
167+
setupLog.Info("creating grpc configmap")
168+
return k8sClient.Create(ctx, controllers.GrpcConfigMap, &client.CreateOptions{})
169+
}
170+
}
171+
// NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found
172+
return nil
173+
})
174+
158175
go func() {
159176
if err := g.Wait(); err != nil {
160177
setupLog.Error(err, "error with async operation of creating grpc deployment")
161178
os.Exit(1)
162179
}
180+
setupLog.Info("grpc server has been created")
163181
}()
164182
}
165183

0 commit comments

Comments
 (0)