1
0
Fork 0
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:
Adam Janikowski 2022-11-23 13:57:29 +01:00 committed by GitHub
parent 565da298f1
commit b0bd486eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 757 additions and 299 deletions

View file

@ -27,6 +27,7 @@
- (Improvement) Add Anonymous Inspector mods
- (Improvement) Do not check checksums for DeploymentReplicationStatus.IncomingSynchronization field values
- (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)
- (Feature) Add action progress

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *arangoClusterSynchronizationsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ArangoClusterSynchronizationGK()
g := constants.ArangoClusterSynchronizationGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ArangoClusterSynchronizationVersionV1, DefaultVersion:
case constants.ArangoClusterSynchronizationVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
} else {
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) {
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
} else {
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) {
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
} else {
return e.i.ArangoClusterSynchronizationModInterface().V1().UpdateStatus(ctx, o, opts)
}

View 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()
}

View file

@ -29,6 +29,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
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) {
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(ArangoClusterSynchronizationGR(), name)
return nil, apiErrors.NewNotFound(constants.ArangoClusterSynchronizationGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *arangoMembersInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ArangoMemberGK()
g := constants.ArangoMemberGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ArangoMemberVersionV1, DefaultVersion:
case constants.ArangoMemberVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*api.ArangoMember); !ok {
return nil, newInvalidTypeError(ArangoMemberGKv1())
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
} else {
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) {
if o, ok := obj.(*api.ArangoMember); !ok {
return nil, newInvalidTypeError(ArangoMemberGKv1())
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
} else {
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) {
if o, ok := obj.(*api.ArangoMember); !ok {
return nil, newInvalidTypeError(ArangoMemberGKv1())
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
} else {
return e.i.ArangoMemberModInterface().V1().UpdateStatus(ctx, o, opts)
}

View 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()
}

View file

@ -29,6 +29,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
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 {
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(ArangoMemberGR(), name)
return nil, apiErrors.NewNotFound(constants.ArangoMemberGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *arangoTasksInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ArangoTaskGK()
g := constants.ArangoTaskGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ArangoTaskVersionV1, DefaultVersion:
case constants.ArangoTaskVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*api.ArangoTask); !ok {
return nil, newInvalidTypeError(ArangoTaskGKv1())
return nil, newInvalidTypeError(constants.ArangoTaskGKv1())
} else {
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) {
if o, ok := obj.(*api.ArangoTask); !ok {
return nil, newInvalidTypeError(ArangoTaskGKv1())
return nil, newInvalidTypeError(constants.ArangoTaskGKv1())
} else {
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) {
if o, ok := obj.(*api.ArangoTask); !ok {
return nil, newInvalidTypeError(ArangoTaskGKv1())
return nil, newInvalidTypeError(constants.ArangoTaskGKv1())
} else {
return e.i.ArangoTaskModInterface().V1().UpdateStatus(ctx, o, opts)
}

View 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()
}

View file

@ -29,6 +29,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
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) {
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(ArangoTaskGR(), name)
return nil, apiErrors.NewNotFound(constants.ArangoTaskGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *endpointsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := EndpointsGK()
g := constants.EndpointsGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case EndpointsVersionV1, DefaultVersion:
case constants.EndpointsVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*core.Endpoints); !ok {
return nil, newInvalidTypeError(EndpointsGKv1())
return nil, newInvalidTypeError(constants.EndpointsGKv1())
} else {
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) {
if o, ok := obj.(*core.Endpoints); !ok {
return nil, newInvalidTypeError(EndpointsGKv1())
return nil, newInvalidTypeError(constants.EndpointsGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(EndpointsGR(), name)
return nil, apiErrors.NewNotFound(constants.EndpointsGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *nodesInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := NodeGK()
g := constants.NodeGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case NodeVersionV1, DefaultVersion:
case constants.NodeVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -25,6 +25,8 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
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) {
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) {
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) {
return nil, newNotImplementedError(NodeGKv1())
return nil, newNotImplementedError(constants.NodeGKv1())
}
func (e *nodesInspectorAnonymousV1) Delete(ctx context.Context, name string, opts meta.DeleteOptions) error {
return newNotImplementedError(NodeGKv1())
return newNotImplementedError(constants.NodeGKv1())
}

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(NodeGR(), name)
return nil, apiErrors.NewNotFound(constants.NodeGR(), name)
} else {
return s, nil
}

View file

@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
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"
)
@ -106,7 +107,7 @@ func Test_OwnerRef(t *testing.T) {
},
},
}
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
obj1 := &core.Service{
ObjectMeta: meta.ObjectMeta{
Name: "obj1",
@ -133,7 +134,7 @@ func Test_OwnerRef(t *testing.T) {
})
t.Run("Owner - infinite loop", func(t *testing.T) {
s2uid := uuid.NewUUID()
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
obj4 := &api.ArangoDeployment{
ObjectMeta: meta.ObjectMeta{
Name: "obj4",
@ -205,7 +206,7 @@ func Test_OwnerRef(t *testing.T) {
UID: uuid.NewUUID(),
},
}
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
last := &core.Service{
ObjectMeta: meta.ObjectMeta{
@ -259,7 +260,7 @@ func Test_OwnerRef(t *testing.T) {
UID: uuid.NewUUID(),
},
}
sapi, skind := ServiceGKv1().ToAPIVersionAndKind()
sapi, skind := constants.ServiceGKv1().ToAPIVersionAndKind()
last := &core.Service{
ObjectMeta: meta.ObjectMeta{
@ -324,7 +325,7 @@ func clientWithGVK(t *testing.T, obj ...GVKEnsurer) kclient.Client {
func ensureGVK(t *testing.T, objs ...GVKEnsurer) {
for _, o := range objs {
gvk, ok := ExtractGVKFromObject(o)
gvk, ok := constants.ExtractGVKFromObject(o)
require.True(t, ok)
o.SetGroupVersionKind(gvk)

View file

@ -24,19 +24,20 @@ import (
"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/constants"
)
func (p *podDisruptionBudgetsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := PodDisruptionBudgetGK()
g := constants.PodDisruptionBudgetGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case PodDisruptionBudgetVersionV1, DefaultVersion:
case constants.PodDisruptionBudgetVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}
return &podDisruptionBudgetsInspectorAnonymousV1{i: p.state}, true
case PodDisruptionBudgetVersionV1Beta1:
case constants.PodDisruptionBudgetVersionV1Beta1:
if p.v1beta1 == nil || p.v1beta1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
policyv1 "k8s.io/api/policy/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*policyv1.PodDisruptionBudget); !ok {
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1())
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1())
} else {
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) {
if o, ok := obj.(*policyv1.PodDisruptionBudget); !ok {
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1())
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1())
} else {
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) {
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) {

View file

@ -26,6 +26,8 @@ import (
policyv1beta1 "k8s.io/api/policy/v1beta1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*policyv1beta1.PodDisruptionBudget); !ok {
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1Beta1())
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1Beta1())
} else {
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) {
if o, ok := obj.(*policyv1beta1.PodDisruptionBudget); !ok {
return nil, newInvalidTypeError(PodDisruptionBudgetGKv1Beta1())
return nil, newInvalidTypeError(constants.PodDisruptionBudgetGKv1Beta1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(PodDisruptionBudgetGR(), name)
return nil, apiErrors.NewNotFound(constants.PodDisruptionBudgetGR(), name)
} else {
return s, nil
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(PodDisruptionBudgetGR(), name)
return nil, apiErrors.NewNotFound(constants.PodDisruptionBudgetGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *podsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := PodGK()
g := constants.PodGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case PodVersionV1, DefaultVersion:
case constants.PodVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*core.Pod); !ok {
return nil, newInvalidTypeError(PodGKv1())
return nil, newInvalidTypeError(constants.PodGKv1())
} else {
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) {
if o, ok := obj.(*core.Pod); !ok {
return nil, newInvalidTypeError(PodGKv1())
return nil, newInvalidTypeError(constants.PodGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(PodGR(), name)
return nil, apiErrors.NewNotFound(constants.PodGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *persistentVolumeClaimsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := PersistentVolumeClaimGK()
g := constants.PersistentVolumeClaimGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case PersistentVolumeClaimVersionV1, DefaultVersion:
case constants.PersistentVolumeClaimVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*core.PersistentVolumeClaim); !ok {
return nil, newInvalidTypeError(PersistentVolumeClaimGKv1())
return nil, newInvalidTypeError(constants.PersistentVolumeClaimGKv1())
} else {
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) {
if o, ok := obj.(*core.PersistentVolumeClaim); !ok {
return nil, newInvalidTypeError(PersistentVolumeClaimGKv1())
return nil, newInvalidTypeError(constants.PersistentVolumeClaimGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(PersistentVolumeClaimGR(), name)
return nil, apiErrors.NewNotFound(constants.PersistentVolumeClaimGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *serviceAccountsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ServiceAccountGK()
g := constants.ServiceAccountGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ServiceAccountVersionV1, DefaultVersion:
case constants.ServiceAccountVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*core.ServiceAccount); !ok {
return nil, newInvalidTypeError(ServiceAccountGKv1())
return nil, newInvalidTypeError(constants.ServiceAccountGKv1())
} else {
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) {
if o, ok := obj.(*core.ServiceAccount); !ok {
return nil, newInvalidTypeError(ServiceAccountGKv1())
return nil, newInvalidTypeError(constants.ServiceAccountGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(ServiceAccountGR(), name)
return nil, apiErrors.NewNotFound(constants.ServiceAccountGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *secretsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := SecretGK()
g := constants.SecretGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case SecretVersionV1, DefaultVersion:
case constants.SecretVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*core.Secret); !ok {
return nil, newInvalidTypeError(SecretGKv1())
return nil, newInvalidTypeError(constants.SecretGKv1())
} else {
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) {
if o, ok := obj.(*core.Secret); !ok {
return nil, newInvalidTypeError(SecretGKv1())
return nil, newInvalidTypeError(constants.SecretGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(SecretGR(), name)
return nil, apiErrors.NewNotFound(constants.SecretGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *servicesInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ServiceGK()
g := constants.ServiceGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ServiceVersionV1, DefaultVersion:
case constants.ServiceVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*core.Service); !ok {
return nil, newInvalidTypeError(ServiceGKv1())
return nil, newInvalidTypeError(constants.ServiceGKv1())
} else {
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) {
if o, ok := obj.(*core.Service); !ok {
return nil, newInvalidTypeError(ServiceGKv1())
return nil, newInvalidTypeError(constants.ServiceGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(ServiceGR(), name)
return nil, apiErrors.NewNotFound(constants.ServiceGR(), name)
} else {
return s, nil
}

View file

@ -24,14 +24,15 @@ import (
"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/constants"
)
func (p *serviceMonitorsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ServiceMonitorGK()
g := constants.ServiceMonitorGK()
if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ServiceMonitorVersionV1, DefaultVersion:
case constants.ServiceMonitorVersionV1, DefaultVersion:
if p.v1 == nil || p.v1.err != nil {
return nil, false
}

View file

@ -26,6 +26,8 @@ import (
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
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) {
if o, ok := obj.(*monitoring.ServiceMonitor); !ok {
return nil, newInvalidTypeError(ServiceMonitorGKv1())
return nil, newInvalidTypeError(constants.ServiceMonitorGKv1())
} else {
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) {
if o, ok := obj.(*monitoring.ServiceMonitor); !ok {
return nil, newInvalidTypeError(ServiceMonitorGKv1())
return nil, newInvalidTypeError(constants.ServiceMonitorGKv1())
} else {
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) {
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) {

View 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()
}

View file

@ -28,6 +28,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -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) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(ServiceMonitorGR(), name)
return nil, apiErrors.NewNotFound(constants.ServiceMonitorGR(), name)
} else {
return s, nil
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
"k8s.io/apimachinery/pkg/runtime/schema"
@ -64,19 +64,3 @@ func ArangoClusterSynchronizationGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
"k8s.io/apimachinery/pkg/runtime/schema"

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
"k8s.io/apimachinery/pkg/runtime/schema"
@ -64,19 +64,3 @@ func ArangoMemberGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
"k8s.io/apimachinery/pkg/runtime/schema"
@ -64,19 +64,3 @@ func ArangoTaskGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func EndpointsGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
"reflect"

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func NodeGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
policyv1 "k8s.io/api/policy/v1"
@ -79,27 +79,3 @@ func PodDisruptionBudgetGRv1Beta1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func PodGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func PersistentVolumeClaimGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func ServiceAccountGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func SecretGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
core "k8s.io/api/core/v1"
@ -62,19 +62,3 @@ func ServiceGRv1() schema.GroupVersionResource {
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()
}

View file

@ -18,7 +18,7 @@
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
package constants
import (
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring"
@ -62,19 +62,3 @@ func ServiceMonitorGRv1() schema.GroupVersionResource {
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()
}

View 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)
}