-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathportal_sdkops.go
More file actions
42 lines (37 loc) · 1.51 KB
/
portal_sdkops.go
File metadata and controls
42 lines (37 loc) · 1.51 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
// Code generated by CRD generation pipeline. DO NOT EDIT.
package v1alpha1
import (
"encoding/json"
"fmt"
sdkkonnectcomp "github.com/Kong/sdk-konnect-go/models/components"
)
// ToCreatePortal converts the PortalAPISpec to the SDK type
// sdkkonnectcomp.CreatePortal using JSON marshal/unmarshal.
// Fields that exist in the CRD spec but not in the SDK type (e.g., Kubernetes
// object references) are naturally excluded because they have different JSON names.
func (s *PortalAPISpec) ToCreatePortal() (*sdkkonnectcomp.CreatePortal, error) {
data, err := json.Marshal(s)
if err != nil {
return nil, fmt.Errorf("failed to marshal PortalAPISpec: %w", err)
}
var target sdkkonnectcomp.CreatePortal
if err := json.Unmarshal(data, &target); err != nil {
return nil, fmt.Errorf("failed to unmarshal into CreatePortal: %w", err)
}
return &target, nil
}
// ToUpdatePortal converts the PortalAPISpec to the SDK type
// sdkkonnectcomp.UpdatePortal using JSON marshal/unmarshal.
// Fields that exist in the CRD spec but not in the SDK type (e.g., Kubernetes
// object references) are naturally excluded because they have different JSON names.
func (s *PortalAPISpec) ToUpdatePortal() (*sdkkonnectcomp.UpdatePortal, error) {
data, err := json.Marshal(s)
if err != nil {
return nil, fmt.Errorf("failed to marshal PortalAPISpec: %w", err)
}
var target sdkkonnectcomp.UpdatePortal
if err := json.Unmarshal(data, &target); err != nil {
return nil, fmt.Errorf("failed to unmarshal into UpdatePortal: %w", err)
}
return &target, nil
}