Skip to content

Commit 8027de2

Browse files
committed
remove Kind specificity on requests
1 parent f1dfb45 commit 8027de2

File tree

8 files changed

+297
-315
lines changed

8 files changed

+297
-315
lines changed

api/core/core.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ message GetObjectResponse {
186186

187187
message ListObjectsRequest {
188188
string namespace = 1;
189-
Kind kind = 2;
189+
string kind = 2;
190190
string clusterName = 3;
191191
}
192192

@@ -198,7 +198,7 @@ message ListObjectsResponse {
198198
message GetReconciledObjectsRequest {
199199
string automationName = 1;
200200
string namespace = 2;
201-
Kind automationKind = 3;
201+
string automationKind = 3;
202202
repeated GroupVersionKind kinds = 4;
203203
string clusterName = 5;
204204
}

api/core/core.swagger.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,7 @@
330330
"name": "kind",
331331
"in": "query",
332332
"required": false,
333-
"type": "string",
334-
"enum": [
335-
"GitRepository",
336-
"Bucket",
337-
"HelmRepository",
338-
"HelmChart",
339-
"Kustomization",
340-
"HelmRelease",
341-
"Cluster",
342-
"OCIRepository",
343-
"Provider",
344-
"Alert"
345-
],
346-
"default": "GitRepository"
333+
"type": "string"
347334
},
348335
{
349336
"name": "clusterName",
@@ -705,7 +692,7 @@
705692
"type": "string"
706693
},
707694
"automationKind": {
708-
"$ref": "#/definitions/v1Kind"
695+
"type": "string"
709696
},
710697
"kinds": {
711698
"type": "array",

core/server/fluxruntime.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,18 @@ func (cs *coreServer) GetReconciledObjects(ctx context.Context, msg *pb.GetRecon
164164
var opts client.MatchingLabels
165165

166166
switch msg.AutomationKind {
167-
case pb.Kind_Kustomization:
167+
case "Kustomization":
168168
opts = client.MatchingLabels{
169169
KustomizeNameKey: msg.AutomationName,
170170
KustomizeNamespaceKey: msg.Namespace,
171171
}
172-
case pb.Kind_HelmRelease:
172+
case "HelmRelease":
173173
opts = client.MatchingLabels{
174174
HelmNameKey: msg.AutomationName,
175175
HelmNamespaceKey: msg.Namespace,
176176
}
177177
default:
178-
return nil, fmt.Errorf("unsupported application kind: %s", msg.AutomationKind.String())
178+
return nil, fmt.Errorf("unsupported application kind: %s", msg.AutomationKind)
179179
}
180180

181181
result := []unstructured.Unstructured{}

core/server/fluxruntime_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestGetReconciledObjects(t *testing.T) {
7171
res, err := c.GetReconciledObjects(ctx, &pb.GetReconciledObjectsRequest{
7272
AutomationName: automationName,
7373
Namespace: ns.Name,
74-
AutomationKind: pb.Kind_Kustomization,
74+
AutomationKind: "Kustomization",
7575
Kinds: []*pb.GroupVersionKind{{Group: "apps", Version: "v1", Kind: "Deployment"}},
7676
ClusterName: clustersmngr.DefaultCluster,
7777
})

core/server/objects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func getUnstructuredHelmReleaseInventory(ctx context.Context, obj unstructured.U
3636
func (cs *coreServer) ListObjects(ctx context.Context, msg *pb.ListObjectsRequest) (*pb.ListObjectsResponse, error) {
3737
respErrors := []*pb.ListError{}
3838

39-
gvk, err := cs.primaryKinds.Lookup(msg.Kind.String())
39+
gvk, err := cs.primaryKinds.Lookup(msg.Kind)
4040
if err != nil {
4141
return nil, err
4242
}

core/server/objects_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func TestListObjectSingle(t *testing.T) {
361361

362362
res, err := c.ListObjects(ctx, &pb.ListObjectsRequest{
363363
Namespace: ns.Name,
364-
Kind: pb.Kind_Kustomization,
364+
Kind: "Kustomization",
365365
})
366366
g.Expect(err).NotTo(HaveOccurred())
367367
g.Expect(res.Errors).To(BeEmpty())
@@ -413,7 +413,7 @@ func TestListObjectMultiple(t *testing.T) {
413413

414414
res, err := c.ListObjects(ctx, &pb.ListObjectsRequest{
415415
Namespace: ns.Name,
416-
Kind: pb.Kind_HelmRelease,
416+
Kind: "HelmRelease",
417417
})
418418
g.Expect(err).NotTo(HaveOccurred())
419419
g.Expect(res.Errors).To(BeEmpty())
@@ -454,7 +454,7 @@ func TestListObjectSingleWithClusterName(t *testing.T) {
454454

455455
res, err := c.ListObjects(ctx, &pb.ListObjectsRequest{
456456
Namespace: ns.Name,
457-
Kind: pb.Kind_Kustomization,
457+
Kind: "Kustomization",
458458
ClusterName: "Default",
459459
})
460460
g.Expect(err).NotTo(HaveOccurred())
@@ -507,7 +507,7 @@ func TestListObjectMultipleWithClusterName(t *testing.T) {
507507

508508
res, err := c.ListObjects(ctx, &pb.ListObjectsRequest{
509509
Namespace: ns.Name,
510-
Kind: pb.Kind_HelmRelease,
510+
Kind: "HelmRelease",
511511
ClusterName: "Default",
512512
})
513513
g.Expect(err).NotTo(HaveOccurred())
@@ -564,7 +564,7 @@ func TestListObject_HelmReleaseWithInventory(t *testing.T) {
564564

565565
res, err := c.ListObjects(ctx, &pb.ListObjectsRequest{
566566
Namespace: ns.Name,
567-
Kind: pb.Kind_HelmRelease,
567+
Kind: "HelmRelease",
568568
})
569569

570570
g.Expect(err).NotTo(HaveOccurred())
@@ -610,7 +610,7 @@ func TestListObject_HelmReleaseCantGetSecret(t *testing.T) {
610610

611611
res, err := c.ListObjects(ctx, &pb.ListObjectsRequest{
612612
Namespace: ns.Name,
613-
Kind: pb.Kind_HelmRelease,
613+
Kind: "HelmRelease",
614614
})
615615
g.Expect(err).NotTo(HaveOccurred())
616616
g.Expect(res.Errors).To(HaveLen(1))

0 commit comments

Comments
 (0)