Skip to content

Commit

Permalink
updates on resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Aug 8, 2024
1 parent 2dee76e commit 9c40670
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 133 deletions.
265 changes: 157 additions & 108 deletions apis/refs/v1beta1/computerefs.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ spec:
- external
properties:
external:
description: The compute network selflink of form "projects/<project>/global/networks/<network>",
when not managed by Config Connector.
description: An external value of a `ComputeNetwork` resource,
when not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeNetwork` resource.
Expand Down Expand Up @@ -275,8 +275,8 @@ spec:
- external
properties:
external:
description: The compute network selflink of form "projects/<project>/global/networks/<network>",
when not managed by Config Connector.
description: An external value of a `ComputeNetwork` resource,
when not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeNetwork` resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ spec:
- external
properties:
external:
description: The compute network selflink of form "projects/<project>/global/networks/<network>",
when not managed by Config Connector.
description: An external value of a `ComputeNetwork` resource,
when not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeNetwork` resource.
Expand Down Expand Up @@ -154,8 +154,8 @@ spec:
- external
properties:
external:
description: The ComputeSubnetwork selflink of form "projects/{{project}}/regions/{{region}}/subnetworks/{{name}}",
when not managed by KCC.
description: An external value a `ComputeSubnetwork`, when
not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeSubnetwork` resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ spec:
- external
properties:
external:
description: The compute network selflink of form "projects/<project>/global/networks/<network>",
when not managed by Config Connector.
description: An external value of a `ComputeNetwork` resource,
when not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeNetwork` resource.
Expand Down Expand Up @@ -262,9 +262,8 @@ spec:
- external
properties:
external:
description: The compute network selflink of form
"projects/<project>/global/networks/<network>",
when not managed by Config Connector.
description: An external value of a `ComputeNetwork`
resource, when not managed by KCC.
type: string
name:
description: The `name` field of a `ComputeNetwork`
Expand Down
3 changes: 0 additions & 3 deletions mockgcp/mockcompute/networksv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func (s *NetworksV1) Get(ctx context.Context, req *pb.GetNetworkRequest) (*pb.Ne

obj := &pb.Network{}
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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/direct/cloudbuild/workerpool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u

// Get computeNetwork
if obj.Spec.PrivatePoolConfig.NetworkConfig != nil {
networkRef, err := refs.ResolveComputeNetwork(ctx, reader, obj, &obj.Spec.PrivatePoolConfig.NetworkConfig.PeeredNetworkRef)
networkRef, err := refs.ResolveComputeNetwork(ctx, reader, obj, &obj.Spec.PrivatePoolConfig.NetworkConfig.PeeredNetworkRef, "id")
if err != nil {
return nil, err

}
obj.Spec.PrivatePoolConfig.NetworkConfig.PeeredNetworkRef.External = networkRef.String()
obj.Spec.PrivatePoolConfig.NetworkConfig.PeeredNetworkRef.External = networkRef.External
}

// Get CloudBuild GCP client
Expand Down
10 changes: 4 additions & 6 deletions pkg/controller/direct/networkconnectivity/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ func (r *refNormalizer) VisitField(path string, v any) error {
}

if networkRef, ok := v.(*refs.ComputeNetworkRef); ok {
resolved, err := refs.ResolveComputeNetwork(r.ctx, r.kube, r.src, networkRef)
resolved, err := refs.ResolveComputeNetwork(r.ctx, r.kube, r.src, networkRef, "id")
if err != nil {
return err
}
*networkRef = refs.ComputeNetworkRef{
External: resolved.String(),
}
*networkRef = *resolved
}

if subnetworkRef, ok := v.(*refs.ComputeSubnetworkRef); ok {
resolved, err := refs.ResolveComputeSubnetwork(r.ctx, r.kube, r.src, subnetworkRef)
resolved, err := refs.ResolveComputeSubnetwork(r.ctx, r.kube, r.src, subnetworkRef, "id")
if err != nil {
return err
}
Expand All @@ -73,7 +71,7 @@ func (r *refNormalizer) VisitField(path string, v any) error {
if subnetworkRefs, ok := v.([]refs.ComputeSubnetworkRef); ok {
for i := range subnetworkRefs {
subnetworkRef := &subnetworkRefs[i]
resolved, err := refs.ResolveComputeSubnetwork(r.ctx, r.kube, r.src, subnetworkRef)
resolved, err := refs.ResolveComputeSubnetwork(r.ctx, r.kube, r.src, subnetworkRef, "id")
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ resourceID: string
</td>
<td>
<p><code class="apitype">string</code></p>
<p>{% verbatim %}The compute network selflink of form "projects/<project>/global/networks/<network>", when not managed by Config Connector.{% endverbatim %}</p>
<p>{% verbatim %}An external value of a `ComputeNetwork` resource, when not managed by KCC.{% endverbatim %}</p>
</td>
</tr>
<tr>
Expand Down

0 comments on commit 9c40670

Please sign in to comment.