pkg/controller/direct/networkconnectivity/mapper.go (279 lines of code) (raw):

// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package networkconnectivity import ( "time" krm "github.com/GoogleCloudPlatform/k8s-config-connector/apis/networkconnectivity/v1alpha1" refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/networkconnectivity/v1" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct" "google.golang.org/protobuf/types/known/timestamppb" ) func NetworkConnectivityServiceConnectionPolicySpec_FromProto(mapCtx *direct.MapContext, in *pb.ServiceConnectionPolicy) *krm.NetworkConnectivityServiceConnectionPolicySpec { if in == nil { return nil } out := &krm.NetworkConnectivityServiceConnectionPolicySpec{} // MISSING: CreateTime out.Description = direct.LazyPtr(in.GetDescription()) // MISSING: Etag // MISSING: Infrastructure // MISSING: Labels // MISSING: Name if in.Network != "" { out.Network = &refs.ComputeNetworkRef{External: in.Network} } out.PscConfig = PscConfig_FromProto(mapCtx, in.GetPscConfig()) // MISSING: PscConnections out.ServiceClass = direct.LazyPtr(in.GetServiceClass()) // MISSING: UpdateTime return out } func NetworkConnectivityServiceConnectionPolicySpec_Network_ToProto(mapCtx *direct.MapContext, in *refs.ComputeNetworkRef) string { if in == nil { return "" } return in.External } func PscConfig_Subnetworks_FromProto(mapCtx *direct.MapContext, in []string) []refs.ComputeSubnetworkRef { if in == nil { return nil } var out []refs.ComputeSubnetworkRef for _, s := range in { out = append(out, refs.ComputeSubnetworkRef{External: s}) } return out } func PscConfig_Subnetworks_ToProto(mapCtx *direct.MapContext, in []refs.ComputeSubnetworkRef) []string { if in == nil { return nil } var out []string for _, ref := range in { out = append(out, ref.External) } return out } func Group_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Group_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Group_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Group_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func InternalRange_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func InternalRange_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func InternalRange_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func InternalRange_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Hub_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Hub_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Hub_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Hub_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceConnectionPolicy_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { return Timestamp_FromProto(mapCtx, in) } func ServiceConnectionPolicy_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { return Timestamp_ToProto(mapCtx, in) } func ServiceConnectionPolicy_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { return Timestamp_FromProto(mapCtx, in) } func ServiceConnectionPolicy_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { return Timestamp_ToProto(mapCtx, in) } func OperationMetadata_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func OperationMetadata_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func OperationMetadata_EndTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func OperationMetadata_EndTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func RegionalEndpoint_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func RegionalEndpoint_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func RegionalEndpoint_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func RegionalEndpoint_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func PolicyBasedRoute_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func PolicyBasedRoute_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func PolicyBasedRoute_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func PolicyBasedRoute_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Route_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Route_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Route_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Route_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func RouteTable_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func RouteTable_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func RouteTable_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func RouteTable_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceClass_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceClass_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceClass_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceClass_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceConnectionMap_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceConnectionMap_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceConnectionMap_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceConnectionMap_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceConnectionToken_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceConnectionToken_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceConnectionToken_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceConnectionToken_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Spoke_CreateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Spoke_CreateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Spoke_UpdateTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func Spoke_UpdateTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func ServiceConnectionToken_ExpireTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { mapCtx.NotImplemented() return nil } func ServiceConnectionToken_ExpireTime_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { mapCtx.NotImplemented() return nil } func Timestamp_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string { if in == nil { return nil } t := in.AsTime() s := t.Format(time.RFC3339Nano) return &s } func Timestamp_ToProto(mapCtx *direct.MapContext, in *string) *timestamppb.Timestamp { if in == nil { return nil } t, err := time.Parse(time.RFC3339Nano, *in) if err != nil { mapCtx.Errorf("parsing timestamp %q", *in) return nil } return timestamppb.New(t) }