Skip to content

Commit

Permalink
re-enable mock check on serviceusage
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwenma committed Jun 4, 2024
1 parent ea7a70c commit 4521f1e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
10 changes: 5 additions & 5 deletions apis/cloudbuild/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func Convert_NetworkConfig_API_v1_To_KRM(in *cloudbuildpb.PrivatePoolV1Config_Ne
}

switch in.EgressOption {
case 0:
case cloudbuildpb.PrivatePoolV1Config_NetworkConfig_EGRESS_OPTION_UNSPECIFIED:
out.EgressOption = "EGRESS_OPTION_UNSPECIFIED"
case 1:
case cloudbuildpb.PrivatePoolV1Config_NetworkConfig_NO_PUBLIC_EGRESS:
out.EgressOption = "NO_PUBLIC_EGRESS"
case 2:
case cloudbuildpb.PrivatePoolV1Config_NetworkConfig_PUBLIC_EGRESS:
out.EgressOption = "PUBLIC_EGRESS"
default:
return fmt.Errorf("unknown egressoption %s", out.EgressOption)
Expand All @@ -71,7 +71,7 @@ func Convert_WorkerConfig_API_v1_To_KRM(in *cloudbuildpb.PrivatePoolV1Config_Wor
if in == nil {
return nil
}
out.DiskSizeGb = int(in.DiskSizeGb)
out.DiskSizeGb = in.DiskSizeGb
out.MachineType = in.MachineType
return nil
}
Expand Down Expand Up @@ -144,7 +144,7 @@ func Convert_PrivatePoolV1Config_WorkerConfig_KRM_To_API_v1(in *WorkerConfig, ou
return nil
}
obj := in.DeepCopy()
out.DiskSizeGb = int64(obj.DiskSizeGb)
out.DiskSizeGb = obj.DiskSizeGb
out.MachineType = obj.MachineType
return nil
}
2 changes: 1 addition & 1 deletion apis/cloudbuild/v1beta1/workerpool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type WorkerConfig struct {
// +optional
MachineType string `json:"machineType,omitempty"`
// +optional
DiskSizeGb int `json:"diskSizeGb,omitempty"`
DiskSizeGb int64 `json:"diskSizeGb,omitempty"`
}

type NetworkConfig struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ spec:
- external
properties:
external:
description: The , when not managed by KCC.
description: The compute network selflink of form "projects/<project>/global/networks/<network>",
when not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeNetwork` resource.
Expand All @@ -120,6 +121,7 @@ spec:
workerConfig:
properties:
diskSizeGb:
format: int64
type: integer
machineType:
type: string
Expand Down Expand Up @@ -191,6 +193,7 @@ spec:
workerConfig:
properties:
diskSizeGb:
format: int64
type: integer
machineType:
type: string
Expand Down
5 changes: 1 addition & 4 deletions config/tests/samples/create/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,7 @@ func MaybeSkip(t *testing.T, name string, resources []*unstructured.Unstructured
case schema.GroupKind{Group: "servicenetworking.cnrm.cloud.google.com", Kind: "ServiceNetworkingConnection"}:

case schema.GroupKind{Group: "serviceusage.cnrm.cloud.google.com", Kind: "Service"}:
if os.Getenv("GOLDEN_REQUEST_CHECKS") != "" {
// no golden log for this resource yet
t.Skipf("gk %v/%v does not support golden request check; skipping", gvk.GroupKind(), name)
}

case schema.GroupKind{Group: "serviceusage.cnrm.cloud.google.com", Kind: "ServiceIdentity"}:

case schema.GroupKind{Group: "sql.cnrm.cloud.google.com", Kind: "SQLInstance"}:
Expand Down
24 changes: 16 additions & 8 deletions mockgcp/mockcloudbuild/workerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ func (s *CloudBuildV1) CreateWorkerPool(ctx context.Context, req *pb.CreateWorke
}
obj.State = pb.WorkerPool_RUNNING
metadata := &pb.CreateWorkerPoolOperationMetadata{
WorkerPool: fqn,
CreateTime: now,
CompleteTime: now,
WorkerPool: fqn,
}
return s.operations.DoneLRO(ctx, name.String(), metadata, obj)
return s.operations.StartLRO(ctx, req.GetParent(), metadata, func() (proto.Message, error) {
metadata.CreateTime = now
metadata.CompleteTime = now
return obj, nil
})
}

func (s *CloudBuildV1) UpdateWorkerPool(ctx context.Context, req *pb.UpdateWorkerPoolRequest) (*longrunningpb.Operation, error) {
Expand Down Expand Up @@ -109,11 +111,13 @@ func (s *CloudBuildV1) UpdateWorkerPool(ctx context.Context, req *pb.UpdateWorke
return nil, err
}
metadata := &pb.UpdateWorkerPoolOperationMetadata{
WorkerPool: fqn,
CreateTime: now,
CompleteTime: now,
WorkerPool: fqn,
}
return s.operations.DoneLRO(ctx, name.String(), metadata, obj)

return s.operations.StartLRO(ctx, name.GetParent(), metadata, func() (proto.Message, error) {
metadata.CompleteTime = now
return obj, nil
})
}

func (s *CloudBuildV1) DeleteWorkerPool(ctx context.Context, req *pb.DeleteWorkerPoolRequest) (*longrunningpb.Operation, error) {
Expand Down Expand Up @@ -153,6 +157,10 @@ func (n *workerPoolName) String() string {
return "projects/" + n.Project.ID + "/locations/" + n.Location + "/workerPools/" + n.WorkerPoolName
}

func (n *workerPoolName) GetParent() string {
return "projects/" + n.Project.ID + "/locations/" + n.Location
}

func (s *MockService) parseWorkerPoolName(name string) (*workerPoolName, error) {
tokens := strings.Split(name, "/")

Expand Down

0 comments on commit 4521f1e

Please sign in to comment.