-
Notifications
You must be signed in to change notification settings - Fork 682
/
aliases.go
159 lines (118 loc) · 4.89 KB
/
aliases.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package kates
import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
xv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/version"
"k8s.io/cli-runtime/pkg/genericclioptions"
metrics "k8s.io/metrics/pkg/apis/metrics/v1beta1"
)
// The kubernetes client libraries and core protobufs are split across so many different packages
// that it is extremely difficult to keep them straight. The naming conventions are also very poorly
// chosen resulting in frequent name collisions under even simple uses. Case in point, there are a
// whole lot of v1 packages (core/v1, apiextensions/v1, meta/v1, apps/v1) just to name a few, and
// you need to use at least 3 of these together in order to accomplish almost anything. The types
// within packages are often horribly named as well (e.g. dynamic.Interface, rest.Config,
// version.Info are not super description when you omit the packages).
//
// The aliases in this file are intended to do several things:
//
// 1. Make our kubernetes code easier to read by providing a standard set of aliases instead of
// requiring developers to make up potentially different aliases at the point of use.
//
// 2. Make for a simpler and easier Quickstart for our kubernetes library by providing a single
// entry point.
//
// 3. Allow us to build a set of simpler and easier to use APIs on top of client-go while using
// types that are compatible with client-go so we have a good escape hatch for directly using
// client-go.
//
// 4. Provide a single file that helps me (rhs@datawire.io) remember where the hell everything is.
// type related aliases
type TypeMeta = metav1.TypeMeta
type ObjectMeta = metav1.ObjectMeta
type Namespace = corev1.Namespace
type LocalObjectReference = corev1.LocalObjectReference
type Event = corev1.Event
type ConfigMap = corev1.ConfigMap
type Secret = corev1.Secret
type Ingress = netv1beta1.Ingress
type IngressClass = netv1beta1.IngressClass
type Service = corev1.Service
type ServiceSpec = corev1.ServiceSpec
type ServicePort = corev1.ServicePort
type Endpoints = corev1.Endpoints
var ServiceTypeLoadBalancer = corev1.ServiceTypeLoadBalancer
type Pod = corev1.Pod
type PodSpec = corev1.PodSpec
type Container = corev1.Container
type SecurityContext = corev1.SecurityContext
type PodCondition = corev1.PodCondition
type PodLogOptions = corev1.PodLogOptions
var PodSucceeded = corev1.PodSucceeded
var PodFailed = corev1.PodFailed
var PodReady = corev1.PodReady
var CoreConditionTrue = corev1.ConditionTrue
type Node = corev1.Node
const NodeUnreachablePodReason = "NodeLost" // k8s.io/kubernetes/pkg/util/node.NodeUnreachablePodReason
type Volume = corev1.Volume
type VolumeSource = corev1.VolumeSource
type PersistentVolumeClaimVolumeSource = corev1.PersistentVolumeClaimVolumeSource
type VolumeMount = corev1.VolumeMount
type ResourceRequirements = corev1.ResourceRequirements
type ResourceList = corev1.ResourceList
const ResourceCPU = corev1.ResourceCPU
const ResourceMemory = corev1.ResourceMemory
type PersistentVolumeClaim = corev1.PersistentVolumeClaim
type Deployment = appsv1.Deployment
type CustomResourceDefinition = xv1.CustomResourceDefinition
var NamesAccepted = xv1.NamesAccepted
var Established = xv1.Established
var ConditionTrue = xv1.ConditionTrue
type NodeMetrics = metrics.NodeMetrics
type PodMetrics = metrics.PodMetrics
type ContainerMetrics = metrics.ContainerMetrics
type Unstructured = unstructured.Unstructured
var MustParseQuantity = resource.MustParse
type Quantity = resource.Quantity
type IntOrString = intstr.IntOrString
var Int = intstr.Int
// client related aliases
type ConfigFlags = genericclioptions.ConfigFlags
var NewConfigFlags = genericclioptions.NewConfigFlags
type VersionInfo = version.Info
type PatchType = types.PatchType
var (
JSONPatchType = types.JSONPatchType
MergePatchType = types.MergePatchType
StrategicMergePatchType = types.StrategicMergePatchType
ApplyPatchType = types.ApplyPatchType
)
type GetOptions = metav1.GetOptions
type ListOptions = metav1.ListOptions
type CreateOptions = metav1.CreateOptions
type UpdateOptions = metav1.UpdateOptions
type PatchOptions = metav1.PatchOptions
type DeleteOptions = metav1.DeleteOptions
var NamespaceAll = metav1.NamespaceAll
var NamespaceNone = metav1.NamespaceNone
type Selector = labels.Selector
type LabelSet = labels.Set
var ParseSelector = labels.Parse
// error related aliases
var IsNotFound = apierrors.IsNotFound
var IsConflict = apierrors.IsConflict
//
type Object interface {
runtime.Object
metav1.Object
}