Skip to content

Commit

Permalink
mock gcp log
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwenma committed Dec 12, 2024
1 parent 94cd8f2 commit 2d81810
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 52 deletions.
2 changes: 1 addition & 1 deletion dev/tasks/run-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [[ -z "${KUBEBUILDER_ASSETS:-}" ]]; then
fi

if [[ -z "${KCC_USE_DIRECT_RECONCILERS:-}" ]]; then
KCC_USE_DIRECT_RECONCILERS=ComputeForwardingRule,GKEHubFeatureMembership,SecretManagerSecret,SecretManagerSecretVersion
KCC_USE_DIRECT_RECONCILERS=ComputeForwardingRule,GKEHubFeatureMembership
fi
echo "Using direct controllers: $KCC_USE_DIRECT_RECONCILERS"
export KCC_USE_DIRECT_RECONCILERS
Expand Down
4 changes: 4 additions & 0 deletions mockgcp/mocksecretmanager/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ func (s *SecretsV1) UpdateSecret(ctx context.Context, req *pb.UpdateSecretReques
updated.Expiration = &pb.Secret_ExpireTime{
ExpireTime: req.Secret.GetExpireTime(),
}
case "ttl":
updated.Expiration = &pb.Secret_Ttl{
Ttl: req.Secret.GetTtl(),
}
case "expiration":
updated.Expiration = req.Secret.GetExpiration()
case "rotation.nextRotationTime":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: secretmanager.cnrm.cloud.google.com/v1beta1
kind: SecretManagerSecret
metadata:
annotations:
alpha.cnrm.cloud.google.com/reconciler: direct
cnrm.cloud.google.com/management-conflict-prevention-policy: none
cnrm.cloud.google.com/project-id: ${projectId}
finalizers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Expand All @@ -362,7 +363,7 @@ X-Xss-Protection: 0
"done": true,
"name": "operations/${operationID}",
"response": {
"@type": "type.googleapis.com/google.api.serviceusage.v1beta1.ServiceIdentity",
"@type": "type.googleapis.com/mockgcp.api.serviceusage.v1beta1.ServiceIdentity",
"email": "service-${projectNumber}@gcp-sa-secretmanager.iam.gserviceaccount.com",
"uniqueId": "12345678"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: secretmanager.cnrm.cloud.google.com/v1beta1
kind: SecretManagerSecret
metadata:
annotations:
cnrm.cloud.google.com/project-id: ${projectId}
labels:
cnrm-test: "true"
label-one: value-one
label-two: value-two
managed-by-cnrm: "true"
name: secretmanagersecret-${uniqueId}
spec:
annotations:
bar: secretmanagersecret-bar
foo: secretmanagersecret
expireTime: "2025-10-03T15:01:23Z"
resourceID: secretmanagersecret-${uniqueId}
rotation:
nextRotationTime: "2025-10-03T15:01:23Z"
rotationPeriod: 3600s
topics:
- topicRef:
external: projects/${projectId}/topics/topic-2-${uniqueId}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: secretmanager.cnrm.cloud.google.com/v1beta1
kind: SecretManagerSecret
metadata:
annotations:
cnrm.cloud.google.com/management-conflict-prevention-policy: none
cnrm.cloud.google.com/project-id: ${projectId}
finalizers:
- cnrm.cloud.google.com/finalizer
- cnrm.cloud.google.com/deletion-defender
generation: 2
labels:
cnrm-test: "true"
label-one: value-one
label-two: value-two
name: secretmanagersecret-${uniqueId}
namespace: ${uniqueId}
spec:
annotations:
bar: secretmanagersecret-bar
foo: secretmanagersecret
expireTime: "2025-10-03T15:01:23Z"
replication:
automatic: true
rotation:
nextRotationTime: "2025-10-03T15:01:23Z"
rotationPeriod: 3600s
topics:
- topicRef:
name: topic-2-${uniqueId}
status:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: The resource is up to date
reason: UpToDate
status: "True"
type: Ready
externalRef: projects/${projectId}/secrets/secretmanagersecret-${uniqueId}
name: projects/${projectNumber}/secrets/secretmanagersecret-${uniqueId}
observedGeneration: 2
observedState: {}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Expand All @@ -180,7 +181,7 @@ X-Xss-Protection: 0
"done": true,
"name": "operations/${operationID}",
"response": {
"@type": "type.googleapis.com/google.api.serviceusage.v1beta1.ServiceIdentity",
"@type": "type.googleapis.com/mockgcp.api.serviceusage.v1beta1.ServiceIdentity",
"email": "service-${projectNumber}@gcp-sa-secretmanager.iam.gserviceaccount.com",
"uniqueId": "12345678"
}
Expand Down Expand Up @@ -380,9 +381,10 @@ X-Xss-Protection: 0

---

GET https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?alt=json
GET https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
User-Agent: kcc/controller-manager
x-goog-request-params: name=projects%2F${projectId}%2Fsecrets%2Fsecretmanagersecret-${uniqueId}

404 Not Found
Cache-Control: private
Expand All @@ -405,9 +407,10 @@ X-Xss-Protection: 0

---

POST https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets?alt=json&secretId=secretmanagersecret-${uniqueId}
POST https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets?%24alt=json%3Benum-encoding%3Dint&secretId=secretmanagersecret-${uniqueId}
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
User-Agent: kcc/controller-manager
x-goog-request-params: parent=projects%2F${projectId}

{
"annotations": {
Expand Down Expand Up @@ -473,9 +476,10 @@ X-Xss-Protection: 0

---

GET https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?alt=json
GET https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
User-Agent: kcc/controller-manager
x-goog-request-params: name=projects%2F${projectId}%2Fsecrets%2Fsecretmanagersecret-${uniqueId}

200 OK
Cache-Control: private
Expand Down Expand Up @@ -517,22 +521,25 @@ X-Xss-Protection: 0

---

PATCH https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?alt=json&updateMask=labels%2Cannotations%2Ctopics%2CexpireTime%2Crotation
PATCH https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint&updateMask=annotations%2CexpireTime%2Clabels%2Crotation.nextRotationTime%2Ctopics
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
User-Agent: kcc/controller-manager
x-goog-request-params: secret.name=projects%2F${projectId}%2Fsecrets%2Fsecretmanagersecret-${uniqueId}

{
"annotations": {
"bar": "secretmanagersecret-bar",
"foo": "secretmanagersecret"
},
"etag": "abcdef0123A=",
"expireTime": "2025-10-03T15:01:23Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
"label-two": "value-two",
"managed-by-cnrm": "true"
},
"name": "projects/${projectId}/secrets/secretmanagersecret-${uniqueId}",
"replication": {
"automatic": {}
},
Expand Down Expand Up @@ -635,9 +642,57 @@ X-Xss-Protection: 0

---

DELETE https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?alt=json
GET https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager
User-Agent: kcc/controller-manager
x-goog-request-params: name=projects%2F${projectId}%2Fsecrets%2Fsecretmanagersecret-${uniqueId}

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

{
"annotations": {
"bar": "secretmanagersecret-bar",
"foo": "secretmanagersecret"
},
"createTime": "2024-04-01T12:34:56.123456Z",
"etag": "abcdef0123A=",
"expireTime": "2025-10-03T15:01:23Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
"label-two": "value-two",
"managed-by-cnrm": "true"
},
"name": "projects/${projectNumber}/secrets/secretmanagersecret-${uniqueId}",
"replication": {
"automatic": {}
},
"rotation": {
"nextRotationTime": "2025-10-03T15:01:23Z",
"rotationPeriod": "3600s"
},
"topics": [
{
"name": "projects/${projectId}/topics/topic-2-${uniqueId}"
}
]
}

---

DELETE https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint
Content-Type: application/json
User-Agent: kcc/controller-manager
x-goog-request-params: name=projects%2F${projectId}%2Fsecrets%2Fsecretmanagersecret-${uniqueId}

200 OK
Cache-Control: private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ spec:
annotations:
bar: secretmanagersecret-bar
foo: secretmanagersecret
expireTime: "2024-12-12T05:00:40.845270931Z"
replication:
userManaged:
replicas:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ Content-Type: application/json
User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Expand All @@ -362,7 +363,7 @@ X-Xss-Protection: 0
"done": true,
"name": "operations/${operationID}",
"response": {
"@type": "type.googleapis.com/google.api.serviceusage.v1beta1.ServiceIdentity",
"@type": "type.googleapis.com/mockgcp.api.serviceusage.v1beta1.ServiceIdentity",
"email": "service-${projectNumber}@gcp-sa-secretmanager.iam.gserviceaccount.com",
"uniqueId": "12345678"
}
Expand Down Expand Up @@ -737,7 +738,6 @@ X-Xss-Protection: 0
},
"createTime": "2024-04-01T12:34:56.123456Z",
"etag": "abcdef0123A=",
"expireTime": "2024-12-12T05:00:28.938552436Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
Expand All @@ -764,7 +764,8 @@ X-Xss-Protection: 0
{
"name": "projects/${projectId}/topics/topic-${uniqueId}"
}
]
],
"ttl": "100s"
}

