mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-15 17:51:03 +00:00
72 lines
2.4 KiB
Go
72 lines
2.4 KiB
Go
//
|
|
// DISCLAIMER
|
|
//
|
|
// Copyright 2018 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
|
|
//
|
|
// Author Ewout Prangsma
|
|
//
|
|
|
|
package v1alpha
|
|
|
|
import (
|
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// EndpointTLSSpec contains the specification regarding the TLS connection to the syncmasters
|
|
// in either source or destination endpoint.
|
|
type EndpointTLSSpec struct {
|
|
// CASecretName holds the name of a Secret containing a ca.crt public key for TLS validation.
|
|
CASecretName *string `json:"caSecretName,omitempty"`
|
|
}
|
|
|
|
// GetCASecretName returns the value of caSecretName.
|
|
func (s EndpointTLSSpec) GetCASecretName() string {
|
|
return util.StringOrDefault(s.CASecretName)
|
|
}
|
|
|
|
// Validate the given spec, returning an error on validation
|
|
// problems or nil if all ok.
|
|
func (s EndpointTLSSpec) Validate(caSecretNameRequired bool) error {
|
|
if err := k8sutil.ValidateOptionalResourceName(s.GetCASecretName()); err != nil {
|
|
return maskAny(err)
|
|
}
|
|
if caSecretNameRequired && s.GetCASecretName() == "" {
|
|
return maskAny(errors.Wrapf(ValidationError, "Provide a caSecretName"))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetDefaults fills empty field with default values.
|
|
func (s *EndpointTLSSpec) SetDefaults() {
|
|
}
|
|
|
|
// SetDefaultsFrom fills empty field with default values from the given source.
|
|
func (s *EndpointTLSSpec) SetDefaultsFrom(source EndpointTLSSpec) {
|
|
if s.CASecretName == nil {
|
|
s.CASecretName = util.NewStringOrNil(source.CASecretName)
|
|
}
|
|
}
|
|
|
|
// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec.
|
|
// It returns a list of fields that have been reset.
|
|
// Field names are relative to `spec.`.
|
|
func (s EndpointTLSSpec) ResetImmutableFields(target *EndpointTLSSpec, fieldPrefix string) []string {
|
|
var result []string
|
|
return result
|
|
}
|