Skip to content

Commit b0bd486

Browse files
authored
[Improvement] Add Resource kerror Type (#1192)
1 parent 565da29 commit b0bd486

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+757
-299
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- (Improvement) Add Anonymous Inspector mods
2828
- (Improvement) Do not check checksums for DeploymentReplicationStatus.IncomingSynchronization field values
2929
- (Improvement) Add ServerGroup details into ServerGroupSpec
30+
- (Improvement) Add Resource kerror Type
3031

3132
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
3233
- (Feature) Add action progress

pkg/deployment/resources/inspector/acs_anonymous.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ import (
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525

2626
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
27+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
2728
)
2829

2930
func (p *arangoClusterSynchronizationsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
30-
g := ArangoClusterSynchronizationGK()
31+
g := constants.ArangoClusterSynchronizationGK()
3132

3233
if g.Kind == gvk.Kind && g.Group == gvk.Group {
3334
switch gvk.Version {
34-
case ArangoClusterSynchronizationVersionV1, DefaultVersion:
35+
case constants.ArangoClusterSynchronizationVersionV1, DefaultVersion:
3536
if p.v1 == nil || p.v1.err != nil {
3637
return nil, false
3738
}

pkg/deployment/resources/inspector/acs_anonymous_v1.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/apimachinery/pkg/types"
2828

2929
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
30+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
3031
)
3132

3233
type arangoClusterSynchronizationsInspectorAnonymousV1 struct {
@@ -39,23 +40,23 @@ func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Get(ctx context.Cont
3940

4041
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
4142
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
42-
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
43+
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
4344
} else {
4445
return e.i.ArangoClusterSynchronizationModInterface().V1().Create(ctx, o, opts)
4546
}
4647
}
4748

4849
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
4950
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
50-
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
51+
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
5152
} else {
5253
return e.i.ArangoClusterSynchronizationModInterface().V1().Update(ctx, o, opts)
5354
}
5455
}
5556

5657
func (e *arangoClusterSynchronizationsInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
5758
if o, ok := obj.(*api.ArangoClusterSynchronization); !ok {
58-
return nil, newInvalidTypeError(ArangoClusterSynchronizationGKv1())
59+
return nil, newInvalidTypeError(constants.ArangoClusterSynchronizationGKv1())
5960
} else {
6061
return e.i.ArangoClusterSynchronizationModInterface().V1().UpdateStatus(ctx, o, opts)
6162
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package inspector
22+
23+
import (
24+
"k8s.io/apimachinery/pkg/runtime/schema"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
27+
)
28+
29+
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
30+
return constants.ArangoClusterSynchronizationGKv1()
31+
}
32+
33+
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
34+
return constants.ArangoClusterSynchronizationGRv1()
35+
}
36+
37+
func (p *arangoClusterSynchronizationsInspector) GroupKind() schema.GroupKind {
38+
return constants.ArangoClusterSynchronizationGK()
39+
}
40+
41+
func (p *arangoClusterSynchronizationsInspector) GroupResource() schema.GroupResource {
42+
return constants.ArangoClusterSynchronizationGR()
43+
}

pkg/deployment/resources/inspector/acs_v1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3030
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3131
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoclustersynchronization/v1"
32+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
3233
)
3334