---
Expand All @@ -791,7 +792,6 @@ X-Xss-Protection: 0
},
"createTime": "2024-04-01T12:34:56.123456Z",
"etag": "abcdef0123A=",
"expireTime": "2024-12-12T05:00:28.938552436Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
Expand All @@ -818,12 +818,13 @@ X-Xss-Protection: 0
{
"name": "projects/${projectId}/topics/topic-${uniqueId}"
}
]
],
"ttl": "100s"
}

---

PATCH https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint&updateMask=annotations%2CexpireTime%2Clabels%2Crotation.nextRotationTime%2Crotation.rotationPeriod%2Ctopics%2Cttl
PATCH https://secretmanager.googleapis.com/v1/projects/${projectId}/secrets/secretmanagersecret-${uniqueId}?%24alt=json%3Benum-encoding%3Dint&updateMask=annotations%2Clabels%2Crotation.nextRotationTime%2Crotation.rotationPeriod%2Ctopics%2Cttl
Content-Type: application/json
User-Agent: kcc/controller-manager
x-goog-request-params: secret.name=projects%2F${projectId}%2Fsecrets%2Fsecretmanagersecret-${uniqueId}
Expand Down Expand Up @@ -883,7 +884,6 @@ X-Xss-Protection: 0
},
"createTime": "2024-04-01T12:34:56.123456Z",
"etag": "abcdef0123A=",
"expireTime": "2024-12-12T05:00:40.845270931Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
Expand Down Expand Up @@ -911,7 +911,8 @@ X-Xss-Protection: 0
{
"name": "projects/${projectId}/topics/topic-2-${uniqueId}"
}
]
],
"ttl": "110s"
}

