common

package
v0.0.0-...-5bf9445 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2019 The Kubernetes Authors.

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 2019 The Kubernetes Authors.

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 2019 The Kubernetes Authors.

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.

Index

Constants

This section is empty.

Variables

View Source
var KubeClient *kubernetes.Interface

KubeClient a k8s client used for k8s native resources

View Source
var KubeConfig *rest.Config

KubeConfig is the given kubeconfig at startup

Functions

func DeduplicateItems

func DeduplicateItems(included []string, excluded []string) (res []string)

DeduplicateItems does the dedup

func ExtractNamespaceLabel

func ExtractNamespaceLabel(instance *policiesv1alpha1.TrustedNodePolicy) string

ExtractNamespaceLabel to find out the cluster-namespace from the label

func FindPattern

func FindPattern(pattern string, list []string) (result []string)

FindPattern finds patterns

func GetAllNamespaces

func GetAllNamespaces() (list []string, err error)

================================================================= GetAllNamespaces gets the list of all namespaces from k8s

func GetGenericObject

func GetGenericObject(data []byte, namespace string) (unstructured.Unstructured, error)

GetGenericObject returns a generic object information from the k8s API server

func GetSelectedNamespaces

func GetSelectedNamespaces(included, excluded, allNamespaces []string) []string

================================================================= GetSelectedNamespaces returns the list of filtered namespaces according to the policy namespace selector

func IfMatch

func IfMatch(name string, included, excluded []string) bool

IfMatch check matches

func Initialize

func Initialize(kClient *kubernetes.Interface, cfg *rest.Config)

Initialize to initialize some controller variables

func MatchNames

func MatchNames(all, included, excluded []string) []string

MatchNames matches names

func Round

func Round(num float64) int

Round rounds the value

func ToFixed

func ToFixed(num float64, precision int) float64

ToFixed returns a float with a certain precision

Types

type SyncedPolicyMap

type SyncedPolicyMap struct {
	PolicyMap map[string]*policiesv1alpha1.TrustedNodePolicy
	//Mx for making the map thread safe
	Mx sync.RWMutex
}

SyncedPolicyMap a thread safe map

func (*SyncedPolicyMap) AddObject

func (spm *SyncedPolicyMap) AddObject(key string, plc *policiesv1alpha1.TrustedNodePolicy)

AddObject safely add to map

func (*SyncedPolicyMap) GetObject

func (spm *SyncedPolicyMap) GetObject(key string) (value *policiesv1alpha1.TrustedNodePolicy, found bool)

GetObject used for fetching objects from the synced map

func (*SyncedPolicyMap) RemoveObject

func (spm *SyncedPolicyMap) RemoveObject(key string)

RemoveObject safely remove from map

Jump to

Keyboard shortcuts

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