Documentation ¶
Index ¶
- Constants
- Variables
- func APIVersion2GroupVersion(str string) (string, string)
- func BeEquivalentToError(expected error) types.GomegaMatcher
- func ComputeHash(trait *v1alpha2.ComponentTrait) string
- func DeepHashObject(hasher hash.Hash, objectToWrite interface{})
- func FetchScopeDefinition(ctx context.Context, r client.Reader, scope *unstructured.Unstructured) (*v1alpha2.ScopeDefinition, error)
- func FetchTraitDefinition(ctx context.Context, r client.Reader, trait *unstructured.Unstructured) (*v1alpha2.TraitDefinition, error)
- func FetchWorkload(ctx context.Context, c client.Client, mLog logr.Logger, oamTrait oam.Trait) (*unstructured.Unstructured, error)
- func FetchWorkloadChildResources(ctx context.Context, mLog logr.Logger, r client.Reader, ...) ([]*unstructured.Unstructured, error)
- func FetchWorkloadDefinition(ctx context.Context, r client.Reader, workload *unstructured.Unstructured) (*v1alpha2.WorkloadDefinition, error)
- func GenTraitName(componentName string, ct *v1alpha2.ComponentTrait) string
- func GetCRDName(u *unstructured.Unstructured) string
- func GetComponent(ctx context.Context, client client.Reader, ...) (*v1alpha2.Component, string, error)
- func Kind2Resource(str string) string
- func LocateParentAppConfig(ctx context.Context, client client.Client, oamObject oam.Object) (oam.Object, error)
- func Object2Map(obj interface{}) (map[string]interface{}, error)
- func Object2Unstructured(obj interface{}) (*unstructured.Unstructured, error)
- func PassLabelAndAnnotation(parentObj oam.Object, childObj labelAnnotationObject)
- func PatchCondition(ctx context.Context, r client.StatusClient, workload ConditionedObject, ...) error
- func UnpackRevisionData(rev *appsv1.ControllerRevision) (*v1alpha2.Component, error)
- type AlreadyExistMatcher
- type ConditionedObject
- type ErrorMatcher
- type NotFoundMatcher
Constants ¶
const ( //ErrUpdateStatus is the error while applying status. ErrUpdateStatus = "cannot apply status" //ErrLocateAppConfig is the error while locating parent application. ErrLocateAppConfig = "cannot locate the parent application configuration to emit event to" // ErrLocateWorkload is the error while locate the workload ErrLocateWorkload = "cannot find the workload that the trait is referencing to" // ErrFetchChildResources is the error while fetching workload child resources ErrFetchChildResources = "failed to fetch workload child resources" )
const (
//TraitPrefixKey is prefix of trait name
TraitPrefixKey = "trait"
)
Variables ¶
var ( //KindDeployment is the k8s Deployment kind. KindDeployment = reflect.TypeOf(appsv1.Deployment{}).Name() //KindService is the k8s Service kind. KindService = reflect.TypeOf(corev1.Service{}).Name() // ReconcileWaitResult is the time to wait between reconciliation. ReconcileWaitResult = reconcile.Result{RequeueAfter: 30 * time.Second} )
Functions ¶
func APIVersion2GroupVersion ¶
APIVersion2GroupVersion turn an apiVersion string into group and version
func BeEquivalentToError ¶
func BeEquivalentToError(expected error) types.GomegaMatcher
BeEquivalentToError matches the error to take care of nil.
func ComputeHash ¶ added in v0.0.4
func ComputeHash(trait *v1alpha2.ComponentTrait) string
ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.
func DeepHashObject ¶ added in v0.0.4
DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.
func FetchScopeDefinition ¶ added in v0.0.5
func FetchScopeDefinition(ctx context.Context, r client.Reader, scope *unstructured.Unstructured) (*v1alpha2.ScopeDefinition, error)
FetchScopeDefinition fetch corresponding scopeDefinition given a scope
func FetchTraitDefinition ¶
func FetchTraitDefinition(ctx context.Context, r client.Reader, trait *unstructured.Unstructured) (*v1alpha2.TraitDefinition, error)
FetchTraitDefinition fetch corresponding traitDefinition given a trait
func FetchWorkload ¶ added in v0.0.6
func FetchWorkload(ctx context.Context, c client.Client, mLog logr.Logger, oamTrait oam.Trait) ( *unstructured.Unstructured, error)
FetchWorkload fetch the workload that a trait refers to
func FetchWorkloadChildResources ¶
func FetchWorkloadChildResources(ctx context.Context, mLog logr.Logger, r client.Reader, workload *unstructured.Unstructured) ([]*unstructured.Unstructured, error)
FetchWorkloadChildResources fetch corresponding child resources given a workload
func FetchWorkloadDefinition ¶
func FetchWorkloadDefinition(ctx context.Context, r client.Reader, workload *unstructured.Unstructured) (*v1alpha2.WorkloadDefinition, error)
FetchWorkloadDefinition fetch corresponding workloadDefinition given a workload
func GenTraitName ¶ added in v0.0.4
func GenTraitName(componentName string, ct *v1alpha2.ComponentTrait) string
GenTraitName generate trait name
func GetCRDName ¶ added in v0.0.4
func GetCRDName(u *unstructured.Unstructured) string
GetCRDName return the CRD name of any resources the format of the CRD of a resource is <kind purals>.<group>
func GetComponent ¶ added in v0.0.9
func GetComponent(ctx context.Context, client client.Reader, acc v1alpha2.ApplicationConfigurationComponent, namespace string) (*v1alpha2.Component, string, error)
GetComponent will get Component and RevisionName by AppConfigComponent
func LocateParentAppConfig ¶
func LocateParentAppConfig(ctx context.Context, client client.Client, oamObject oam.Object) (oam.Object, error)
LocateParentAppConfig locate the parent application configuration object
func Object2Map ¶
Object2Map turn the Object to a map
func Object2Unstructured ¶
func Object2Unstructured(obj interface{}) (*unstructured.Unstructured, error)
Object2Unstructured convert an object to an unstructured struct
func PassLabelAndAnnotation ¶ added in v0.0.9
PassLabelAndAnnotation passes through labels and annotation objectMeta from the parent to the child object
func PatchCondition ¶
func PatchCondition(ctx context.Context, r client.StatusClient, workload ConditionedObject, condition ...cpv1alpha1.Condition) error
PatchCondition condition for a conditioned object
func UnpackRevisionData ¶ added in v0.0.9
func UnpackRevisionData(rev *appsv1.ControllerRevision) (*v1alpha2.Component, error)
UnpackRevisionData will unpack revision.Data to Component
Types ¶
type AlreadyExistMatcher ¶
type AlreadyExistMatcher struct { }
AlreadyExistMatcher matches the error to be already exist
func (AlreadyExistMatcher) FailureMessage ¶
func (matcher AlreadyExistMatcher) FailureMessage(actual interface{}) (message string)
FailureMessage builds an error message.
func (AlreadyExistMatcher) Match ¶
func (matcher AlreadyExistMatcher) Match(actual interface{}) (success bool, err error)
Match matches error.
func (AlreadyExistMatcher) NegatedFailureMessage ¶
func (matcher AlreadyExistMatcher) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage builds an error message.
type ConditionedObject ¶
type ConditionedObject interface { oam.Object oam.Conditioned }
A ConditionedObject is an Object type with condition field
type ErrorMatcher ¶
type ErrorMatcher struct {
ExpectedError error
}
ErrorMatcher matches errors.
func (ErrorMatcher) FailureMessage ¶
func (matcher ErrorMatcher) FailureMessage(actual interface{}) (message string)
FailureMessage builds an error message.
func (ErrorMatcher) Match ¶
func (matcher ErrorMatcher) Match(actual interface{}) (success bool, err error)
Match matches an error.
func (ErrorMatcher) NegatedFailureMessage ¶
func (matcher ErrorMatcher) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage builds an error message.
type NotFoundMatcher ¶
type NotFoundMatcher struct { }
NotFoundMatcher matches the error to be not found.
func (NotFoundMatcher) FailureMessage ¶
func (matcher NotFoundMatcher) FailureMessage(actual interface{}) (message string)
FailureMessage builds an error message.
func (NotFoundMatcher) Match ¶
func (matcher NotFoundMatcher) Match(actual interface{}) (success bool, err error)
Match matches the api error.
func (NotFoundMatcher) NegatedFailureMessage ¶
func (matcher NotFoundMatcher) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage builds an error message.