backendconfig

package
v1.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

View Source
const (
	OAuthClientIDKey     = "client_id"
	OAuthClientSecretKey = "client_secret"
)

Variables

View Source
var (
	ErrBackendConfigDoesNotExist = errors.New("no BackendConfig for service port exists.")
	ErrBackendConfigFailedToGet  = errors.New("client had error getting BackendConfig for service port.")
	ErrNoBackendConfigForPort    = errors.New("no BackendConfig name found for service port.")
)
View Source
var (
	TestBackendConfig = &backendconfigv1.BackendConfig{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "config-test",
			Namespace: "test",
		},
	}

	SvcWithoutConfig = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-no-config",
			Namespace: "test",
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithTestConfig = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-test-config",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"ports": {"port1": "config-test"}}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithTestConfigBeta = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-test-config-beta",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BetaBackendConfigKey: `{"ports": {"port1": "config-test"}}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithTestConfigPortNumber = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-test-config-port-number",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"ports": {"443": "config-test"}}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Port: 443},
			},
		},
	}

	SvcWithTestConfigMismatchPort = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-test-config-mismatch-port",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"ports": {"port2": "config-test"}}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithDefaultTestConfig = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-default-test-config",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"default": "config-test"}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithTestConfigOtherNamespace = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-test-config",
			Namespace: "other-namespace",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"ports": {"port1": "config-test"}}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithOtherConfig = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-other-config",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"ports": {"port1": "config-other"}}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithDefaultOtherConfig = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-default-other-config",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `{"default": "config-other"}`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}

	SvcWithInvalidConfig = &apiv1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "svc-invalid-config",
			Namespace: "test",
			Annotations: map[string]string{
				annotations.BackendConfigKey: `invalid`,
			},
		},
		Spec: apiv1.ServiceSpec{
			Ports: []apiv1.ServicePort{
				{Name: "port1"},
			},
		},
	}
)

The below vars are used for sharing unit testing types with multiple packages.

Functions

func BackendConfigName

func BackendConfigName(backendConfigs annotations.BackendConfigs, svcPort apiv1.ServicePort) string

BackendConfigName returns the name of the BackendConfig which is associated with the given ServicePort.

func CRDMeta

func CRDMeta() *crd.CRDMeta

func GetBackendConfigForServicePort

func GetBackendConfigForServicePort(backendConfigLister cache.Store, svc *apiv1.Service, svcPort *apiv1.ServicePort) (*backendconfigv1.BackendConfig, error)

GetBackendConfigForServicePort returns the corresponding BackendConfig for the given ServicePort if specified.

func Validate

func Validate(kubeClient kubernetes.Interface, beConfig *backendconfigv1.BackendConfig) error

Types

This section is empty.

Directories

Path Synopsis
client
clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
clientset/versioned/typed/backendconfig/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
clientset/versioned/typed/backendconfig/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
clientset/versioned/typed/backendconfig/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
clientset/versioned/typed/backendconfig/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL