mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Improvement] Add Resource kerror Type (#1192)
This commit is contained in:
parent
565da298f1
commit
b0bd486eb4
70 changed files with 757 additions and 299 deletions
|
@ -27,6 +27,7 @@
|
||||||
- (Improvement) Add Anonymous Inspector mods
|
- (Improvement) Add Anonymous Inspector mods
|
||||||
- (Improvement) Do not check checksums for DeploymentReplicationStatus.IncomingSynchronization field values
|
- (Improvement) Do not check checksums for DeploymentReplicationStatus.IncomingSynchronization field values
|
||||||
- (Improvement) Add ServerGroup details into ServerGroupSpec
|
- (Improvement) Add ServerGroup details into ServerGroupSpec
|
||||||
|
- (Improvement) Add Resource kerror Type
|
||||||
|
|
||||||
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
|
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
|
||||||
- (Feature) Add action progress
|
- (Feature) Add action progress
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *arangoClusterSynchronizationsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := ArangoClusterSynchronizationGK()
|
g := constants.ArangoClusterSynchronizationGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case ArangoClusterSynchronizationVersionV1, DefaultVersion:
|
case constants.ArangoClusterSynchronizationVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type arangoClusterSynchronizationsInspectorAnonymousV1 struct {
|
type arangoClusterSynchronizationsInspectorAnonymousV1 struct {
|
||||||
|
@ -39,7 +40,7 @@ func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Get(ctx context.Cont
|
||||||
|
|
||||||
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
|
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
|
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoClusterSynchronizationModInterface().V1().Create(ctx, o, opts)
|
return e.i.ArangoClusterSynchronizationModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Create(ctx context.C
|
||||||
|
|
||||||
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
|
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
|
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoClusterSynchronizationModInterface().V1().Update(ctx, o, opts)
|
return e.i.ArangoClusterSynchronizationModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +56,7 @@ func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Update(ctx context.C
|
||||||
|
|
||||||
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
|
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
|
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoClusterSynchronizationModInterface().V1().UpdateStatus(ctx, o, opts)
|
return e.i.ArangoClusterSynchronizationModInterface().V1().UpdateStatus(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
|
43
pkg/deployment/resources/inspector/acs_gvk.go
Normal file
43
pkg/deployment/resources/inspector/acs_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.ArangoClusterSynchronizationGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.ArangoClusterSynchronizationGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoClusterSynchronizationsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.ArangoClusterSynchronizationGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoClusterSynchronizationsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.ArangoClusterSynchronizationGR()
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import (
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoclustersynchronization/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoclustersynchronization/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspector) V1() (ins.Inspector, error) {
|
func (p *arangoClusterSynchronizationsInspector) V1() (ins.Inspector, error) {
|
||||||
|
@ -130,7 +131,7 @@ func (p *arangoClusterSynchronizationsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoClusterSynchronization, error) {
|
func (p *arangoClusterSynchronizationsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoClusterSynchronization, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(ArangoClusterSynchronizationGR(), name)
|
return nil, apiErrors.NewNotFound(constants.ArangoClusterSynchronizationGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *arangoMembersInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *arangoMembersInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := ArangoMemberGK()
|
g := constants.ArangoMemberGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case ArangoMemberVersionV1, DefaultVersion:
|
case constants.ArangoMemberVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type arangoMembersInspectorAnonymousV1 struct {
|
type arangoMembersInspectorAnonymousV1 struct {
|
||||||
|
@ -39,7 +40,7 @@ func (e *arangoMembersInspectorAnonymousV1) Get(ctx context.Context, name string
|
||||||
|
|
||||||
func (e *arangoMembersInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *arangoMembersInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoMember); !ok {
|
if o, ok := obj.(*api.ArangoMember); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoMemberGKv1())
|
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoMemberModInterface().V1().Create(ctx, o, opts)
|
return e.i.ArangoMemberModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ func (e *arangoMembersInspectorAnonymousV1) Create(ctx context.Context, obj meta
|
||||||
|
|
||||||
func (e *arangoMembersInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *arangoMembersInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoMember); !ok {
|
if o, ok := obj.(*api.ArangoMember); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoMemberGKv1())
|
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoMemberModInterface().V1().Update(ctx, o, opts)
|
return e.i.ArangoMemberModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +56,7 @@ func (e *arangoMembersInspectorAnonymousV1) Update(ctx context.Context, obj meta
|
||||||
|
|
||||||
func (e *arangoMembersInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *arangoMembersInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoMember); !ok {
|
if o, ok := obj.(*api.ArangoMember); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoMemberGKv1())
|
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoMemberModInterface().V1().UpdateStatus(ctx, o, opts)
|
return e.i.ArangoMemberModInterface().V1().UpdateStatus(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
|
43
pkg/deployment/resources/inspector/am_gvk.go
Normal file
43
pkg/deployment/resources/inspector/am_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *arangoMembersInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.ArangoMemberGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoMembersInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.ArangoMemberGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoMembersInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.ArangoMemberGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoMembersInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.ArangoMemberGR()
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import (
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *arangoMembersInspector) V1() ins.Inspector {
|
func (p *arangoMembersInspector) V1() ins.Inspector {
|
||||||
|
@ -110,7 +111,7 @@ func (p *arangoMembersInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *arangoMembersInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoMember, error) {
|
func (p *arangoMembersInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoMember, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(ArangoMemberGR(), name)
|
return nil, apiErrors.NewNotFound(constants.ArangoMemberGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *arangoTasksInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *arangoTasksInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := ArangoTaskGK()
|
g := constants.ArangoTaskGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case ArangoTaskVersionV1, DefaultVersion:
|
case constants.ArangoTaskVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type arangoTasksInspectorAnonymousV1 struct {
|
type arangoTasksInspectorAnonymousV1 struct {
|
||||||
|
@ -39,7 +40,7 @@ func (e *arangoTasksInspectorAnonymousV1) Get(ctx context.Context, name string,
|
||||||
|
|
||||||
func (e *arangoTasksInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *arangoTasksInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoTask); !ok {
|
if o, ok := obj.(*api.ArangoTask); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoTaskGKv1())
|
return nil, newInvalidTypeError(constants.ArangoTaskGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoTaskModInterface().V1().Create(ctx, o, opts)
|
return e.i.ArangoTaskModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ func (e *arangoTasksInspectorAnonymousV1) Create(ctx context.Context, obj meta.O
|
||||||
|
|
||||||
func (e *arangoTasksInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *arangoTasksInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoTask); !ok {
|
if o, ok := obj.(*api.ArangoTask); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoTaskGKv1())
|
return nil, newInvalidTypeError(constants.ArangoTaskGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoTaskModInterface().V1().Update(ctx, o, opts)
|
return e.i.ArangoTaskModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +56,7 @@ func (e *arangoTasksInspectorAnonymousV1) Update(ctx context.Context, obj meta.O
|
||||||
|
|
||||||
func (e *arangoTasksInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *arangoTasksInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*api.ArangoTask); !ok {
|
if o, ok := obj.(*api.ArangoTask); !ok {
|
||||||
return nil, newInvalidTypeError(ArangoTaskGKv1())
|
return nil, newInvalidTypeError(constants.ArangoTaskGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ArangoTaskModInterface().V1().UpdateStatus(ctx, o, opts)
|
return e.i.ArangoTaskModInterface().V1().UpdateStatus(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
|
43
pkg/deployment/resources/inspector/at_gvk.go
Normal file
43
pkg/deployment/resources/inspector/at_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *arangoTasksInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.ArangoTaskGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoTasksInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.ArangoTaskGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoTasksInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.ArangoTaskGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *arangoTasksInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.ArangoTaskGR()
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import (
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangotask/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangotask/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *arangoTasksInspector) V1() (ins.Inspector, error) {
|
func (p *arangoTasksInspector) V1() (ins.Inspector, error) {
|
||||||
|
@ -130,7 +131,7 @@ func (p *arangoTasksInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *arangoTasksInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoTask, error) {
|
func (p *arangoTasksInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoTask, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(ArangoTaskGR(), name)
|
return nil, apiErrors.NewNotFound(constants.ArangoTaskGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *endpointsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *endpointsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := EndpointsGK()
|
g := constants.EndpointsGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case EndpointsVersionV1, DefaultVersion:
|
case constants.EndpointsVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type endpointsInspectorAnonymousV1 struct {
|
type endpointsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *endpointsInspectorAnonymousV1) Get(ctx context.Context, name string, op
|
||||||
|
|
||||||
func (e *endpointsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *endpointsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Endpoints); !ok {
|
if o, ok := obj.(*core.Endpoints); !ok {
|
||||||
return nil, newInvalidTypeError(EndpointsGKv1())
|
return nil, newInvalidTypeError(constants.EndpointsGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.EndpointsModInterface().V1().Create(ctx, o, opts)
|
return e.i.EndpointsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *endpointsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Obj
|
||||||
|
|
||||||
func (e *endpointsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *endpointsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Endpoints); !ok {
|
if o, ok := obj.(*core.Endpoints); !ok {
|
||||||
return nil, newInvalidTypeError(EndpointsGKv1())
|
return nil, newInvalidTypeError(constants.EndpointsGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.EndpointsModInterface().V1().Update(ctx, o, opts)
|
return e.i.EndpointsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *endpointsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *endpointsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(EndpointsGKv1())
|
return nil, newNotImplementedError(constants.EndpointsGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *endpointsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *endpointsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/endpoints_gvk.go
Normal file
43
pkg/deployment/resources/inspector/endpoints_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *endpointsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.EndpointsGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *endpointsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.EndpointsGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *endpointsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.EndpointsGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *endpointsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.EndpointsGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/endpoints/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/endpoints/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ func (p *endpointsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *endpointsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Endpoints, error) {
|
func (p *endpointsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Endpoints, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(EndpointsGR(), name)
|
return nil, apiErrors.NewNotFound(constants.EndpointsGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *nodesInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *nodesInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := NodeGK()
|
g := constants.NodeGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case NodeVersionV1, DefaultVersion:
|
case constants.NodeVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ import (
|
||||||
|
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type nodesInspectorAnonymousV1 struct {
|
type nodesInspectorAnonymousV1 struct {
|
||||||
|
@ -36,21 +38,21 @@ func (e *nodesInspectorAnonymousV1) Get(ctx context.Context, name string, opts m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nodesInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *nodesInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(NodeGKv1())
|
return nil, newNotImplementedError(constants.NodeGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nodesInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *nodesInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(NodeGKv1())
|
return nil, newNotImplementedError(constants.NodeGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nodesInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *nodesInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(NodeGKv1())
|
return nil, newNotImplementedError(constants.NodeGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nodesInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *nodesInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
return nil, newNotImplementedError(NodeGKv1())
|
return nil, newNotImplementedError(constants.NodeGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nodesInspectorAnonymousV1) Delete(ctx context.Context, name string, opts meta.DeleteOptions) error {
|
func (e *nodesInspectorAnonymousV1) Delete(ctx context.Context, name string, opts meta.DeleteOptions) error {
|
||||||
return newNotImplementedError(NodeGKv1())
|
return newNotImplementedError(constants.NodeGKv1())
|
||||||
}
|
}
|
||||||
|
|
43
pkg/deployment/resources/inspector/nodes_gvk.go
Normal file
43
pkg/deployment/resources/inspector/nodes_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *nodesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.NodeGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *nodesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.NodeGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *nodesInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.NodeGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *nodesInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.NodeGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/node/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/node/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ func (p *nodesInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *nodesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Node, error) {
|
func (p *nodesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Node, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(NodeGR(), name)
|
return nil, apiErrors.NewNotFound(constants.NodeGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
|
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ func Test_OwnerRef(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
|
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
|
||||||
obj1 := &core.Service{
|
obj1 := &core.Service{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: "obj1",
|
Name: "obj1",
|
||||||
|
@ -133,7 +134,7 @@ func Test_OwnerRef(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("Owner - infinite loop", func(t *testing.T) {
|
t.Run("Owner - infinite loop", func(t *testing.T) {
|
||||||
s2uid := uuid.NewUUID()
|
s2uid := uuid.NewUUID()
|
||||||
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
|
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
|
||||||
obj4 := &api.ArangoDeployment{
|
obj4 := &api.ArangoDeployment{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: "obj4",
|
Name: "obj4",
|
||||||
|
@ -205,7 +206,7 @@ func Test_OwnerRef(t *testing.T) {
|
||||||
UID: uuid.NewUUID(),
|
UID: uuid.NewUUID(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
|
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
|
||||||
|
|
||||||
last := &core.Service{
|
last := &core.Service{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
|
@ -259,7 +260,7 @@ func Test_OwnerRef(t *testing.T) {
|
||||||
UID: uuid.NewUUID(),
|
UID: uuid.NewUUID(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
|
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
|
||||||
|
|
||||||
last := &core.Service{
|
last := &core.Service{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
|
@ -324,7 +325,7 @@ func clientWithGVK(t *testing.T, obj ...GVKEnsurer) kclient.Client {
|
||||||
|
|
||||||
func ensureGVK(t *testing.T, objs ...GVKEnsurer) {
|
func ensureGVK(t *testing.T, objs ...GVKEnsurer) {
|
||||||
for _, o := range objs {
|
for _, o := range objs {
|
||||||
gvk, ok := ExtractGVKFromObject(o)
|
gvk, ok := constants.ExtractGVKFromObject(o)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
o.SetGroupVersionKind(gvk)
|
o.SetGroupVersionKind(gvk)
|
||||||
|
|
|
@ -24,19 +24,20 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *podDisruptionBudgetsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := PodDisruptionBudgetGK()
|
g := constants.PodDisruptionBudgetGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case PodDisruptionBudgetVersionV1, DefaultVersion:
|
case constants.PodDisruptionBudgetVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return &podDisruptionBudgetsInspectorAnonymousV1{i: p.state}, true
|
return &podDisruptionBudgetsInspectorAnonymousV1{i: p.state}, true
|
||||||
case PodDisruptionBudgetVersionV1Beta1:
|
case constants.PodDisruptionBudgetVersionV1Beta1:
|
||||||
if p.v1beta1 == nil || p.v1beta1.err != nil {
|
if p.v1beta1 == nil || p.v1beta1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
policyv1 "k8s.io/api/policy/v1"
|
policyv1 "k8s.io/api/policy/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type podDisruptionBudgetsInspectorAnonymousV1 struct {
|
type podDisruptionBudgetsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *podDisruptionBudgetsInspectorAnonymousV1) Get(ctx context.Context, name
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*policyv1.PodDisruptionBudget); !ok {
|
if o, ok := obj.(*policyv1.PodDisruptionBudget); !ok {
|
||||||
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1())
|
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PodDisruptionBudgetsModInterface().V1().Create(ctx, o, opts)
|
return e.i.PodDisruptionBudgetsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *podDisruptionBudgetsInspectorAnonymousV1) Create(ctx context.Context, o
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*policyv1.PodDisruptionBudget); !ok {
|
if o, ok := obj.(*policyv1.PodDisruptionBudget); !ok {
|
||||||
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1())
|
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PodDisruptionBudgetsModInterface().V1().Update(ctx, o, opts)
|
return e.i.PodDisruptionBudgetsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(PodDisruptionBudgetGKv1())
|
return nil, newNotImplementedError(constants.PodDisruptionBudgetGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type podDisruptionBudgetsInspectorAnonymousV1Beta1 struct {
|
type podDisruptionBudgetsInspectorAnonymousV1Beta1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Get(ctx context.Context,
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*policyv1beta1.PodDisruptionBudget); !ok {
|
if o, ok := obj.(*policyv1beta1.PodDisruptionBudget); !ok {
|
||||||
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1Beta1())
|
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1Beta1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PodDisruptionBudgetsModInterface().V1Beta1().Create(ctx, o, opts)
|
return e.i.PodDisruptionBudgetsModInterface().V1Beta1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Create(ctx context.Conte
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*policyv1beta1.PodDisruptionBudget); !ok {
|
if o, ok := obj.(*policyv1beta1.PodDisruptionBudget); !ok {
|
||||||
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1Beta1())
|
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1Beta1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PodDisruptionBudgetsModInterface().V1Beta1().Update(ctx, o, opts)
|
return e.i.PodDisruptionBudgetsModInterface().V1Beta1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(PodDisruptionBudgetGKv1Beta1())
|
return nil, newNotImplementedError(constants.PodDisruptionBudgetGKv1Beta1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *podDisruptionBudgetsInspectorAnonymousV1Beta1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
51
pkg/deployment/resources/inspector/pdbs_gvk.go
Normal file
51
pkg/deployment/resources/inspector/pdbs_gvk.go
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *podDisruptionBudgetsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.PodDisruptionBudgetGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podDisruptionBudgetsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.PodDisruptionBudgetGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podDisruptionBudgetsInspectorV1Beta1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.PodDisruptionBudgetGKv1Beta1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podDisruptionBudgetsInspectorV1Beta1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.PodDisruptionBudgetGRv1Beta1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podDisruptionBudgetsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.PodDisruptionBudgetGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podDisruptionBudgetsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.PodDisruptionBudgetGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ func (p *podDisruptionBudgetsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*policyv1.PodDisruptionBudget, error) {
|
func (p *podDisruptionBudgetsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*policyv1.PodDisruptionBudget, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(PodDisruptionBudgetGR(), name)
|
return nil, apiErrors.NewNotFound(constants.PodDisruptionBudgetGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1beta1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ func (p *podDisruptionBudgetsInspectorV1Beta1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspectorV1Beta1) Get(ctx context.Context, name string, opts meta.GetOptions) (*policyv1beta1.PodDisruptionBudget, error) {
|
func (p *podDisruptionBudgetsInspectorV1Beta1) Get(ctx context.Context, name string, opts meta.GetOptions) (*policyv1beta1.PodDisruptionBudget, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(PodDisruptionBudgetGR(), name)
|
return nil, apiErrors.NewNotFound(constants.PodDisruptionBudgetGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *podsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *podsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := PodGK()
|
g := constants.PodGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case PodVersionV1, DefaultVersion:
|
case constants.PodVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type podsInspectorAnonymousV1 struct {
|
type podsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *podsInspectorAnonymousV1) Get(ctx context.Context, name string, opts me
|
||||||
|
|
||||||
func (e *podsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *podsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Pod); !ok {
|
if o, ok := obj.(*core.Pod); !ok {
|
||||||
return nil, newInvalidTypeError(PodGKv1())
|
return nil, newInvalidTypeError(constants.PodGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PodsModInterface().V1().Create(ctx, o, opts)
|
return e.i.PodsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *podsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object,
|
||||||
|
|
||||||
func (e *podsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *podsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Pod); !ok {
|
if o, ok := obj.(*core.Pod); !ok {
|
||||||
return nil, newInvalidTypeError(PodGKv1())
|
return nil, newInvalidTypeError(constants.PodGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PodsModInterface().V1().Update(ctx, o, opts)
|
return e.i.PodsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *podsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *podsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(PodGKv1())
|
return nil, newNotImplementedError(constants.PodGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *podsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *podsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/pods_gvk.go
Normal file
43
pkg/deployment/resources/inspector/pods_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *podsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.PodGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.PodGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.PodGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *podsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.PodGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ func (p *podsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *podsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Pod, error) {
|
func (p *podsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Pod, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(PodGR(), name)
|
return nil, apiErrors.NewNotFound(constants.PodGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *persistentVolumeClaimsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *persistentVolumeClaimsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := PersistentVolumeClaimGK()
|
g := constants.PersistentVolumeClaimGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case PersistentVolumeClaimVersionV1, DefaultVersion:
|
case constants.PersistentVolumeClaimVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type persistentVolumeClaimsInspectorAnonymousV1 struct {
|
type persistentVolumeClaimsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *persistentVolumeClaimsInspectorAnonymousV1) Get(ctx context.Context, na
|
||||||
|
|
||||||
func (e *persistentVolumeClaimsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *persistentVolumeClaimsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.PersistentVolumeClaim); !ok {
|
if o, ok := obj.(*core.PersistentVolumeClaim); !ok {
|
||||||
return nil, newInvalidTypeError(PersistentVolumeClaimGKv1())
|
return nil, newInvalidTypeError(constants.PersistentVolumeClaimGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PersistentVolumeClaimsModInterface().V1().Create(ctx, o, opts)
|
return e.i.PersistentVolumeClaimsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *persistentVolumeClaimsInspectorAnonymousV1) Create(ctx context.Context,
|
||||||
|
|
||||||
func (e *persistentVolumeClaimsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *persistentVolumeClaimsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.PersistentVolumeClaim); !ok {
|
if o, ok := obj.(*core.PersistentVolumeClaim); !ok {
|
||||||
return nil, newInvalidTypeError(PersistentVolumeClaimGKv1())
|
return nil, newInvalidTypeError(constants.PersistentVolumeClaimGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.PersistentVolumeClaimsModInterface().V1().Update(ctx, o, opts)
|
return e.i.PersistentVolumeClaimsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *persistentVolumeClaimsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *persistentVolumeClaimsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(PersistentVolumeClaimGKv1())
|
return nil, newNotImplementedError(constants.PersistentVolumeClaimGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *persistentVolumeClaimsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *persistentVolumeClaimsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/pvcs_gvk.go
Normal file
43
pkg/deployment/resources/inspector/pvcs_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *persistentVolumeClaimsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.PersistentVolumeClaimGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *persistentVolumeClaimsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.PersistentVolumeClaimGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *persistentVolumeClaimsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.PersistentVolumeClaimGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *persistentVolumeClaimsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.PersistentVolumeClaimGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ func (p *persistentVolumeClaimsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *persistentVolumeClaimsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.PersistentVolumeClaim, error) {
|
func (p *persistentVolumeClaimsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.PersistentVolumeClaim, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(PersistentVolumeClaimGR(), name)
|
return nil, apiErrors.NewNotFound(constants.PersistentVolumeClaimGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *serviceAccountsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *serviceAccountsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := ServiceAccountGK()
|
g := constants.ServiceAccountGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case ServiceAccountVersionV1, DefaultVersion:
|
case constants.ServiceAccountVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serviceAccountsInspectorAnonymousV1 struct {
|
type serviceAccountsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *serviceAccountsInspectorAnonymousV1) Get(ctx context.Context, name stri
|
||||||
|
|
||||||
func (e *serviceAccountsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *serviceAccountsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.ServiceAccount); !ok {
|
if o, ok := obj.(*core.ServiceAccount); !ok {
|
||||||
return nil, newInvalidTypeError(ServiceAccountGKv1())
|
return nil, newInvalidTypeError(constants.ServiceAccountGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ServiceAccountsModInterface().V1().Create(ctx, o, opts)
|
return e.i.ServiceAccountsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *serviceAccountsInspectorAnonymousV1) Create(ctx context.Context, obj me
|
||||||
|
|
||||||
func (e *serviceAccountsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *serviceAccountsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.ServiceAccount); !ok {
|
if o, ok := obj.(*core.ServiceAccount); !ok {
|
||||||
return nil, newInvalidTypeError(ServiceAccountGKv1())
|
return nil, newInvalidTypeError(constants.ServiceAccountGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ServiceAccountsModInterface().V1().Update(ctx, o, opts)
|
return e.i.ServiceAccountsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *serviceAccountsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *serviceAccountsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(ServiceAccountGKv1())
|
return nil, newNotImplementedError(constants.ServiceAccountGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *serviceAccountsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *serviceAccountsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/sa_gvk.go
Normal file
43
pkg/deployment/resources/inspector/sa_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *serviceAccountsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.ServiceAccountGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *serviceAccountsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.ServiceAccountGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *serviceAccountsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.ServiceAccountGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *serviceAccountsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.ServiceAccountGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ func (p *serviceAccountsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *serviceAccountsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.ServiceAccount, error) {
|
func (p *serviceAccountsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.ServiceAccount, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(ServiceAccountGR(), name)
|
return nil, apiErrors.NewNotFound(constants.ServiceAccountGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *secretsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *secretsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := SecretGK()
|
g := constants.SecretGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case SecretVersionV1, DefaultVersion:
|
case constants.SecretVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type secretsInspectorAnonymousV1 struct {
|
type secretsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *secretsInspectorAnonymousV1) Get(ctx context.Context, name string, opts
|
||||||
|
|
||||||
func (e *secretsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *secretsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Secret); !ok {
|
if o, ok := obj.(*core.Secret); !ok {
|
||||||
return nil, newInvalidTypeError(SecretGKv1())
|
return nil, newInvalidTypeError(constants.SecretGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.SecretsModInterface().V1().Create(ctx, o, opts)
|
return e.i.SecretsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *secretsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Objec
|
||||||
|
|
||||||
func (e *secretsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *secretsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Secret); !ok {
|
if o, ok := obj.(*core.Secret); !ok {
|
||||||
return nil, newInvalidTypeError(SecretGKv1())
|
return nil, newInvalidTypeError(constants.SecretGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.SecretsModInterface().V1().Update(ctx, o, opts)
|
return e.i.SecretsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *secretsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *secretsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(SecretGKv1())
|
return nil, newNotImplementedError(constants.SecretGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *secretsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *secretsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/secrets_gvk.go
Normal file
43
pkg/deployment/resources/inspector/secrets_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *secretsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.SecretGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *secretsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.SecretGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *secretsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.SecretGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *secretsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.SecretGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ func (p *secretsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *secretsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Secret, error) {
|
func (p *secretsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Secret, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(SecretGR(), name)
|
return nil, apiErrors.NewNotFound(constants.SecretGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *servicesInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *servicesInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := ServiceGK()
|
g := constants.ServiceGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case ServiceVersionV1, DefaultVersion:
|
case constants.ServiceVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type servicesInspectorAnonymousV1 struct {
|
type servicesInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *servicesInspectorAnonymousV1) Get(ctx context.Context, name string, opt
|
||||||
|
|
||||||
func (e *servicesInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *servicesInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Service); !ok {
|
if o, ok := obj.(*core.Service); !ok {
|
||||||
return nil, newInvalidTypeError(ServiceGKv1())
|
return nil, newInvalidTypeError(constants.ServiceGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ServicesModInterface().V1().Create(ctx, o, opts)
|
return e.i.ServicesModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *servicesInspectorAnonymousV1) Create(ctx context.Context, obj meta.Obje
|
||||||
|
|
||||||
func (e *servicesInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *servicesInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*core.Service); !ok {
|
if o, ok := obj.(*core.Service); !ok {
|
||||||
return nil, newInvalidTypeError(ServiceGKv1())
|
return nil, newInvalidTypeError(constants.ServiceGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ServicesModInterface().V1().Update(ctx, o, opts)
|
return e.i.ServicesModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *servicesInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *servicesInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(ServiceGKv1())
|
return nil, newNotImplementedError(constants.ServiceGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *servicesInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *servicesInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/services_gvk.go
Normal file
43
pkg/deployment/resources/inspector/services_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *servicesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.ServiceGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *servicesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.ServiceGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *servicesInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.ServiceGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *servicesInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.ServiceGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ func (p *servicesInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *servicesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Service, error) {
|
func (p *servicesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Service, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(ServiceGR(), name)
|
return nil, apiErrors.NewNotFound(constants.ServiceGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *serviceMonitorsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
func (p *serviceMonitorsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
|
||||||
g := ServiceMonitorGK()
|
g := constants.ServiceMonitorGK()
|
||||||
|
|
||||||
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
if g.Kind == gvk.Kind && g.Group == gvk.Group {
|
||||||
switch gvk.Version {
|
switch gvk.Version {
|
||||||
case ServiceMonitorVersionV1, DefaultVersion:
|
case constants.ServiceMonitorVersionV1, DefaultVersion:
|
||||||
if p.v1 == nil || p.v1.err != nil {
|
if p.v1 == nil || p.v1.err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import (
|
||||||
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serviceMonitorsInspectorAnonymousV1 struct {
|
type serviceMonitorsInspectorAnonymousV1 struct {
|
||||||
|
@ -38,7 +40,7 @@ func (e *serviceMonitorsInspectorAnonymousV1) Get(ctx context.Context, name stri
|
||||||
|
|
||||||
func (e *serviceMonitorsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
func (e *serviceMonitorsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*monitoring.ServiceMonitor); !ok {
|
if o, ok := obj.(*monitoring.ServiceMonitor); !ok {
|
||||||
return nil, newInvalidTypeError(ServiceMonitorGKv1())
|
return nil, newInvalidTypeError(constants.ServiceMonitorGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ServiceMonitorsModInterface().V1().Create(ctx, o, opts)
|
return e.i.ServiceMonitorsModInterface().V1().Create(ctx, o, opts)
|
||||||
}
|
}
|
||||||
|
@ -46,14 +48,14 @@ func (e *serviceMonitorsInspectorAnonymousV1) Create(ctx context.Context, obj me
|
||||||
|
|
||||||
func (e *serviceMonitorsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *serviceMonitorsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
if o, ok := obj.(*monitoring.ServiceMonitor); !ok {
|
if o, ok := obj.(*monitoring.ServiceMonitor); !ok {
|
||||||
return nil, newInvalidTypeError(ServiceMonitorGKv1())
|
return nil, newInvalidTypeError(constants.ServiceMonitorGKv1())
|
||||||
} else {
|
} else {
|
||||||
return e.i.ServiceMonitorsModInterface().V1().Update(ctx, o, opts)
|
return e.i.ServiceMonitorsModInterface().V1().Update(ctx, o, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *serviceMonitorsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
func (e *serviceMonitorsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
|
||||||
return nil, newNotImplementedError(ServiceMonitorGKv1())
|
return nil, newNotImplementedError(constants.ServiceMonitorGKv1())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *serviceMonitorsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
func (e *serviceMonitorsInspectorAnonymousV1) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts meta.PatchOptions, subresources ...string) (result meta.Object, err error) {
|
||||||
|
|
43
pkg/deployment/resources/inspector/sm_gvk.go
Normal file
43
pkg/deployment/resources/inspector/sm_gvk.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package inspector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *serviceMonitorsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
||||||
|
return constants.ServiceMonitorGKv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *serviceMonitorsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
||||||
|
return constants.ServiceMonitorGRv1()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *serviceMonitorsInspector) GroupKind() schema.GroupKind {
|
||||||
|
return constants.ServiceMonitorGK()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *serviceMonitorsInspector) GroupResource() schema.GroupResource {
|
||||||
|
return constants.ServiceMonitorGR()
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import (
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor/v1"
|
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ func (p *serviceMonitorsInspectorV1) Read() ins.ReadInterface {
|
||||||
|
|
||||||
func (p *serviceMonitorsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*monitoring.ServiceMonitor, error) {
|
func (p *serviceMonitorsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*monitoring.ServiceMonitor, error) {
|
||||||
if s, ok := p.GetSimple(name); !ok {
|
if s, ok := p.GetSimple(name); !ok {
|
||||||
return nil, apiErrors.NewNotFound(ServiceMonitorGR(), name)
|
return nil, apiErrors.NewNotFound(constants.ServiceMonitorGR(), name)
|
||||||
} else {
|
} else {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
@ -64,19 +64,3 @@ func ArangoClusterSynchronizationGRv1() schema.GroupVersionResource {
|
||||||
Version: ArangoClusterSynchronizationVersionV1,
|
Version: ArangoClusterSynchronizationVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return ArangoClusterSynchronizationGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return ArangoClusterSynchronizationGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return ArangoClusterSynchronizationGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoClusterSynchronizationsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return ArangoClusterSynchronizationGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
@ -64,19 +64,3 @@ func ArangoMemberGRv1() schema.GroupVersionResource {
|
||||||
Version: ArangoMemberVersionV1,
|
Version: ArangoMemberVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *arangoMembersInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return ArangoMemberGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoMembersInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return ArangoMemberGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoMembersInspector) GroupKind() schema.GroupKind {
|
|
||||||
return ArangoMemberGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoMembersInspector) GroupResource() schema.GroupResource {
|
|
||||||
return ArangoMemberGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
@ -64,19 +64,3 @@ func ArangoTaskGRv1() schema.GroupVersionResource {
|
||||||
Version: ArangoTaskVersionV1,
|
Version: ArangoTaskVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *arangoTasksInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return ArangoTaskGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoTasksInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return ArangoTaskGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoTasksInspector) GroupKind() schema.GroupKind {
|
|
||||||
return ArangoTaskGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *arangoTasksInspector) GroupResource() schema.GroupResource {
|
|
||||||
return ArangoTaskGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func EndpointsGRv1() schema.GroupVersionResource {
|
||||||
Version: EndpointsVersionV1,
|
Version: EndpointsVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *endpointsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return EndpointsGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *endpointsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return EndpointsGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *endpointsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return EndpointsGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *endpointsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return EndpointsGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func NodeGRv1() schema.GroupVersionResource {
|
||||||
Version: NodeVersionV1,
|
Version: NodeVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *nodesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return NodeGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *nodesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return NodeGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *nodesInspector) GroupKind() schema.GroupKind {
|
|
||||||
return NodeGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *nodesInspector) GroupResource() schema.GroupResource {
|
|
||||||
return NodeGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
policyv1 "k8s.io/api/policy/v1"
|
policyv1 "k8s.io/api/policy/v1"
|
||||||
|
@ -79,27 +79,3 @@ func PodDisruptionBudgetGRv1Beta1() schema.GroupVersionResource {
|
||||||
Version: PodDisruptionBudgetVersionV1Beta1,
|
Version: PodDisruptionBudgetVersionV1Beta1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return PodDisruptionBudgetGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return PodDisruptionBudgetGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspectorV1Beta1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return PodDisruptionBudgetGKv1Beta1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspectorV1Beta1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return PodDisruptionBudgetGRv1Beta1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return PodDisruptionBudgetGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podDisruptionBudgetsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return PodDisruptionBudgetGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func PodGRv1() schema.GroupVersionResource {
|
||||||
Version: PodVersionV1,
|
Version: PodVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *podsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return PodGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return PodGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return PodGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *podsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return PodGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func PersistentVolumeClaimGRv1() schema.GroupVersionResource {
|
||||||
Version: PersistentVolumeClaimVersionV1,
|
Version: PersistentVolumeClaimVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *persistentVolumeClaimsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return PersistentVolumeClaimGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *persistentVolumeClaimsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return PersistentVolumeClaimGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *persistentVolumeClaimsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return PersistentVolumeClaimGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *persistentVolumeClaimsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return PersistentVolumeClaimGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func ServiceAccountGRv1() schema.GroupVersionResource {
|
||||||
Version: ServiceAccountVersionV1,
|
Version: ServiceAccountVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *serviceAccountsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return ServiceAccountGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *serviceAccountsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return ServiceAccountGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *serviceAccountsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return ServiceAccountGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *serviceAccountsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return ServiceAccountGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func SecretGRv1() schema.GroupVersionResource {
|
||||||
Version: SecretVersionV1,
|
Version: SecretVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *secretsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return SecretGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *secretsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return SecretGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *secretsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return SecretGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *secretsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return SecretGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
|
@ -62,19 +62,3 @@ func ServiceGRv1() schema.GroupVersionResource {
|
||||||
Version: ServiceVersionV1,
|
Version: ServiceVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *servicesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return ServiceGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *servicesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return ServiceGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *servicesInspector) GroupKind() schema.GroupKind {
|
|
||||||
return ServiceGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *servicesInspector) GroupResource() schema.GroupResource {
|
|
||||||
return ServiceGR()
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
|
|
||||||
package inspector
|
package constants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring"
|
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring"
|
||||||
|
@ -62,19 +62,3 @@ func ServiceMonitorGRv1() schema.GroupVersionResource {
|
||||||
Version: ServiceMonitorVersionV1,
|
Version: ServiceMonitorVersionV1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *serviceMonitorsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
|
|
||||||
return ServiceMonitorGKv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *serviceMonitorsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
|
|
||||||
return ServiceMonitorGRv1()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *serviceMonitorsInspector) GroupKind() schema.GroupKind {
|
|
||||||
return ServiceMonitorGK()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *serviceMonitorsInspector) GroupResource() schema.GroupResource {
|
|
||||||
return ServiceMonitorGR()
|
|
||||||
}
|
|
84
pkg/util/k8sutil/kerrors/resources.go
Normal file
84
pkg/util/k8sutil/kerrors/resources.go
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License 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.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package kerrors
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewResourceError(cause error, obj interface{}) error {
|
||||||
|
if cause == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if gvk, ok := constants.ExtractGVKFromObject(obj); !ok {
|
||||||
|
return cause
|
||||||
|
} else {
|
||||||
|
if meta, ok := obj.(meta.Object); ok {
|
||||||
|
return ResourceError{
|
||||||
|
GVK: gvk,
|
||||||
|
Namespace: meta.GetNamespace(),
|
||||||
|
Name: meta.GetName(),
|
||||||
|
cause: cause,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ResourceError{
|
||||||
|
GVK: gvk,
|
||||||
|
cause: cause,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceError struct {
|
||||||
|
GVK schema.GroupVersionKind
|
||||||
|
|
||||||
|
Namespace, Name string
|
||||||
|
|
||||||
|
cause error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r ResourceError) Cause() error { return r.cause }
|
||||||
|
func (r ResourceError) Unwrap() error { return r.cause }
|
||||||
|
|
||||||
|
func (r ResourceError) Error() string {
|
||||||
|
gvk := r.GVK.String()
|
||||||
|
if r.GVK.Empty() {
|
||||||
|
gvk = "UNKNOWN"
|
||||||
|
}
|
||||||
|
|
||||||
|
n := fmt.Sprintf("%s/%s", r.Namespace, r.Name)
|
||||||
|
if r.Namespace == "" {
|
||||||
|
n = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
cause := "Unknown"
|
||||||
|
if e := r.cause; e != nil {
|
||||||
|
cause = e.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("Resource [%s] %s: %s", gvk, n, cause)
|
||||||
|
}
|
Loading…
Reference in a new issue