controllers

package
v0.0.0-...-8da0143 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 72 Imported by: 0

Documentation

Overview

Code generated by MockGen. DO NOT EDIT. Source: controllers/checkout.go

Generated by this command:

mockgen -source controllers/checkout.go -package controllers -self_package=github.com/hybrid-cloud-patterns/patterns-operator/controllers

Package controllers is a generated GoMock package.

Code generated by MockGen. DO NOT EDIT. Source: controllers/drift.go

Generated by this command:

mockgen -source controllers/drift.go -package controllers -self_package=github.com/hybrid-cloud-patterns/patterns-operator/controllers

Package controllers is a generated GoMock package.

Index

Constants

View Source
const (
	// UpdateEvent is the name of the update event
	PatternStartEvent   = "Pattern started"
	PatternEndEvent     = "Pattern completed"
	PatternRefreshEvent = "Pattern refreshed"

	// RefreshIntervalMinutes is the minimum time between updates (4h)
	RefreshIntervalMinutes float64 = 240

	// AnalyticsSent is an int bit-field that stores which info has already been sent
	AnalyticsSentIdentify = 0x0
	AnalyticsSentStart    = 0x1
	AnalyticsSentEnd      = 0x2
	AnalyticsSentRefresh  = 0x3

	MinSubDomainParts = 3
)
View Source
const (
	ArgoCDGroup    = "argoproj.io"
	ArgoCDVersion  = "v1beta1"
	ArgoCDResource = "argocds"
)

Which ArgoCD objects we're creating

View Source
const (
	// Default Operator Namespace
	OperatorNamespace = "openshift-operators"
	// Default Operator Config Map Name
	OperatorConfigMap = "patterns-operator-config"
	// Default Subscription Namespace
	SubscriptionNamespace = "openshift-operators"
	// Default Application Namespace
	ApplicationNamespace = "openshift-gitops"
	// ClusterWide Argo Name
	ClusterWideArgoName = "openshift-gitops"
)

Below are the default constants that we will use throughout the patterns operator code

View Source
const (
	GitOpsDefaultChannel                = "gitops-1.14"
	GitOpsDefaultPackageName            = "openshift-gitops-operator"
	GitOpsDefaultCatalogSource          = "redhat-operators"
	GitOpsDefaultCatalogSourceNamespace = "openshift-marketplace"
	GitOpsDefaultApprovalPlan           = "Automatic"
)

GitOps Subscription

View Source
const (
	// Require manual intervention before Argo will sync new content. Default: False
	GitOpsDefaultManualSync = "false"
	// Require manual confirmation before installing and upgrading operators. Default: False
	GitOpsDefaultManualApproval = "false"
	// Dangerous. Force a specific version to be installed. Default: False
	GitOpsDefaultUseCSV = "false"
)

GitOps Configuration

View Source
const (
	// URL to the Validated Patterns Helm chart repo
	GiteaHelmRepoUrl = "https://charts.validatedpatterns.io/"
	// Repo name for the Validated Patterns Helm repo
	GiteaRepoName = "helm-charts"
	// Gitea chart name in the Validated Patterns repo
	GiteaChartName = "gitea"
	// Release name used by the Helm SDK
	GiteaReleaseName = "gitea"
	// Namespace for the Gitea resources
	GiteaNamespace = "vp-gitea"
	// Our gitea-chart default version (we stay on the latest 0.0.X version)
	GiteaDefaultChartVersion = "0.0.*"
	// Default Gitea Admin user
	GiteaAdminUser = "gitea_admin"
	// Gitea Admin Secrets name
	GiteaAdminSecretName = "gitea-admin-secret" //nolint:gosec
	// GiteaServer default name
	GiteaServerDefaultName = "vp-gitea-instance"
	// Gitea Route Name
	GiteaRouteName = "gitea-route"
	// Gitea Argo Application Name
	GiteaApplicationName = "gitea-in-cluster"
	// Gitea Default Random Password Length
	GiteaDefaultPasswordLen = 15
)

Gitea chart defaults

View Source
const GitCustomCAFile = "/tmp/vp-git-cas.pem"
View Source
const ReconcileLoopRequeueTime = 180 * time.Second
View Source
const VPTmpFolder = "vp"