3435
func (p *arangoClusterSynchronizationsInspector) V1() (ins.Inspector, error) {
@@ -130,7 +131,7 @@ func (p *arangoClusterSynchronizationsInspectorV1) Read() ins.ReadInterface {
130131

131132
func (p *arangoClusterSynchronizationsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoClusterSynchronization, error) {
132133
if s, ok := p.GetSimple(name); !ok {
133-
return nil, apiErrors.NewNotFound(ArangoClusterSynchronizationGR(), name)
134+
return nil, apiErrors.NewNotFound(constants.ArangoClusterSynchronizationGR(), name)
134135
} else {
135136
return s, nil
136137
}

pkg/deployment/resources/inspector/am_anonymous.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ import (
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525

2626
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
27+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
2728
)
2829

2930
func (p *arangoMembersInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
30-
g := ArangoMemberGK()
31+
g := constants.ArangoMemberGK()
3132

3233
if g.Kind == gvk.Kind && g.Group == gvk.Group {
3334
switch gvk.Version {
34-
case ArangoMemberVersionV1, DefaultVersion:
35+
case constants.ArangoMemberVersionV1, DefaultVersion:
3536
if p.v1 == nil || p.v1.err != nil {
3637
return nil, false
3738
}

pkg/deployment/resources/inspector/am_anonymous_v1.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/apimachinery/pkg/types"
2828

2929
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
30+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
3031
)
3132

3233
type arangoMembersInspectorAnonymousV1 struct {
@@ -39,23 +40,23 @@ func (e *arangoMembersInspectorAnonymousV1) Get(ctx context.Context, name string
3940

4041
func (e *arangoMembersInspectorAnonymousV1) Create(ctx context.Context, obj meta.Object, opts meta.CreateOptions) (meta.Object, error) {
4142
if o, ok := obj.(*api.ArangoMember); !ok {
42-
return nil, newInvalidTypeError(ArangoMemberGKv1())
43+
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
4344
} else {
4445
return e.i.ArangoMemberModInterface().V1().Create(ctx, o, opts)
4546
}
4647
}
4748

4849
func (e *arangoMembersInspectorAnonymousV1) Update(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
4950
if o, ok := obj.(*api.ArangoMember); !ok {
50-
return nil, newInvalidTypeError(ArangoMemberGKv1())
51+
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
5152
} else {
5253
return e.i.ArangoMemberModInterface().V1().Update(ctx, o, opts)
5354
}
5455
}
5556

5657
func (e *arangoMembersInspectorAnonymousV1) UpdateStatus(ctx context.Context, obj meta.Object, opts meta.UpdateOptions) (meta.Object, error) {
5758
if o, ok := obj.(*api.ArangoMember); !ok {
58-
return nil, newInvalidTypeError(ArangoMemberGKv1())
59+
return nil, newInvalidTypeError(constants.ArangoMemberGKv1())
5960
} else {
6061
return e.i.ArangoMemberModInterface().V1().UpdateStatus(ctx, o, opts)
6162
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package inspector
22+
23+
import (
24+
"k8s.io/apimachinery/pkg/runtime/schema"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
27+
)
28+
29+
func (p *arangoMembersInspectorV1) GroupVersionKind() schema.GroupVersionKind {
30+
return constants.ArangoMemberGKv1()
31+
}
32+
33+
func (p *arangoMembersInspectorV1) GroupVersionResource() schema.GroupVersionResource {
34+
return constants.ArangoMemberGRv1()
35+
}
36+
37+
func (p *arangoMembersInspector) GroupKind() schema.GroupKind {
38+
return constants.ArangoMemberGK()
39+
}
40+
41+
func (p *arangoMembersInspector) GroupResource() schema.GroupResource {
42+
return constants.ArangoMemberGR()
43+
}

pkg/deployment/resources/inspector/am_v1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3030
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3131
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
32+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
3233
)
3334

3435
func (p *arangoMembersInspector) V1() ins.Inspector {
@@ -110,7 +111,7 @@ func (p *arangoMembersInspectorV1) Read() ins.ReadInterface {
110111

111112
func (p *arangoMembersInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoMember, error) {
112113
if s, ok := p.GetSimple(name); !ok {
113-
return nil, apiErrors.NewNotFound(ArangoMemberGR(), name)
114+
return nil, apiErrors.NewNotFound(constants.ArangoMemberGR(), name)
114115
} else {
115116
return s, nil
116117
}

pkg/deployment/resources/inspector/at_anonymous.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ import (
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525

2626
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
27+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
2728
)
2829

2930
func (p *arangoTasksInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
30-
g := ArangoTaskGK()
31+
g := constants.ArangoTaskGK()
3132

3233
if g.Kind == gvk.Kind && g.Group == gvk.Group {
3334
switch gvk.Version {
34-
case ArangoTaskVersionV1, DefaultVersion:
35+
case constants.ArangoTaskVersionV1, DefaultVersion:
3536
if p.v1 == nil || p.v1.err != nil {
3637
return nil, false
3738
}

0 commit comments

Comments
 (0)