Documentation ¶
Index ¶
- Constants
- func Add(mgr manager.Manager) error
- func CreateSubscriptionAdminRBAC(r client.Client) error
- func GetClustersByPlacement(instance *subv1.Subscription, kubeclient client.Client, logger logr.Logger) ([]types.NamespacedName, error)
- func GetReferenceString(ref *corev1.ObjectReference) string
- func GetSubscriptionRefChannel(clt client.Client, s *appv1.Subscription) (*chnv1.Channel, *chnv1.Channel, error)
- func ObjectString(obj metav1.Object) string
- func PrintHelper(o metav1.Object) types.NamespacedName
- type AnsibleHooks
- func (a *AnsibleHooks) AppendPreHookStatusToSubscription(subIns *subv1.Subscription) subv1.SubscriptionStatus
- func (a *AnsibleHooks) AppendStatusToSubscription(subIns *subv1.Subscription) subv1.SubscriptionStatus
- func (a *AnsibleHooks) ApplyPostHooks(subKey types.NamespacedName) error
- func (a *AnsibleHooks) ApplyPreHooks(subKey types.NamespacedName) error
- func (a *AnsibleHooks) DeregisterSubscription(subKey types.NamespacedName) error
- func (a *AnsibleHooks) GetLastAppliedInstance(subKey types.NamespacedName) AppliedInstance
- func (a *AnsibleHooks) HasHooks(hookType string, subKey types.NamespacedName) bool
- func (a *AnsibleHooks) IsPostHooksCompleted(subKey types.NamespacedName) (bool, error)
- func (a *AnsibleHooks) IsPreHooksCompleted(subKey types.NamespacedName) (bool, error)
- func (a *AnsibleHooks) RegisterSubscription(subIns *subv1.Subscription, placementDecisionUpdated bool, ...) error
- func (a *AnsibleHooks) ResetGitOps(g GitOps)
- func (a *AnsibleHooks) SetSuffixFunc(f SuffixFunc)
- type AppliedInstance
- type EqualSub
- type FormatFunc
- type GitOps
- type HookOps
- type HookProcessor
- type Hooks
- type HubGitOps
- func (h *HubGitOps) DeregisterBranch(subKey types.NamespacedName)
- func (h *HubGitOps) DownloadAnsibleHookResource(subIns *subv1.Subscription) error
- func (h *HubGitOps) GetHooks(subIns *subv1.Subscription, hookPath string) ([]ansiblejob.AnsibleJob, error)
- func (h *HubGitOps) GetLatestCommitID(subIns *subv1.Subscription) (string, error)
- func (h *HubGitOps) GetRepoRecords() map[string]*RepoRegistery
- func (h *HubGitOps) GetRepoRootDirctory(subIns *subv1.Subscription) string
- func (h *HubGitOps) GetSubRecords() map[types.NamespacedName]string
- func (h *HubGitOps) GitWatch(ctx context.Context)
- func (h *HubGitOps) HasHookFolders(subIns *subv1.Subscription) bool
- func (h *HubGitOps) RegisterBranch(subIns *subv1.Subscription) error
- func (h *HubGitOps) ResolveLocalGitFolder(subIns *subv1.Subscription) string
- func (h *HubGitOps) Start(ctx context.Context) error
- type HubGitOption
- type Job
- type JobInstances
- type ManageClusters
- type Option
- type ReconcileSubscription
- func (r *ReconcileSubscription) AddAppLabels(s *appv1alpha1.Subscription)
- func (r *ReconcileSubscription) AddClusterAdminAnnotation(sub *appv1.Subscription) bool
- func (r *ReconcileSubscription) GetChannelGeneration(s *appv1alpha1.Subscription) (string, error)
- func (r *ReconcileSubscription) GetChannelNamespaceType(s *appv1alpha1.Subscription) (string, string, string)
- func (r *ReconcileSubscription) GetGitResources(sub *appv1.Subscription, isAdmin bool) ([]*v1.ObjectReference, error)
- func (r *ReconcileSubscription) IsSubscriptionCompleted(subKey types.NamespacedName) (bool, error)
- func (r *ReconcileSubscription) PropagateAppSubManifestWork(instance *appSubV1.Subscription, clusters []ManageClusters) error
- func (r *ReconcileSubscription) Reconcile(ctx context.Context, request reconcile.Request) (result reconcile.Result, returnErr error)
- type RepoRegistery
- type SuffixFunc
Constants ¶
const ( PrehookDirSuffix = "/prehook/" PosthookDirSuffix = "/posthook/" JobCompleted = "successful" AnsibleJobKind = "AnsibleJob" AnsibleJobVersion = "tower.ansible.com/v1alpha1" Status = "status" AnsibleJobResult = "ansiblejobresult" SubLabel = "ownersub" PreHookType = "pre" PostHookType = "post" DebugLog = 1 InfoLog = 0 )
const (
INFOLevel = 1
)
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add creates a new Subscription Controller and adds it to the Manager. The Manager will set fields on the Controller and Start it when the Manager is Started.
func CreateSubscriptionAdminRBAC ¶ added in v0.5.0
CreateSubscriptionAdminRBAC checks existence of subscription-admin clusterrole and clusterrolebinding and creates them if not found
func GetClustersByPlacement ¶
func GetClustersByPlacement(instance *subv1.Subscription, kubeclient client.Client, logger logr.Logger) ([]types.NamespacedName, error)
Top priority: placementRef, ignore others Next priority: clusterNames, ignore selector Bottomline: Use label selector
func GetReferenceString ¶
func GetReferenceString(ref *corev1.ObjectReference) string
func ObjectString ¶
func PrintHelper ¶
func PrintHelper(o metav1.Object) types.NamespacedName
Types ¶
type AnsibleHooks ¶
type AnsibleHooks struct {
// contains filtered or unexported fields
}
func NewAnsibleHooks ¶
func (*AnsibleHooks) AppendPreHookStatusToSubscription ¶
func (a *AnsibleHooks) AppendPreHookStatusToSubscription(subIns *subv1.Subscription) subv1.SubscriptionStatus
func (*AnsibleHooks) AppendStatusToSubscription ¶
func (a *AnsibleHooks) AppendStatusToSubscription(subIns *subv1.Subscription) subv1.SubscriptionStatus
func (*AnsibleHooks) ApplyPostHooks ¶
func (a *AnsibleHooks) ApplyPostHooks(subKey types.NamespacedName) error
func (*AnsibleHooks) ApplyPreHooks ¶
func (a *AnsibleHooks) ApplyPreHooks(subKey types.NamespacedName) error
func (*AnsibleHooks) DeregisterSubscription ¶
func (a *AnsibleHooks) DeregisterSubscription(subKey types.NamespacedName) error
func (*AnsibleHooks) GetLastAppliedInstance ¶
func (a *AnsibleHooks) GetLastAppliedInstance(subKey types.NamespacedName) AppliedInstance
func (*AnsibleHooks) HasHooks ¶
func (a *AnsibleHooks) HasHooks(hookType string, subKey types.NamespacedName) bool
func (*AnsibleHooks) IsPostHooksCompleted ¶
func (a *AnsibleHooks) IsPostHooksCompleted(subKey types.NamespacedName) (bool, error)
func (*AnsibleHooks) IsPreHooksCompleted ¶
func (a *AnsibleHooks) IsPreHooksCompleted(subKey types.NamespacedName) (bool, error)
func (*AnsibleHooks) RegisterSubscription ¶
func (a *AnsibleHooks) RegisterSubscription(subIns *subv1.Subscription, placementDecisionUpdated bool, placementRuleRv string) error
func (*AnsibleHooks) ResetGitOps ¶
func (a *AnsibleHooks) ResetGitOps(g GitOps)
func (*AnsibleHooks) SetSuffixFunc ¶
func (a *AnsibleHooks) SetSuffixFunc(f SuffixFunc)
type AppliedInstance ¶
type AppliedInstance struct {
// contains filtered or unexported fields
}
type EqualSub ¶
type EqualSub func(*subv1.Subscription, *subv1.Subscription) bool
type FormatFunc ¶
type FormatFunc func(ansiblejob.AnsibleJob) string
type GitOps ¶
type GitOps interface { //DownloadAnsibleHookResource downloads the ansible job from the git and marshal //the resource to DownloadAnsibleHookResource(*subv1.Subscription) error HasHookFolders(*subv1.Subscription) bool // GetHooks returns the ansiblejob from a given folder, if the folder is // inaccessible, then os.Error is returned GetHooks(*subv1.Subscription, string) ([]ansiblejob.AnsibleJob, error) // RegisterBranch to git watcher and do a initial download for other // components to consume RegisterBranch(*subv1.Subscription) error // DeregisterBranch DeregisterBranch(types.NamespacedName) //helper for test GetRepoRecords() map[string]*RepoRegistery GetSubRecords() map[types.NamespacedName]string //GetLatestCommitID will output the latest commit id from local git record GetLatestCommitID(*subv1.Subscription) (string, error) //ResolveLocalGitFolder is used to open a local folder for downloading the //repo branch ResolveLocalGitFolder(*subv1.Subscription) string GetRepoRootDirctory(*subv1.Subscription) string //Runnable Start(context.Context) error }
type HookOps ¶
type HookOps func(*AnsibleHooks)
type HookProcessor ¶
type HookProcessor interface { // register subsription to the HookProcessor RegisterSubscription(*subv1.Subscription, bool, string) error DeregisterSubscription(types.NamespacedName) error //SetSuffixFunc let user reset the suffixFunc rule of generating the suffix //of hook instance name SetSuffixFunc(SuffixFunc) ResetGitOps(GitOps) //ApplyPreHook returns a type.NamespacedName of the preHook ApplyPreHooks(types.NamespacedName) error IsPreHooksCompleted(types.NamespacedName) (bool, error) ApplyPostHooks(types.NamespacedName) error IsPostHooksCompleted(types.NamespacedName) (bool, error) HasHooks(string, types.NamespacedName) bool //WriteStatusToSubscription gets the status at the entry of the reconcile, //also the procssed subscription(which should carry all the update status on //the given reconciel), then WriteStatusToSubscription will append the hook //status info and make a update to the cluster AppendStatusToSubscription(*appv1.Subscription) appv1.SubscriptionStatus AppendPreHookStatusToSubscription(*appv1.Subscription) appv1.SubscriptionStatus GetLastAppliedInstance(types.NamespacedName) AppliedInstance }
HookProcessor tracks the pre and post hook information of subscriptions.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func (*Hooks) ConstructStatus ¶
func (h *Hooks) ConstructStatus() subv1.AnsibleJobsStatus
type HubGitOps ¶
type HubGitOps struct {
// contains filtered or unexported fields
}
func NewHookGit ¶
func NewHookGit(clt client.Client, ops ...HubGitOption) *HubGitOps
func (*HubGitOps) DeregisterBranch ¶
func (h *HubGitOps) DeregisterBranch(subKey types.NamespacedName)
func (*HubGitOps) DownloadAnsibleHookResource ¶
func (h *HubGitOps) DownloadAnsibleHookResource(subIns *subv1.Subscription) error
func (*HubGitOps) GetHooks ¶
func (h *HubGitOps) GetHooks(subIns *subv1.Subscription, hookPath string) ([]ansiblejob.AnsibleJob, error)
GetHooks will provided the ansibleJobs at the given hookPath(if given a posthook path, then posthook ansiblejob is returned)
func (*HubGitOps) GetLatestCommitID ¶
func (h *HubGitOps) GetLatestCommitID(subIns *subv1.Subscription) (string, error)
func (*HubGitOps) GetRepoRecords ¶
func (h *HubGitOps) GetRepoRecords() map[string]*RepoRegistery
helper for test
func (*HubGitOps) GetRepoRootDirctory ¶
func (h *HubGitOps) GetRepoRootDirctory(subIns *subv1.Subscription) string
func (*HubGitOps) GetSubRecords ¶
func (h *HubGitOps) GetSubRecords() map[types.NamespacedName]string
helper for test
func (*HubGitOps) HasHookFolders ¶
func (h *HubGitOps) HasHookFolders(subIns *subv1.Subscription) bool
func (*HubGitOps) RegisterBranch ¶
func (h *HubGitOps) RegisterBranch(subIns *subv1.Subscription) error
func (*HubGitOps) ResolveLocalGitFolder ¶
func (h *HubGitOps) ResolveLocalGitFolder(subIns *subv1.Subscription) string
type HubGitOption ¶
type HubGitOption func(*HubGitOps)
type Job ¶
type Job struct { Original ansiblejob.AnsibleJob Instance []ansiblejob.AnsibleJob // track the create instance InstanceSet map[types.NamespacedName]struct{} // contains filtered or unexported fields }
type JobInstances ¶
type JobInstances map[types.NamespacedName]*Job
JobInstances can be applied and can be quired to see if the most applied instance is succeeded or not
type ManageClusters ¶ added in v0.5.0
type Option ¶
type Option func(*ReconcileSubscription)
Option provide easy way to test the reconciler
type ReconcileSubscription ¶
ReconcileSubscription reconciles a Subscription object
func (*ReconcileSubscription) AddAppLabels ¶ added in v0.7.0
func (r *ReconcileSubscription) AddAppLabels(s *appv1alpha1.Subscription)
func (*ReconcileSubscription) AddClusterAdminAnnotation ¶
func (r *ReconcileSubscription) AddClusterAdminAnnotation(sub *appv1.Subscription) bool
AddClusterAdminAnnotation adds cluster-admin annotation if conditions are met
func (*ReconcileSubscription) GetChannelGeneration ¶
func (r *ReconcileSubscription) GetChannelGeneration(s *appv1alpha1.Subscription) (string, error)
GetChannelGeneration get the channel generation
func (*ReconcileSubscription) GetChannelNamespaceType ¶
func (r *ReconcileSubscription) GetChannelNamespaceType(s *appv1alpha1.Subscription) (string, string, string)
GetChannelNamespaceType get the channel namespace and channel type by the given subscription
func (*ReconcileSubscription) GetGitResources ¶ added in v0.5.0
func (r *ReconcileSubscription) GetGitResources(sub *appv1.Subscription, isAdmin bool) ([]*v1.ObjectReference, error)
GetGitResources clones the git repo and regenerate deployables and update annotation if needed
func (*ReconcileSubscription) IsSubscriptionCompleted ¶
func (r *ReconcileSubscription) IsSubscriptionCompleted(subKey types.NamespacedName) (bool, error)
IsSubscriptionCompleted will check: a, if the subscription itself is processed b, for each of the subscription created on managed cluster, it will check if it is 1, propagated and 2, subscribed
func (*ReconcileSubscription) PropagateAppSubManifestWork ¶ added in v0.5.0
func (r *ReconcileSubscription) PropagateAppSubManifestWork(instance *appSubV1.Subscription, clusters []ManageClusters) error
func (*ReconcileSubscription) Reconcile ¶
func (r *ReconcileSubscription) Reconcile(ctx context.Context, request reconcile.Request) (result reconcile.Result, returnErr error)
Reconcile reads that state of the cluster for a Subscription object and makes changes based on the state read and what is in the Subscription.Spec
type RepoRegistery ¶
type RepoRegistery struct {
// contains filtered or unexported fields
}
type SuffixFunc ¶
type SuffixFunc func(GitOps, *subv1.Subscription) string