Variables

View Source
var DefaultPatternOperatorConfig = map[string]string{
	"gitops.catalogSource":       GitOpsDefaultCatalogSource,
	"gitops.name":                GitOpsDefaultPackageName,
	"gitops.channel":             GitOpsDefaultChannel,
	"gitops.sourceNamespace":     GitOpsDefaultCatalogSourceNamespace,
	"gitops.installApprovalPlan": GitOpsDefaultApprovalPlan,
	"gitops.ManualSync":          GitOpsDefaultManualSync,
	"gitea.chartName":            GiteaChartName,
	"gitea.helmRepoUrl":          GiteaHelmRepoUrl,
	"gitea.chartVersion":         GiteaDefaultChartVersion,
}

Functions

func DefaultRandRead

func DefaultRandRead(b []byte) (int, error)

func DropLocalGitPaths

func DropLocalGitPaths() error

func GenerateRandomPassword

func GenerateRandomPassword(length int, randRead func([]byte) (int, error)) (string, error)

GenerateRandomPassword generates a random password of specified length

func IsCommonSlimmed

func IsCommonSlimmed(patternPath string) bool

This function returns true if common is the slimmed version and false if it is not

Types

type GitAuthenticationBackend

type GitAuthenticationBackend uint
const (
	GitAuthNone     GitAuthenticationBackend = 0
	GitAuthPassword GitAuthenticationBackend = 1
	GitAuthSsh      GitAuthenticationBackend = 2
)

type GitClient

type GitClient interface {
	NewRemoteClient(c *config.RemoteConfig) RemoteClient
}

type GitOperations

type GitOperations interface {
	OpenRepository(directory string) (*git.Repository, error)
	CloneRepository(directory string, isBare bool, options *git.CloneOptions) (*git.Repository, error)
}

GitOperations interface defines the methods used from the go-git package.

type GitOperationsImpl

type GitOperationsImpl struct{}

GitOperationsImpl implements the GitOperations interface using the actual go-git package.

func (*GitOperationsImpl) CloneRepository

func (g *GitOperationsImpl) CloneRepository(directory string, isBare bool, options *git.CloneOptions) (*git.Repository, error)

func (*GitOperationsImpl) OpenRepository

func (g *GitOperationsImpl) OpenRepository(directory string) (*git.Repository, error)

OpenRepository opens a git repository.

type GitOpsConfig

type GitOpsConfig map[string]string
var PatternsOperatorConfig GitOpsConfig

type GiteaOperations

type GiteaOperations interface {
	MigrateGiteaRepo(fullClient kubernetes.Interface, username, password, upstreamURL, giteaServerRoute string) (success bool, repositoryURL string, err error)
}

type GiteaOperationsImpl

type GiteaOperationsImpl struct{}

func (*GiteaOperationsImpl) MigrateGiteaRepo

func (g *GiteaOperationsImpl) MigrateGiteaRepo(
	fullClient kubernetes.Interface, username, password, upstreamURL, giteaServerRoute string) (success bool, repositoryURL string, err error)

Function that creates a mirror repo in Gitea

type MockGitClient

type MockGitClient struct {
	// contains filtered or unexported fields
}

MockGitClient is a mock of GitClient interface.

func NewMockGitClient

func NewMockGitClient(ctrl *gomock.Controller) *MockGitClient

NewMockGitClient creates a new mock instance.

func (*MockGitClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGitClient) NewRemoteClient

func (m *MockGitClient) NewRemoteClient(c *config.RemoteConfig) RemoteClient

NewRemoteClient mocks base method.

type MockGitClientMockRecorder

type MockGitClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockGitClientMockRecorder is the mock recorder for MockGitClient.

func (*MockGitClientMockRecorder) NewRemoteClient

func (mr *MockGitClientMockRecorder) NewRemoteClient(c any) *gomock.Call

NewRemoteClient indicates an expected call of NewRemoteClient.

type MockGitOperations

type MockGitOperations struct {
	// contains filtered or unexported fields
}

MockGitOperations is a mock of GitOperations interface.

func NewMockGitOperations

func NewMockGitOperations(ctrl *gomock.Controller) *MockGitOperations

