Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- (Feature) Add CoreV1 Endpoints Inspector
- (Feature) Add Current ArangoDeployment Inspector
- (Refactor) Anonymous inspector functions

## [1.2.11](https://github.com/arangodb/kube-arangodb/tree/1.2.11) (2022-04-30)
- (Bugfix) Orphan PVC are not removed
Expand Down
4 changes: 2 additions & 2 deletions pkg/deployment/resources/certificates_client_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

"github.com/rs/zerolog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"

certificates "github.com/arangodb-helper/go-certificates"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
Expand All @@ -41,7 +41,7 @@ const (

// createClientAuthCACertificate creates a client authentication CA certificate and stores it in a secret with name
// specified in the given spec.
func createClientAuthCACertificate(ctx context.Context, log zerolog.Logger, secrets secretv1.ModInterface, spec api.SyncAuthenticationSpec, deploymentName string, ownerRef *metav1.OwnerReference) error {
func createClientAuthCACertificate(ctx context.Context, log zerolog.Logger, secrets secretv1.ModInterface, spec api.SyncAuthenticationSpec, deploymentName string, ownerRef *meta.OwnerReference) error {
log = log.With().Str("secret", spec.GetClientCASecretName()).Logger()
options := certificates.CreateCertificateOptions{
CommonName: fmt.Sprintf("%s Client Authentication Root Certificate", deploymentName),
Expand Down
6 changes: 3 additions & 3 deletions pkg/deployment/resources/certificates_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/rs/zerolog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
Expand All @@ -49,7 +49,7 @@ const (
// createTLSCACertificate creates a CA certificate and stores it in a secret with name
// specified in the given spec.
func createTLSCACertificate(ctx context.Context, log zerolog.Logger, secrets secretv1.ModInterface, spec api.TLSSpec,
deploymentName string, ownerRef *metav1.OwnerReference) error {
deploymentName string, ownerRef *meta.OwnerReference) error {
log = log.With().Str("secret", spec.GetCASecretName()).Logger()

options := certificates.CreateCertificateOptions{
Expand Down Expand Up @@ -79,7 +79,7 @@ func createTLSCACertificate(ctx context.Context, log zerolog.Logger, secrets sec
// createTLSServerCertificate creates a TLS certificate for a specific server and stores
// it in a secret with the given name.
func createTLSServerCertificate(ctx context.Context, log zerolog.Logger, cachedStatus inspectorInterface.Inspector, secrets secretv1.ModInterface, names tls.KeyfileInput, spec api.TLSSpec,
secretName string, ownerRef *metav1.OwnerReference) (bool, error) {
secretName string, ownerRef *meta.OwnerReference) (bool, error) {
log = log.With().Str("secret", secretName).Logger()
// Load CA certificate
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
Expand Down
39 changes: 39 additions & 0 deletions pkg/deployment/resources/inspector/acs_anonymous.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// 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 (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
"k8s.io/apimachinery/pkg/runtime/schema"
)

func (p *arangoClusterSynchronizationsInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ArangoClusterSynchronizationGK()

if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ArangoClusterSynchronizationVersionV1:
return &arangoClusterSynchronizationsInspectorAnonymousV1{i: p.v1}, true
}
}

return nil, false
}
35 changes: 35 additions & 0 deletions pkg/deployment/resources/inspector/acs_anonymous_v1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 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 (
"context"

meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type arangoClusterSynchronizationsInspectorAnonymousV1 struct {
i *arangoClusterSynchronizationsInspectorV1
}

func (e *arangoClusterSynchronizationsInspectorAnonymousV1) Get(ctx context.Context, name string, opts meta.GetOptions) (meta.Object, error) {
return e.i.Get(ctx, name, opts)
}
81 changes: 81 additions & 0 deletions pkg/deployment/resources/inspector/acs_constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// 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 (
"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// ArangoClusterSynchronization
const (
ArangoClusterSynchronizationGroup = deployment.ArangoDeploymentGroupName
ArangoClusterSynchronizationResource = deployment.ArangoClusterSynchronizationResourcePlural
ArangoClusterSynchronizationKind = deployment.ArangoClusterSynchronizationResourceKind
ArangoClusterSynchronizationVersionV1 = deploymentv1.ArangoDeploymentVersion
)

func ArangoClusterSynchronizationGK() schema.GroupKind {
return schema.GroupKind{
Group: ArangoClusterSynchronizationGroup,
Kind: ArangoClusterSynchronizationKind,
}
}

func ArangoClusterSynchronizationGKv1() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: ArangoClusterSynchronizationGroup,
Kind: ArangoClusterSynchronizationKind,
Version: ArangoClusterSynchronizationVersionV1,
}
}

func ArangoClusterSynchronizationGR() schema.GroupResource {
return schema.GroupResource{
Group: ArangoClusterSynchronizationGroup,
Resource: ArangoClusterSynchronizationResource,
}
}

func ArangoClusterSynchronizationGRv1() schema.GroupVersionResource {
return schema.GroupVersionResource{
Group: ArangoClusterSynchronizationGroup,
Resource: ArangoClusterSynchronizationResource,
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()
}
11 changes: 3 additions & 8 deletions pkg/deployment/resources/inspector/acs_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ package inspector
import (
"context"

"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
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"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func (p *arangoClusterSynchronizationsInspector) V1() (ins.Inspector, error) {
Expand Down Expand Up @@ -129,12 +127,9 @@ func (p *arangoClusterSynchronizationsInspectorV1) Read() ins.ReadInterface {
return p
}

func (p *arangoClusterSynchronizationsInspectorV1) Get(ctx context.Context, name string, opts metav1.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 {
return nil, apiErrors.NewNotFound(schema.GroupResource{
Group: deployment.ArangoDeploymentGroupName,
Resource: deployment.ArangoClusterSynchronizationResourcePlural,
}, name)
return nil, apiErrors.NewNotFound(ArangoClusterSynchronizationGR(), name)
} else {
return s, nil
}
Expand Down
39 changes: 39 additions & 0 deletions pkg/deployment/resources/inspector/am_anonymous.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// 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 (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/anonymous"
"k8s.io/apimachinery/pkg/runtime/schema"
)

func (p *arangoMembersInspector) Anonymous(gvk schema.GroupVersionKind) (anonymous.Interface, bool) {
g := ArangoMemberGK()

if g.Kind == gvk.Kind && g.Group == gvk.Group {
switch gvk.Version {
case ArangoMemberVersionV1:
return &arangoMembersInspectorAnonymousV1{i: p.v1}, true
}
}

return nil, false
}
35 changes: 35 additions & 0 deletions pkg/deployment/resources/inspector/am_anonymous_v1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 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 (
"context"

meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type arangoMembersInspectorAnonymousV1 struct {
i *arangoMembersInspectorV1
}

func (e *arangoMembersInspectorAnonymousV1) Get(ctx context.Context, name string, opts meta.GetOptions) (meta.Object, error) {
return e.i.Get(ctx, name, opts)
}
81 changes: 81 additions & 0 deletions pkg/deployment/resources/inspector/am_constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// 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 (
"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// ArangoMember
const (
ArangoMemberGroup = deployment.ArangoDeploymentGroupName
ArangoMemberResource = deployment.ArangoMemberResourcePlural
ArangoMemberKind = deployment.ArangoMemberResourceKind
ArangoMemberVersionV1 = deploymentv1.ArangoDeploymentVersion
)

func ArangoMemberGK() schema.GroupKind {
return schema.GroupKind{
Group: ArangoMemberGroup,
Kind: ArangoMemberKind,
}
}

func ArangoMemberGKv1() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: ArangoMemberGroup,
Kind: ArangoMemberKind,
Version: ArangoMemberVersionV1,
}
}

func ArangoMemberGR() schema.GroupResource {
return schema.GroupResource{
Group: ArangoMemberGroup,
Resource: ArangoMemberResource,
}
}

func ArangoMemberGRv1() schema.GroupVersionResource {
return schema.GroupVersionResource{
Group: ArangoMemberGroup,
Resource: ArangoMemberResource,
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()
}
Loading