Documentation ¶
Overview ¶
Package fakes defines methods for instantiating objects which act like resources on a Kubernetes cluster, but are not intended to actually be instantiated on a real, production cluster.
The primary purpose of these objects is to aid writing tests, but that is not this package's only purpose. These objects are also used in debugging logic which is compiled in to production code.
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
- Variables
- func Pod(opts ...Opt) *corev1.Pod
- type FakeOpa
- func (f *FakeOpa) AddData(ctx context.Context, data interface{}) (*constraintTypes.Responses, error)
- func (f *FakeOpa) Contains(expected map[OpaKey]interface{}) bool
- func (f *FakeOpa) HasGVK(gvk schema.GroupVersionKind) bool
- func (f *FakeOpa) Len() int
- func (f *FakeOpa) RemoveData(ctx context.Context, data interface{}) (*constraintTypes.Responses, error)
- func (f *FakeOpa) SetErroring(enabled bool)
- type OpaKey
- type Opt
Constants ¶
const ( // Name is the default name given to fake objects. Name = "foo" // Namespace is the default namespace given to fake namespace-scoped objects. Namespace = "bar" // UID is the default UID given to fake objects. UID = "abcd" )
const (
// ExternalDataProviderName is the name of the fake external data provider.
ExternalDataProviderName = "test-provider"
)
Variables ¶
var ExternalDataProviderCache = frameworksexternaldata.NewCache()
ExternalDataProviderCache is the cache of external data providers.
Functions ¶
Types ¶
type FakeOpa ¶
type FakeOpa struct {
// contains filtered or unexported fields
}
FakeOpa is an OpaDataClient for testing.
func (*FakeOpa) HasGVK ¶
func (f *FakeOpa) HasGVK(gvk schema.GroupVersionKind) bool
HasGVK returns true if the cache has any data of the requested kind.
func (*FakeOpa) RemoveData ¶
func (*FakeOpa) SetErroring ¶
SetErroring will error out on AddObject or RemoveObject.
type OpaKey ¶
type OpaKey struct { Gvk schema.GroupVersionKind Key string }
type Opt ¶
Opt modifies a client.Object during object instantiation. Generally, if there are conflicting opts (such as two WithName calls), the latter should win. This allows objects to have defaults which can easily be overridden.
func WithLabels ¶
WithLabels sets the metadata.labels of the object. Overwrites any existing labels on the object.
func WithNamespace ¶
WithNamespace sets the metadata.namespace of the object.