/
openshiftversion_convert.go
50 lines (41 loc) · 1.57 KB
/
openshiftversion_convert.go
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
package v20231122
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"github.com/Azure/ARO-RP/pkg/api"
)
type openShiftVersionConverter struct{}
// openShiftVersionConverter.ToExternal returns a new external representation
// of the internal object, reading from the subset of the internal object's
// fields that appear in the external representation. ToExternal does not
// modify its argument; there is no pointer aliasing between the passed and
// returned objects.
func (openShiftVersionConverter) ToExternal(v *api.OpenShiftVersion) interface{} {
out := &OpenShiftVersion{
ID: v.ID,
proxyResource: true,
Properties: OpenShiftVersionProperties{
Version: v.Properties.Version,
},
}
return out
}
// ToExternalList returns a slice of external representations of the internal
// objects
func (c openShiftVersionConverter) ToExternalList(vers []*api.OpenShiftVersion) interface{} {
l := &OpenShiftVersionList{
OpenShiftVersions: make([]*OpenShiftVersion, 0, len(vers)),
}
for _, ver := range vers {
l.OpenShiftVersions = append(l.OpenShiftVersions, c.ToExternal(ver).(*OpenShiftVersion))
}
return l
}
// ToInternal overwrites in place a pre-existing internal object, setting (only)
// all mapped fields from the external representation. ToInternal modifies its
// argument; there is no pointer aliasing between the passed and returned
// objects
func (c openShiftVersionConverter) ToInternal(_new interface{}, out *api.OpenShiftVersion) {
new := _new.(*OpenShiftVersion)
out.Properties.Version = new.Properties.Version
}