api

package
v0.0.0-...-72ee208 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package api SyncSets API.

Standalone Hive SyncSets without reliance on Kube API, CRs, and etcd.

Schemes: http
Host: localhost
BasePath: /v1
Version: 0.0.1
License: Apache2
Contact: Devan Goodwin<dgoodwin@redhat.com>

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResource

type APIResource interface {
	RowScan(row *sql.Row) error
	Marshal() ([]byte, error)
	Scan(value interface{}) error
	APIVersion() string // to find db tables and api endpoints
}

type Cluster

type Cluster struct {
	// Name of the cluster.
	//
	// required: true
	Name string `json:"name"`
	// Namespace of the cluster. Models the Kubernetes concept of Namespace as OpenShift Hive
	// uses that to allow multiple clusters with the same name, separated by owner.
	//
	// required: true
	Namespace string `json:"namespace"`
	// Kubeconfig is an admin kubeconfig file for communicating with the cluster.
	//
	// required: true
	Kubeconfig string `json:"kubeconfig"`
}

Cluster is a representation of a Cluster we will reconcile SyncSets to.

swagger:model cluster

func (*Cluster) APIVersion

func (a *Cluster) APIVersion() string

func (Cluster) Marshal

func (a Cluster) Marshal() ([]byte, error)

func (*Cluster) RowScan

func (a *Cluster) RowScan(row *sql.Row) error

func (*Cluster) Scan

func (a *Cluster) Scan(value interface{}) error

Implement the sql.Scanner interface to decode a JSON-encoded value into the struct fields.

func (Cluster) Value

func (a Cluster) Value() (driver.Value, error)

type ClusterItem

type ClusterItem struct {
	ID      int
	Cluster Cluster
}

type Registry

type Registry struct {
}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) GetResource

func (r *Registry) GetResource(resourceName string) (APIResource, error)

type SecretMapping

type SecretMapping struct {

	// SourceRef specifies the name and namespace of a secret on the management cluster
	SourceRef SecretReference `json:"sourceRef"`

	// TargetRef specifies the target name and namespace of the secret on the target cluster
	TargetRef SecretReference `json:"targetRef"`
}

SecretMapping defines a source and destination for a secret to be synced by a SyncSet

type SecretReference

type SecretReference struct {
	// Name is the name of the secret
	Name string `json:"name"`
	// Namespace is the namespace where the secret lives. If not present for the source
	// secret reference, it is assumed to be the same namespace as the syncset with the
	// reference.
	// +optional
	Namespace string `json:"namespace,omitempty"`
}

SecretReference is a reference to a secret by name and namespace

type SelectorSyncSet

type SelectorSyncSet struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   SelectorSyncSetSpec   `json:"spec,omitempty"`
	Status SelectorSyncSetStatus `json:"status,omitempty"`
}

SelectorSyncSet is the Schema for the SelectorSyncSet API +k8s:openapi-gen=true +kubebuilder:subresource:status +kubebuilder:resource:path=selectorsyncsets,shortName=sss,scope=Cluster

func (*SelectorSyncSet) APIVersion

func (a *SelectorSyncSet) APIVersion() string

func (SelectorSyncSet) Marshal

func (a SelectorSyncSet) Marshal() ([]byte, error)

func (*SelectorSyncSet) RowScan

func (a *SelectorSyncSet) RowScan(row *sql.Row) error

func (*SelectorSyncSet) Scan

func (a *SelectorSyncSet) Scan(value interface{}) error

Implement the sql.Scanner interface to decode a JSON-encoded value into the struct fields.

func (SelectorSyncSet) Value

func (a SelectorSyncSet) Value() (driver.Value, error)

type SelectorSyncSetList

type SelectorSyncSetList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SelectorSyncSet `json:"items"`
}

SelectorSyncSetList contains a list of SyncSets

type SelectorSyncSetSpec

type SelectorSyncSetSpec struct {
	SyncSetCommonSpec `json:",inline"`

	// ClusterDeploymentSelector is a LabelSelector indicating which clusters the SelectorSyncSet
	// applies to in any namespace.
	// +optional
	ClusterDeploymentSelector metav1.LabelSelector `json:"clusterDeploymentSelector,omitempty"`
}

SelectorSyncSetSpec defines the SyncSetCommonSpec resources and patches to sync along with a ClusterDeploymentSelector indicating which clusters the SelectorSyncSet applies to in any namespace.

type SelectorSyncSetStatus

type SelectorSyncSetStatus struct {
}

SelectorSyncSetStatus defines the observed state of a SelectorSyncSet

type SyncCondition

