/
resource.go
47 lines (42 loc) · 1.58 KB
/
resource.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
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file 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 kubernetes
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/anydotcloud/grm/pkg/types/resource"
)
// Resource represents a custom resource object in the Kubernetes API that
// corresponds to a resource in an cloud service API.
type Resource interface {
resource.Resource
HasConditions
// IsBeingDeleted returns true if the Kubernetes resource has a non-zero
// deletion timestamp
IsBeingDeleted() bool
// SetObjectMeta sets the ObjectMeta field for the resource
SetObjectMeta(meta metav1.ObjectMeta)
// DeepCopy will return a copy of the resource
DeepCopy() Resource
// LateInitialize merges any late-initialized fields from the supplied
// Resource into this Resource.
//
// This method will initialize any optional fields which were not provided
// by the k8s user but were defaulted by the cloud service. If there are
// no such fields to be initialized, no changes are made to the Resource.
//
// NOTE: This method also adds/updates the ConditionTypeLateInitialized for
// the Resource.
LateInitialize(
context.Context,
Resource,
) error
}