---
Expand All @@ -938,7 +939,6 @@ X-Xss-Protection: 0
},
"createTime": "2024-04-01T12:34:56.123456Z",
"etag": "abcdef0123A=",
"expireTime": "2024-12-12T05:00:40.845270931Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
Expand Down Expand Up @@ -966,7 +966,8 @@ X-Xss-Protection: 0
{
"name": "projects/${projectId}/topics/topic-2-${uniqueId}"
}
]
],
"ttl": "110s"
}

---
Expand Down Expand Up @@ -994,7 +995,6 @@ X-Xss-Protection: 0
},
"createTime": "2024-04-01T12:34:56.123456Z",
"etag": "abcdef0123A=",
"expireTime": "2024-12-12T05:00:40.845270931Z",
"labels": {
"cnrm-test": "true",
"label-one": "value-one",
Expand Down Expand Up @@ -1022,7 +1022,8 @@ X-Xss-Protection: 0
{
"name": "projects/${projectId}/topics/topic-2-${uniqueId}"
}
]
],
"ttl": "110s"
}

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ spec:
annotations:
bar: secretmanagersecret-bar
foo: secretmanagersecret
expireTime: "2024-12-12T04:55:16.450080998Z"
replication:
userManaged:
replicas:
Expand Down
Loading

0 comments on commit 2d81810

Please sign in to comment.