-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathconverter.go
More file actions
136 lines (116 loc) · 4.87 KB
/
Copy pathconverter.go
File metadata and controls
136 lines (116 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
//
// 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 v1alpha1
import (
pb "github.com/nvidia/nvsentinel/api/gen/go/device/v1alpha1"
"google.golang.org/protobuf/types/known/timestamppb"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Converter is the interface used to generate type conversion methods between the
// Kubernetes Resource Model structs and the Protobuf message structs.
//
// goverter:converter
// goverter:output:file ./zz_generated.goverter.go
// goverter:extend FromProtobufTypeMeta FromProtobufListTypeMeta FromProtobufTimestamp ToProtobufTimestamp
// goverter:useZeroValueOnPointerInconsistency
type Converter interface {
// FromProtobuf converts a protobuf Gpu message into a GPU object.
//
// goverter:map . TypeMeta | FromProtobufTypeMeta
// goverter:map Metadata ObjectMeta
FromProtobuf(source *pb.Gpu) GPU
// ToProtobuf converts a GPU object into a protobuf Gpu message.
//
// goverter:map ObjectMeta Metadata
// goverter:ignore state sizeCache unknownFields
ToProtobuf(source GPU) *pb.Gpu
// FromProtobufList converts a protobuf GpuList message into a GPUList object.
//
// goverter:map . TypeMeta | FromProtobufListTypeMeta
// goverter:map Metadata ListMeta
FromProtobufList(source *pb.GpuList) *GPUList
// ToProtobufList converts a GPUList object into a protobuf GpuList message.
//
// goverter:map ListMeta Metadata
// goverter:ignore state sizeCache unknownFields
ToProtobufList(source *GPUList) *pb.GpuList
// FromProtobufObjectMeta converts a protobuf ObjectMeta into a metav1.ObjectMeta object.
//
// goverter:ignoreMissing
FromProtobufObjectMeta(source *pb.ObjectMeta) metav1.ObjectMeta
// ToProtobufObjectMeta converts a metav1.ObjectMeta into a protobuf Object message.
//
// goverter:ignore state sizeCache unknownFields
ToProtobufObjectMeta(source metav1.ObjectMeta) *pb.ObjectMeta
// FromProtobufListMeta converts a protobuf ListMeta into a metav1.ListMeta object.
//
// goverter:ignore SelfLink Continue RemainingItemCount
FromProtobufListMeta(source *pb.ListMeta) metav1.ListMeta
// ToProtobufListMeta converts a metav1.ListMeta into a protobuf ListMeta message.
//
// goverter:ignore state sizeCache unknownFields
ToProtobufListMeta(source metav1.ListMeta) *pb.ListMeta
// FromProtobufSpec converts a protobuf GpuSpec message into a GPUSpec object.
//
// goverter:map Uuid UUID
FromProtobufSpec(source *pb.GpuSpec) GPUSpec
// ToProtobufSpec converts a GPUSpec object into a protobuf GpuSpec message.
//
// goverter:map UUID Uuid
// goverter:ignore state sizeCache unknownFields
ToProtobufSpec(source GPUSpec) *pb.GpuSpec
// FromProtobufStatus converts a protobuf GpuStatus message into a GPUStatus object.
FromProtobufStatus(source *pb.GpuStatus) GPUStatus
// ToProtobufStatus converts a GPUStatus object into a protobuf GpuStatus message.
//
// goverter:ignore state sizeCache unknownFields
ToProtobufStatus(source GPUStatus) *pb.GpuStatus
// FromProtobufCondition converts a protobuf Condition message into a metav1.Condition object.
//
// goverter:ignore ObservedGeneration
// Note: ObservedGeneration is specific to k8s and not found in the protobuf Condition message.
FromProtobufCondition(source *pb.Condition) metav1.Condition
// ToProtobufCondition converts a metav1.Condition object into a protobuf Condition message.
//
// goverter:ignore state sizeCache unknownFields
ToProtobufCondition(source metav1.Condition) *pb.Condition
}
// FromProtobufTypeMeta generates the standard TypeMeta for the root GPU resource.
func FromProtobufTypeMeta(_ *pb.Gpu) metav1.TypeMeta {
return metav1.TypeMeta{
Kind: "GPU",
APIVersion: SchemeGroupVersion.String(),
}
}
// FromProtobufListTypeMeta generates the standard TypeMeta for the GPUList resource.
func FromProtobufListTypeMeta(_ *pb.GpuList) metav1.TypeMeta {
return metav1.TypeMeta{
Kind: "GPUList",
APIVersion: SchemeGroupVersion.String(),
}
}
// FromProtobufTimestamp converts a protobuf Timestamp message to a metav1.Time.
func FromProtobufTimestamp(source *timestamppb.Timestamp) metav1.Time {
if source == nil {
return metav1.Time{}
}
return metav1.NewTime(source.AsTime())
}
// ToProtobufTimestamp converts a metav1.Time to a protobuf Timestamp message.
func ToProtobufTimestamp(source metav1.Time) *timestamppb.Timestamp {
if source.IsZero() {
return nil
}
return timestamppb.New(source.Time)
}