type SyncCondition struct {
	// Type is the type of the condition.
	Type SyncConditionType `json:"type"`
	// Status is the status of the condition.
	Status corev1.ConditionStatus `json:"status"`
	// LastProbeTime is the last time we probed the condition.
	// +optional
	LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
	// LastTransitionTime is the last time the condition transitioned from one status to another.
	// +optional
	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
	// Reason is a unique, one-word, CamelCase reason for the condition's last transition.
	// +optional
	Reason string `json:"reason,omitempty"`
	// Message is a human-readable message indicating details about last transition.
	// +optional
	Message string `json:"message,omitempty"`
}

SyncCondition is a condition in a SyncStatus

type SyncConditionType

type SyncConditionType string

SyncConditionType is a valid value for SyncCondition.Type

const (
	// ApplySuccessSyncCondition indicates whether the resource or patch has been applied.
	ApplySuccessSyncCondition SyncConditionType = "ApplySuccess"

	// ApplyFailureSyncCondition indicates that a resource or patch has failed to apply.
	// It should include a reason and message for the failure.
	ApplyFailureSyncCondition SyncConditionType = "ApplyFailure"

	// DeletionFailedSyncCondition indicates that resource deletion has failed.
	// It should include a reason and message for the failure.
	DeletionFailedSyncCondition SyncConditionType = "DeletionFailed"

	// UnknownObjectSyncCondition indicates that the resource type cannot be determined.
	// It should include a reason and message for the failure.
	UnknownObjectSyncCondition SyncConditionType = "UnknownObject"
)

type SyncObjectPatch

type SyncObjectPatch struct {
	// APIVersion is the Group and Version of the object to be patched.
	APIVersion string `json:"apiVersion"`

	// Kind is the Kind of the object to be patched.
	Kind string `json:"kind"`

	// Name is the name of the object to be patched.
	Name string `json:"name"`

	// Namespace is the Namespace in which the object to patch exists.
	// Defaults to the SyncSet's Namespace.
	// +optional
	Namespace string `json:"namespace,omitempty"`

	// Patch is the patch to apply.
	Patch string `json:"patch"`

	// PatchType indicates the PatchType as "strategic" (default), "json", or "merge".
	// +optional
	PatchType string `json:"patchType,omitempty"`
}

SyncObjectPatch represents a patch to be applied to a specific object

type SyncSet

type SyncSet struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   SyncSetSpec   `json:"spec,omitempty"`
	Status SyncSetStatus `json:"status,omitempty"`
}

SyncSet is the Schema for the SyncSet API +k8s:openapi-gen=true +kubebuilder:subresource:status +kubebuilder:resource:path=syncsets,shortName=ss,scope=Namespaced

type SyncSetApplyBehavior

type SyncSetApplyBehavior string

SyncSetApplyBehavior is a string representing the behavior to use when aplying a syncset to target cluster. +kubebuilder:validation:Enum="";Apply;CreateOnly;CreateOrUpdate

const (
	// ApplySyncSetApplyBehavior is the default apply behavior. It will result
	// in resources getting applied using the 'oc apply' command to the target
	// cluster.
	ApplySyncSetApplyBehavior SyncSetApplyBehavior = "Apply"

	// CreateOnlySyncSetApplyBehavior results in resources only getting created
	// if they do not exist, otherwise they are left alone.
	CreateOnlySyncSetApplyBehavior SyncSetApplyBehavior = "CreateOnly"

	// CreateOrUpdateSyncSetApplyBehavior results in resources getting created if
	// they do not exist, otherwise they are updated with the contents of the
	// syncset resource. This is different from Apply behavior in that an annotation
	// is not added to the target resource with the "lastApplied" value. It allows
	// for syncing larger resources, but loses the ability to sync map entry deletes.
	CreateOrUpdateSyncSetApplyBehavior SyncSetApplyBehavior = "CreateOrUpdate"
)

type SyncSetCommonSpec

type SyncSetCommonSpec struct {
	// Resources is the list of objects to sync from RawExtension definitions.
	// +optional
	Resources []runtime.RawExtension `json:"resources,omitempty"`

	// ResourceApplyMode indicates if the Resource apply mode is "Upsert" (default) or "Sync".
	// ApplyMode "Upsert" indicates create and update.
	// ApplyMode "Sync" indicates create, update and delete.
	// +optional
	ResourceApplyMode SyncSetResourceApplyMode `json:"resourceApplyMode,omitempty"`

	// Patches is the list of patches to apply.
	// +optional
	Patches []SyncObjectPatch `json:"patches,omitempty"`

	// Secrets is the list of secrets to sync along with their respective destinations.
	// +optional
	Secrets []SecretMapping `json:"secretMappings,omitempty"`

	// ApplyBehavior indicates how resources in this syncset will be applied to the target
	// cluster. The default value of "Apply" indicates that resources should be applied
	// using the 'oc apply' command. If no value is set, "Apply" is assumed.
	// A value of "CreateOnly" indicates that the resource will only be created if it does
	// not already exist in the target cluster. Otherwise, it will be left alone.
	// A value of "CreateOrUpdate" indicates that the resource will be created/updated without
	// the use of the 'oc apply' command, allowing larger resources to be synced, but losing
	// some functionality of the 'oc apply' command such as the ability to remove annotations,
	// labels, and other map entries in general.
	// +optional
	ApplyBehavior SyncSetApplyBehavior `json:"applyBehavior,omitempty"`
}