NewMockGitOperations creates a new mock instance.

func (*MockGitOperations) CloneRepository

func (m *MockGitOperations) CloneRepository(directory string, isBare bool, options *git.CloneOptions) (*git.Repository, error)

CloneRepository mocks base method.

func (*MockGitOperations) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGitOperations) OpenRepository

func (m *MockGitOperations) OpenRepository(directory string) (*git.Repository, error)

OpenRepository mocks base method.

type MockGitOperationsMockRecorder

type MockGitOperationsMockRecorder struct {
	// contains filtered or unexported fields
}

MockGitOperationsMockRecorder is the mock recorder for MockGitOperations.

func (*MockGitOperationsMockRecorder) CloneRepository

func (mr *MockGitOperationsMockRecorder) CloneRepository(directory, isBare, options any) *gomock.Call

CloneRepository indicates an expected call of CloneRepository.

func (*MockGitOperationsMockRecorder) OpenRepository

func (mr *MockGitOperationsMockRecorder) OpenRepository(directory any) *gomock.Call

OpenRepository indicates an expected call of OpenRepository.

type MockRemoteClient

type MockRemoteClient struct {
	// contains filtered or unexported fields
}

MockRemoteClient is a mock of RemoteClient interface.

func NewMockRemoteClient

func NewMockRemoteClient(ctrl *gomock.Controller) *MockRemoteClient

NewMockRemoteClient creates a new mock instance.

func (*MockRemoteClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRemoteClient) List

List mocks base method.

type MockRemoteClientMockRecorder

type MockRemoteClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockRemoteClientMockRecorder is the mock recorder for MockRemoteClient.

func (*MockRemoteClientMockRecorder) List

List indicates an expected call of List.

type MockdriftWatcher

type MockdriftWatcher struct {
	// contains filtered or unexported fields
}

MockdriftWatcher is a mock of driftWatcher interface.

func NewMockdriftWatcher

func NewMockdriftWatcher(ctrl *gomock.Controller) *MockdriftWatcher

NewMockdriftWatcher creates a new mock instance.

func (*MockdriftWatcher) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockdriftWatcherMockRecorder

type MockdriftWatcherMockRecorder struct {
	// contains filtered or unexported fields
}

MockdriftWatcherMockRecorder is the mock recorder for MockdriftWatcher.

type PatternReconciler

type PatternReconciler struct {
	client.Client
	Scheme          *runtime.Scheme
	AnalyticsClient VpAnalyticsInterface
	// contains filtered or unexported fields
}

PatternReconciler reconciles a Pattern object

func (*PatternReconciler) Reconcile

func (r *PatternReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. The Reconcile function compares the state specified by the Pattern object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.0/pkg/reconcile

func (*PatternReconciler) SetupWithManager

func (r *PatternReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type RemoteClient

type RemoteClient interface {
	List(o *git.ListOptions) (rfs []*plumbing.Reference, err error)
}

type VpAnalytics

type VpAnalytics struct {
	// contains filtered or unexported fields
}

func AnalyticsInit

func AnalyticsInit(disabled bool, logger logr.Logger) *VpAnalytics

func (*VpAnalytics) SendPatternEndEventInfo

func (v *VpAnalytics) SendPatternEndEventInfo(p *api.Pattern) bool

Sends an EndEvent the first time it is invoked. Subsequent invocations will send a Refresh event returns true if the status object in the crd should be updated

func (*VpAnalytics) SendPatternInstallationInfo

func (v *VpAnalytics) SendPatternInstallationInfo(p *api.Pattern) bool

This called at the beginning of the reconciliation loop and only once returns true if the status object in the crd should be updated

func (*VpAnalytics) SendPatternStartEventInfo

func (v *VpAnalytics) SendPatternStartEventInfo(p *api.Pattern) bool

returns true if the status object in the crd should be updated

type VpAnalyticsInterface

type VpAnalyticsInterface interface {
	SendPatternInstallationInfo(p *api.Pattern) bool
	SendPatternStartEventInfo(p *api.Pattern) bool
	SendPatternEndEventInfo(p *api.Pattern) bool
}

Jump to

Keyboard shortcuts

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