forked from GoogleCloudPlatform/k8s-config-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
63 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,9 @@ func (s *GlobalForwardingRulesV1) Get(ctx context.Context, req *pb.GetGlobalForw | |
|
||
obj := &pb.ForwardingRule{} | ||
if err := s.storage.Get(ctx, fqn, obj); err != nil { | ||
if status.Code(err) == codes.NotFound { | ||
return nil, status.Errorf(codes.NotFound, "The resource '%s' was not found", fqn) | ||
} | ||
return nil, err | ||
} | ||
|
||
|
@@ -160,10 +163,13 @@ func (s *GlobalForwardingRulesV1) SetLabels(ctx context.Context, req *pb.SetLabe | |
op := &pb.Operation{ | ||
TargetId: obj.Id, | ||
TargetLink: obj.SelfLink, | ||
OperationType: PtrTo("SetLabels"), | ||
OperationType: PtrTo("setLabels"), | ||
User: PtrTo("[email protected]"), | ||
// SetLabels operation has EndTime in response | ||
EndTime: PtrTo("2024-04-01T12:34:56.123456Z"), | ||
// SetLabels operation finished super fast | ||
Progress: PtrTo(int32(100)), | ||
Status: PtrTo(pb.Operation_DONE), | ||
} | ||
return s.startGlobalLRO(ctx, name.Project.ID, op, func() (proto.Message, error) { | ||
return obj, nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,9 @@ func (s *RegionalForwardingRulesV1) Get(ctx context.Context, req *pb.GetForwardi | |
|
||
obj := &pb.ForwardingRule{} | ||
if err := s.storage.Get(ctx, fqn, obj); err != nil { | ||
if status.Code(err) == codes.NotFound { | ||
return nil, status.Errorf(codes.NotFound, "The resource '%s' was not found", fqn) | ||
} | ||
return nil, err | ||
} | ||
|
||
|
@@ -64,6 +67,7 @@ func (s *RegionalForwardingRulesV1) Insert(ctx context.Context, req *pb.InsertFo | |
obj.CreationTimestamp = PtrTo(s.nowString()) | ||
obj.Id = &id | ||
obj.Kind = PtrTo("compute#forwardingRule") | ||
obj.Region = PtrTo(fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/%s", name.Project.ID, name.Region)) | ||
// If below values are not provided by user, it appears to default by GCP | ||
if obj.LabelFingerprint == nil { | ||
obj.LabelFingerprint = PtrTo(computeFingerprint(obj)) | ||
|
@@ -161,10 +165,13 @@ func (s *RegionalForwardingRulesV1) SetLabels(ctx context.Context, req *pb.SetLa | |
op := &pb.Operation{ | ||
TargetId: obj.Id, | ||
TargetLink: obj.SelfLink, | ||
OperationType: PtrTo("SetLabels"), | ||
OperationType: PtrTo("setLabels"), | ||
User: PtrTo("[email protected]"), | ||
// SetLabels operation has EndTime in response | ||
EndTime: PtrTo("2024-04-01T12:34:56.123456Z"), | ||
// SetLabels operation finished super fast | ||
Progress: PtrTo(int32(100)), | ||
Status: PtrTo(pb.Operation_DONE), | ||
} | ||
return s.startRegionalLRO(ctx, name.Project.ID, name.Region, op, func() (proto.Message, error) { | ||
return obj, nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,11 +731,11 @@ X-Xss-Protection: 0 | |
"errors": [ | ||
{ | ||
"domain": "global", | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found", | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found", | ||
"reason": "notFound" | ||
} | ||
], | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found" | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found" | ||
} | ||
} | ||
|
||
|
@@ -895,41 +895,7 @@ X-Xss-Protection: 0 | |
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"progress": 0, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
"status": "RUNNING", | ||
"targetId": "${forwardingRulesId}", | ||
"targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}", | ||
"user": "[email protected]" | ||
} | ||
|
||
--- | ||
|
||
GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID} | ||
Content-Type: application/json | ||
User-Agent: kcc/controller-manager | ||
x-goog-request-params: project=${projectId}&operation=${operationID} | ||
|
||
200 OK | ||
Cache-Control: private | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: ESF | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"endTime": "2024-04-01T12:34:56.123456Z", | ||
"id": "000000000000000000000", | ||
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"operationType": "setLabels", | ||
"progress": 100, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,11 +731,11 @@ X-Xss-Protection: 0 | |
"errors": [ | ||
{ | ||
"domain": "global", | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found", | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found", | ||
"reason": "notFound" | ||
} | ||
], | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found" | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found" | ||
} | ||
} | ||
|
||
|
@@ -921,41 +921,7 @@ X-Xss-Protection: 0 | |
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"progress": 0, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
"status": "RUNNING", | ||
"targetId": "${forwardingRulesId}", | ||
"targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}", | ||
"user": "[email protected]" | ||
} | ||
|
||
--- | ||
|
||
GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID} | ||
Content-Type: application/json | ||
User-Agent: kcc/controller-manager | ||
x-goog-request-params: project=${projectId}&operation=${operationID} | ||
|
||
200 OK | ||
Cache-Control: private | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: ESF | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"endTime": "2024-04-01T12:34:56.123456Z", | ||
"id": "000000000000000000000", | ||
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"operationType": "setLabels", | ||
"progress": 100, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1026,11 +1026,11 @@ X-Xss-Protection: 0 | |
"errors": [ | ||
{ | ||
"domain": "global", | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found", | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found", | ||
"reason": "notFound" | ||
} | ||
], | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found" | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found" | ||
} | ||
} | ||
|
||
|
@@ -1188,41 +1188,7 @@ X-Xss-Protection: 0 | |
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"progress": 0, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
"status": "RUNNING", | ||
"targetId": "${forwardingRulesId}", | ||
"targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}", | ||
"user": "[email protected]" | ||
} | ||
|
||
--- | ||
|
||
GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID} | ||
Content-Type: application/json | ||
User-Agent: kcc/controller-manager | ||
x-goog-request-params: project=${projectId}&operation=${operationID} | ||
|
||
200 OK | ||
Cache-Control: private | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: ESF | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"endTime": "2024-04-01T12:34:56.123456Z", | ||
"id": "000000000000000000000", | ||
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"operationType": "setLabels", | ||
"progress": 100, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -846,11 +846,11 @@ X-Xss-Protection: 0 | |
"errors": [ | ||
{ | ||
"domain": "global", | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found", | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found", | ||
"reason": "notFound" | ||
} | ||
], | ||
"message": "forwardingRule \"projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}\" not found" | ||
"message": "The resource 'projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}' was not found" | ||
} | ||
} | ||
|
||
|
@@ -1008,41 +1008,7 @@ X-Xss-Protection: 0 | |
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"progress": 0, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
"status": "RUNNING", | ||
"targetId": "${forwardingRulesId}", | ||
"targetLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/forwardingRules/computeglobalforwardingrule-${uniqueId}", | ||
"user": "[email protected]" | ||
} | ||
|
||
--- | ||
|
||
GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID} | ||
Content-Type: application/json | ||
User-Agent: kcc/controller-manager | ||
x-goog-request-params: project=${projectId}&operation=${operationID} | ||
|
||
200 OK | ||
Cache-Control: private | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: ESF | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"endTime": "2024-04-01T12:34:56.123456Z", | ||
"id": "000000000000000000000", | ||
"insertTime": "2024-04-01T12:34:56.123456Z", | ||
"kind": "compute#operation", | ||
"name": "${operationID}", | ||
"operationType": "SetLabels", | ||
"operationType": "setLabels", | ||
"progress": 100, | ||
"selfLink": "https://www.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}", | ||
"startTime": "2024-04-01T12:34:56.123456Z", | ||
|
Oops, something went wrong.