forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rolev6_types.go
95 lines (80 loc) · 2.76 KB
/
rolev6_types.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
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
/*
* Teleport
* Copyright (C) 2023 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/integrations/operator/apis/resources"
)
func init() {
SchemeBuilder.Register(&TeleportRoleV6{}, &TeleportRoleV6List{})
}
// TeleportRoleV6Spec defines the desired state of TeleportRoleV6
type TeleportRoleV6Spec types.RoleSpecV6
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// TeleportRoleV6 is the Schema for the roles API
type TeleportRoleV6 struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TeleportRoleV6Spec `json:"spec,omitempty"`
Status resources.Status `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// TeleportRoleV6List contains a list of TeleportRoleV6
type TeleportRoleV6List struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TeleportRoleV6 `json:"items"`
}
func (r TeleportRoleV6) ToTeleport() types.Role {
return &types.RoleV6{
Kind: types.KindRole,
Version: types.V6,
Metadata: types.Metadata{
Name: r.Name,
Labels: r.Labels,
Description: r.Annotations[resources.DescriptionKey],
},
Spec: types.RoleSpecV6(r.Spec),
}
}
// Marshal serializes a spec into binary data.
func (spec *TeleportRoleV6Spec) Marshal() ([]byte, error) {
return (*types.RoleSpecV6)(spec).Marshal()
}
// Unmarshal deserializes a spec from binary data.
func (spec *TeleportRoleV6Spec) Unmarshal(data []byte) error {
return (*types.RoleSpecV6)(spec).Unmarshal(data)
}
// DeepCopyInto deep-copies one role spec into another.
// Required to satisfy runtime.Object interface.
func (spec *TeleportRoleV6Spec) DeepCopyInto(out *TeleportRoleV6Spec) {
data, err := spec.Marshal()
if err != nil {
panic(err)
}
*out = TeleportRoleV6Spec{}
if err = out.Unmarshal(data); err != nil {
panic(err)
}
}
// StatusConditions returns a pointer to Status.Conditions slice.
func (r *TeleportRoleV6) StatusConditions() *[]metav1.Condition {
return &r.Status.Conditions
}