SyncSetCommonSpec defines the resources and patches to sync

type SyncSetItem

type SyncSetItem struct {
	ID      int
	SyncSet SelectorSyncSet
}

type SyncSetList

type SyncSetList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SyncSet `json:"items"`
}

SyncSetList contains a list of SyncSets

type SyncSetObjectStatus

type SyncSetObjectStatus struct {
	// Name is the name of the SyncSet.
	Name string `json:"name"`

	// Resources is the list of SyncStatus for objects that have been synced.
	// +optional
	Resources []SyncStatus `json:"resources,omitempty"`

	// ResourceApplyMode indicates if the Resource apply mode is "Upsert" (default) or "Sync".
	// ApplyMode "Upsert" indicates create and update.
	// ApplyMode "Sync" indicates create, update and delete.
	// +optional
	ResourceApplyMode SyncSetResourceApplyMode `json:"resourceApplyMode,omitempty"`

	// Patches is the list of SyncStatus for patches that have been applied.
	// +optional
	Patches []SyncStatus `json:"patches,omitempty"`

	// Secrets is the list of SyncStatus for secrets that have been synced.
	// +optional
	Secrets []SyncStatus `json:"secrets,omitempty"`

	// Conditions is the list of SyncConditions used to indicate UnknownObject
	// when a resource type cannot be determined from a SyncSet resource.
	// +optional
	Conditions []SyncCondition `json:"conditions,omitempty"`
}

SyncSetObjectStatus describes the status of resources created or patches that have been applied from a SyncSet or SelectorSyncSet.

type SyncSetPatchApplyMode

type SyncSetPatchApplyMode string

SyncSetPatchApplyMode is a string representing the mode with which to apply SyncSet Patches.

const (
	// ApplyOncePatchApplyMode indicates that the patch should be applied
	// only once.
	ApplyOncePatchApplyMode SyncSetPatchApplyMode = "ApplyOnce"

	// AlwaysApplyPatchApplyMode indicates that the patch should be
	// continuously applied.
	AlwaysApplyPatchApplyMode SyncSetPatchApplyMode = "AlwaysApply"
)

type SyncSetResourceApplyMode

type SyncSetResourceApplyMode string

SyncSetResourceApplyMode is a string representing the mode with which to apply SyncSet Resources.

const (
	// UpsertResourceApplyMode indicates that objects will be updated
	// or inserted (created).
	UpsertResourceApplyMode SyncSetResourceApplyMode = "Upsert"

	// SyncResourceApplyMode inherits the create or update functionality
	// of Upsert but also indicates that objects will be deleted if created
	// previously and detected missing from defined Resources in the SyncSet.
	SyncResourceApplyMode SyncSetResourceApplyMode = "Sync"
)

type SyncSetSpec

type SyncSetSpec struct {
	SyncSetCommonSpec `json:",inline"`

	// ClusterDeploymentRefs is the list of LocalObjectReference indicating which clusters the
	// SyncSet applies to in the SyncSet's namespace.
	// +required
	ClusterDeploymentRefs []corev1.LocalObjectReference `json:"clusterDeploymentRefs"`
}

SyncSetSpec defines the SyncSetCommonSpec resources and patches to sync along with ClusterDeploymentRefs indicating which clusters the SyncSet applies to in the SyncSet's namespace.

type SyncSetStatus

type SyncSetStatus struct {
}

SyncSetStatus defines the observed state of a SyncSet

type SyncStatus

type SyncStatus struct {
	// APIVersion is the Group and Version of the object that was synced or
	// patched.
	APIVersion string `json:"apiVersion"`

	// Kind is the Kind of the object that was synced or patched.
	Kind string `json:"kind"`

	// Resource is the resource name for the object that was synced.
	// This will be populated for resources, but not patches
	// +optional
	Resource string `json:"resource,omitempty"`

	// Name is the name of the object that was synced or patched.
	Name string `json:"name"`

	// Namespace is the Namespace of the object that was synced or patched.
	Namespace string `json:"namespace"`

	// Hash is the unique md5 hash of the resource or patch.
	Hash string `json:"hash"`

	// Conditions is the list of conditions indicating success or failure of object
	// create, update and delete as well as patch application.
	Conditions []SyncCondition `json:"conditions"`
}

SyncStatus describes objects that have been created or patches that have been applied using the unique md5 sum of the object or patch.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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