Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRenovaterPipeline(ctx context.Context, client client.Client, scheme *runtime.Scheme, ...) error
- func DefaultDependenciesUpdate(ctx context.Context, client client.Client, scheme *runtime.Scheme, ...) (immediateRetry bool, err error)
- func GetComponentFromPipelineRun(c client.Client, ctx context.Context, pipelineRun *tektonapi.PipelineRun) (*applicationapi.Component, error)
- func GetGithubInstallationsForComponents(ctx context.Context, client client.Client, eventRecorder record.EventRecorder, ...) (string, []installationStruct, error)
- func IsBuildPushPipelineRun(object client.Object) bool
- type BuildPipeline
- type BuildResult
- type BuildStatus
- type ComponentBuildReconciler
- func (r *ComponentBuildReconciler) ConfigureRepositoryForPaC(ctx context.Context, component *appstudiov1alpha1.Component, ...) (prUrl string, err error)
- func (r *ComponentBuildReconciler) GetBuildPipelineFromComponentAnnotation(ctx context.Context, component *appstudiov1alpha1.Component) (*tektonapi.PipelineRef, error)
- func (r *ComponentBuildReconciler) GetPipelineForComponent(ctx context.Context, component *appstudiov1alpha1.Component) (*tektonapi.PipelineRef, []tektonapi.Param, error)
- func (r *ComponentBuildReconciler) ProvisionPaCForComponent(ctx context.Context, component *appstudiov1alpha1.Component) (string, error)
- func (r *ComponentBuildReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *ComponentBuildReconciler) SetupWithManager(mgr ctrl.Manager) error
- func (r *ComponentBuildReconciler) SubmitNewBuild(ctx context.Context, component *appstudiov1alpha1.Component) error
- func (r *ComponentBuildReconciler) TriggerPaCBuild(ctx context.Context, component *appstudiov1alpha1.Component) (bool, error)
- func (r *ComponentBuildReconciler) UnconfigureRepositoryForPaC(ctx context.Context, component *appstudiov1alpha1.Component, ...) (baseBranch string, prUrl string, action string, err error)
- func (r *ComponentBuildReconciler) UndoPaCProvisionForComponent(ctx context.Context, component *appstudiov1alpha1.Component) (string, error)
- func (r *ComponentBuildReconciler) WaitForCacheUpdate(ctx context.Context, namespace types.NamespacedName, ...)
- type ComponentDependencyUpdateReconciler
- type ErrorInfo
- type GitTektonResourcesRenovater
- type PaCBuildStatus
- type PaCPipelineRunPrunerReconciler
- type SimpleBuildStatus
- type UpdateComponentDependenciesFunction
Constants ¶
const ( BuildRequestAnnotationName = "build.appstudio.openshift.io/request" BuildRequestTriggerSimpleBuildAnnotationValue = "trigger-simple-build" BuildRequestTriggerPaCBuildAnnotationValue = "trigger-pac-build" BuildRequestConfigurePaCAnnotationValue = "configure-pac" BuildRequestUnconfigurePaCAnnotationValue = "unconfigure-pac" BuildStatusAnnotationName = "build.appstudio.openshift.io/status" PaCProvisionFinalizer = "pac.component.appstudio.openshift.io/finalizer" ImageRegistrySecretLinkFinalizer = "image-registry-secret-sa-link.component.appstudio.openshift.io/finalizer" ApplicationNameLabelName = "appstudio.openshift.io/application" ComponentNameLabelName = "appstudio.openshift.io/component" PartOfLabelName = "app.kubernetes.io/part-of" PartOfAppStudioLabelValue = "appstudio" ImageRepoAnnotationName = "image.redhat.com/image" ImageRepoGenerateAnnotationName = "image.redhat.com/generate" )
const ( PipelineRunOnPRExpirationEnvVar = "IMAGE_TAG_ON_PR_EXPIRATION" PipelineRunOnPRExpirationDefault = "5d" // Annotation that specifies git provider id for self hosted SCM instances, e.g. github or gitlab. GitProviderAnnotationName = "git-provider" GitProviderAnnotationURL = "git-provider-url" )
const ( // PipelineRunTypeLabelName contains the type of the PipelineRunType PipelineRunTypeLabelName = "pipelines.appstudio.openshift.io/type" // PipelineRunBuildType is the type denoting a build PipelineRun. PipelineRunBuildType = "build" // PacEventTypeAnnotationName represents the current event type PacEventTypeAnnotationName = "pipelinesascode.tekton.dev/event-type" PacEventPushType = "push" ImageUrlParamName = "IMAGE_URL" ImageDigestParamName = "IMAGE_DIGEST" NudgeProcessedAnnotationName = "build.appstudio.openshift.io/component-nudge-processed" NudgeFinalizer = "build.appstudio.openshift.io/build-nudge-finalizer" FailureCountAnnotationName = "build.appstudio.openshift.io/build-nudge-failures" NudgeFilesAnnotationName = "build.appstudio.openshift.io/build-nudge-files" ComponentNudgedEventType = "ComponentNudged" ComponentNudgeFailedEventType = "ComponentNudgeFailed" MaxAttempts = 3 KubeApiUpdateMaxAttempts = 5 FailureRetryTime = time.Minute * 5 // We retry after 5 minutes on failure )
const (
NextReconcile = 6 * time.Hour
)
Variables ¶
var DefaultUpdateFunction = DefaultDependenciesUpdate
var DevfileSearchForDockerfile = devfile.SearchForDockerfile
That way it can be mocked in tests
var GetHttpClientFunction = getHttpClient
That way it can be mocked in tests
Functions ¶
func CreateRenovaterPipeline ¶
func CreateRenovaterPipeline(ctx context.Context, client client.Client, scheme *runtime.Scheme, namespace string, installations []installationStruct, slug string, debug bool, js func(slug string, repositories []renovateRepository, info interface{}) (string, error), info interface{}) error
CreateRenovaterPipeline will create a renovate pipeline in the user namespace, to update component dependencies. The reasons for using a pipeline in the component namespace instead of a Job in the system namespace is as follows: - The user namespace has direct access to secrets to allow updating private images - Job's are removed after a timeout, so lots of nudges in a short period could make the namespace unusable due to pod Quota, while pipelines are pruned much more aggressively - Users can view the results of pipelines and the results are stored, making debugging much easier - Tekton automatically provides docker config from linked service accounts for private images, with a job I would need to implement this manually
Warning: the installation token used here should only be scoped to the individual repositories being updated
func DefaultDependenciesUpdate ¶
func DefaultDependenciesUpdate(ctx context.Context, client client.Client, scheme *runtime.Scheme, eventRecorder record.EventRecorder, downstreamComponents []applicationapi.Component, result *BuildResult) (immediateRetry bool, err error)
func GetComponentFromPipelineRun ¶
func GetComponentFromPipelineRun(c client.Client, ctx context.Context, pipelineRun *tektonapi.PipelineRun) (*applicationapi.Component, error)
GetComponentFromPipelineRun loads from the cluster the Component referenced in the given PipelineRun. If the PipelineRun doesn't specify a Component we return nil, if the component is not specified we return an error
func GetGithubInstallationsForComponents ¶
func GetGithubInstallationsForComponents(ctx context.Context, client client.Client, eventRecorder record.EventRecorder, componentList []v1alpha1.Component) (string, []installationStruct, error)
GetGithubInstallationsForComponents This method avoids iterating over all installations, it is intended to be called when the component list is small
func IsBuildPushPipelineRun ¶
Types ¶
type BuildPipeline ¶
type BuildResult ¶
type BuildStatus ¶
type BuildStatus struct { Simple *SimpleBuildStatus `json:"simple,omitempty"` PaC *PaCBuildStatus `json:"pac,omitempty"` // Shows build methods agnostic messages, e.g. invalid build request. Message string `json:"message,omitempty"` }
type ComponentBuildReconciler ¶
type ComponentBuildReconciler struct { Client client.Client Scheme *runtime.Scheme EventRecorder record.EventRecorder CredentialProvider *k8s.GitCredentialProvider WebhookURLLoader webhook.WebhookURLLoader }
ComponentBuildReconciler watches AppStudio Component objects in order to provision Pipelines as Code configuration for the Component or submit initial builds and dependent resources if PaC is not configured.
func (*ComponentBuildReconciler) ConfigureRepositoryForPaC ¶
func (r *ComponentBuildReconciler) ConfigureRepositoryForPaC(ctx context.Context, component *appstudiov1alpha1.Component, pacConfig map[string][]byte, webhookTargetUrl, webhookSecret string) (prUrl string, err error)
ConfigureRepositoryForPaC creates a merge request with initial Pipelines as Code configuration and configures a webhook to notify in-cluster PaC unless application (on the repository side) is used.
func (*ComponentBuildReconciler) GetBuildPipelineFromComponentAnnotation ¶
func (r *ComponentBuildReconciler) GetBuildPipelineFromComponentAnnotation(ctx context.Context, component *appstudiov1alpha1.Component) (*tektonapi.PipelineRef, error)
GetBuildPipelineFromComponentAnnotation parses pipeline annotation on component and returns build pipeline
func (*ComponentBuildReconciler) GetPipelineForComponent ¶
func (r *ComponentBuildReconciler) GetPipelineForComponent(ctx context.Context, component *appstudiov1alpha1.Component) (*tektonapi.PipelineRef, []tektonapi.Param, error)
GetPipelineForComponent searches for the build pipeline to use on the component.
func (*ComponentBuildReconciler) ProvisionPaCForComponent ¶
func (r *ComponentBuildReconciler) ProvisionPaCForComponent(ctx context.Context, component *appstudiov1alpha1.Component) (string, error)
ProvisionPaCForComponent does Pipelines as Code provision for the given component. Mainly, it creates PaC configuration merge request into the component source repositotiry. If GitHub PaC application is not configured, creates a webhook for PaC.
func (*ComponentBuildReconciler) SetupWithManager ¶
func (r *ComponentBuildReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
func (*ComponentBuildReconciler) SubmitNewBuild ¶
func (r *ComponentBuildReconciler) SubmitNewBuild(ctx context.Context, component *appstudiov1alpha1.Component) error
SubmitNewBuild creates a new PipelineRun to build a new image for the given component. Is called right ater component creation and later on user's demand.
func (*ComponentBuildReconciler) TriggerPaCBuild ¶
func (r *ComponentBuildReconciler) TriggerPaCBuild(ctx context.Context, component *appstudiov1alpha1.Component) (bool, error)
func (*ComponentBuildReconciler) UnconfigureRepositoryForPaC ¶
func (r *ComponentBuildReconciler) UnconfigureRepositoryForPaC(ctx context.Context, component *appstudiov1alpha1.Component, pacConfig map[string][]byte, webhookTargetUrl string) (baseBranch string, prUrl string, action string, err error)
UnconfigureRepositoryForPaC creates a merge request that deletes Pipelines as Code configuration of the diven component in its repository. Deletes PaC webhook if it's used. Does not delete PaC GitHub application from the repository as its installation was done manually by the user. Returns merge request web URL or empty string if it's not needed.
func (*ComponentBuildReconciler) UndoPaCProvisionForComponent ¶
func (r *ComponentBuildReconciler) UndoPaCProvisionForComponent(ctx context.Context, component *appstudiov1alpha1.Component) (string, error)
UndoPaCProvisionForComponent creates merge request that removes Pipelines as Code configuration from component source repository. Deletes PaC webhook if used. In case of any errors just logs them and does not block Component deletion.
func (*ComponentBuildReconciler) WaitForCacheUpdate ¶
func (r *ComponentBuildReconciler) WaitForCacheUpdate(ctx context.Context, namespace types.NamespacedName, component *appstudiov1alpha1.Component)
type ComponentDependencyUpdateReconciler ¶
type ComponentDependencyUpdateReconciler struct { client.Client ApiReader client.Reader Scheme *runtime.Scheme EventRecorder record.EventRecorder UpdateFunction UpdateComponentDependenciesFunction }
ComponentDependencyUpdateReconciler reconciles a PipelineRun object
func (*ComponentDependencyUpdateReconciler) Reconcile ¶
func (r *ComponentDependencyUpdateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
+kubebuilder:rbac:groups=appstudio.redhat.com,resources=components,verbs=get;list;watch;update;patch +kubebuilder:rbac:groups=appstudio.redhat.com,resources=components/status,verbs=get;list;watch +kubebuilder:rbac:groups=tekton.dev,resources=pipelineruns,verbs=get;list;watch;create;update;patch;delete;deletecollection +kubebuilder:rbac:groups=tekton.dev,resources=pipelineruns/status,verbs=get;update;patch +kubebuilder:rbac:groups=tekton.dev,resources=pipelineruns/finalizers,verbs=update +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
func (*ComponentDependencyUpdateReconciler) SetupWithManager ¶
func (r *ComponentDependencyUpdateReconciler) SetupWithManager(manager ctrl.Manager) error
SetupController creates a new Integration reconciler and adds it to the Manager.
type ErrorInfo ¶
type ErrorInfo struct { ErrId int `json:"error-id,omitempty"` ErrMessage string `json:"error-message,omitempty"` }
Describes persistent error for build request.
type GitTektonResourcesRenovater ¶
type GitTektonResourcesRenovater struct {
// contains filtered or unexported fields
}
GitTektonResourcesRenovater watches build pipeline ConfigMap object in order to update existing .tekton directories.
func NewDefaultGitTektonResourcesRenovater ¶
func NewDefaultGitTektonResourcesRenovater(client client.Client, scheme *runtime.Scheme, eventRecorder record.EventRecorder) *GitTektonResourcesRenovater
func NewGitTektonResourcesRenovater ¶
func NewGitTektonResourcesRenovater(client client.Client, scheme *runtime.Scheme, eventRecorder record.EventRecorder, taskProviders []renovate.TaskProvider) *GitTektonResourcesRenovater
func (*GitTektonResourcesRenovater) SetupWithManager ¶
func (r *GitTektonResourcesRenovater) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type PaCBuildStatus ¶
type PaCBuildStatus struct { // State shows if PaC is used. // Values are: enabled, disabled. State string `json:"state,omitempty"` // Contains link to PaC provision / unprovision pull request MergeUrl string `json:"merge-url,omitempty"` // Time of the last successful PaC configuration in RFC1123 format ConfigurationTime string `json:"configuration-time,omitempty"` ErrorInfo }
type PaCPipelineRunPrunerReconciler ¶
type PaCPipelineRunPrunerReconciler struct { Client client.Client Scheme *runtime.Scheme EventRecorder record.EventRecorder }
PaCPipelineRunPrunerReconciler watches AppStudio Component object in order to clean up running PipelineRuns created by Pipeline-as-Code when the Component gets deleted.
func (*PaCPipelineRunPrunerReconciler) PrunePipelineRuns ¶
func (r *PaCPipelineRunPrunerReconciler) PrunePipelineRuns(ctx context.Context, req ctrl.Request) error
PrunePipelineRuns deletes PipelineRuns, if any, assocoated with the given Component.
func (*PaCPipelineRunPrunerReconciler) SetupWithManager ¶
func (r *PaCPipelineRunPrunerReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type SimpleBuildStatus ¶
type UpdateComponentDependenciesFunction ¶
type UpdateComponentDependenciesFunction = func(ctx context.Context, client client.Client, scheme *runtime.Scheme, eventRecorder record.EventRecorder, downstreamComponents []applicationapi.Component, result *BuildResult) (immediateRetry bool, err error)