Documentation ¶
Index ¶
- Constants
- Variables
- func EnableForeignKeys(fileName string) string
- func EnableImmutable(fileName string) string
- func LogSqliteDeprecation()
- func Open(fileName string) (*sql.DB, error)
- func OpenReadOnly(fileName string) (*sql.DB, error)
- func ToModel(ctx context.Context, q *SQLQuerier) (model.Model, error)
- type BundleDeprecator
- type ConfigMapLoader
- type DbOption
- type DbOptions
- type DeprecationAwareLoader
- func (s DeprecationAwareLoader) AddBundlePackageChannels(manifest registry.PackageManifest, bundle *registry.Bundle) error
- func (s DeprecationAwareLoader) AddBundleSemver(graph *registry.Package, bundle *registry.Bundle) error
- func (s DeprecationAwareLoader) AddOperatorBundle(bundle *registry.Bundle) error
- func (s DeprecationAwareLoader) AddPackageChannels(manifest registry.PackageManifest) error
- func (s DeprecationAwareLoader) AddPackageChannelsFromGraph(graph *registry.Package) error
- func (s DeprecationAwareLoader) ClearNonHeadBundles() error
- func (s DeprecationAwareLoader) DeprecateBundle(path string) error
- func (s DeprecationAwareLoader) Migrate(ctx context.Context) error
- func (s DeprecationAwareLoader) RemoveOverwrittenChannelHead(pkg, bundle string) error
- func (d *DeprecationAwareLoader) RemovePackage(pkg string) error
- func (s DeprecationAwareLoader) RemoveStrandedBundles() error
- type DirectoryLoader
- type MigratableLoader
- type Migrator
- type PackageDeprecator
- type PackageRemover
- type Querier
- type RowScanner
- type SQLDeprecator
- type SQLGraphLoader
- type SQLLiteMigrator
- type SQLPopulator
- type SQLQuerier
- func (s *SQLQuerier) BundlePathForChannelHead(ctx context.Context, pkg string, channel string) (string, error)
- func (s *SQLQuerier) GetApisForEntry(ctx context.Context, entryID int64) (provided []*api.GroupVersionKind, required []*api.GroupVersionKind, err error)
- func (s *SQLQuerier) GetBundle(ctx context.Context, pkgName, channelName, csvName string) (*api.Bundle, error)
- func (s *SQLQuerier) GetBundleForChannel(ctx context.Context, pkg string, channel string) (*api.Bundle, error)
- func (s *SQLQuerier) GetBundlePathIfExists(ctx context.Context, bundleName string) (bundlePath string, err error)
- func (s *SQLQuerier) GetBundlePathsForPackage(ctx context.Context, pkgName string) ([]string, error)
- func (s *SQLQuerier) GetBundleThatProvides(ctx context.Context, group, apiVersion, kind string) (*api.Bundle, error)
- func (s *SQLQuerier) GetBundleThatReplaces(ctx context.Context, name, pkgName, channelName string) (*api.Bundle, error)
- func (s *SQLQuerier) GetBundleVersion(ctx context.Context, image string) (string, error)
- func (s *SQLQuerier) GetBundlesForPackage(ctx context.Context, pkgName string) (map[registry.BundleKey]struct{}, error)
- func (s *SQLQuerier) GetChannelEntriesFromPackage(ctx context.Context, packageName string) ([]registry.ChannelEntryAnnotated, error)
- func (s *SQLQuerier) GetChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*registry.ChannelEntry, err error)
- func (s *SQLQuerier) GetChannelEntriesThatReplace(ctx context.Context, name string) (entries []*registry.ChannelEntry, err error)
- func (s *SQLQuerier) GetCurrentCSVNameForChannel(ctx context.Context, pkgName, channel string) (string, error)
- func (s *SQLQuerier) GetDefaultChannelForPackage(ctx context.Context, pkgName string) (string, error)
- func (s *SQLQuerier) GetDefaultPackage(ctx context.Context, name string) (string, error)
- func (s *SQLQuerier) GetDependenciesForBundle(ctx context.Context, name, version, path string) (dependencies []*api.Dependency, err error)
- func (s *SQLQuerier) GetImagesForBundle(ctx context.Context, csvName string) ([]string, error)
- func (s *SQLQuerier) GetLatestChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*registry.ChannelEntry, err error)
- func (s *SQLQuerier) GetPackage(ctx context.Context, name string) (*registry.PackageManifest, error)
- func (s *SQLQuerier) GetPropertiesForBundle(ctx context.Context, name, version, path string) (properties []*api.Property, err error)
- func (s *SQLQuerier) ListBundles(ctx context.Context) ([]*api.Bundle, error)
- func (s *SQLQuerier) ListChannels(ctx context.Context, pkgName string) ([]string, error)
- func (s *SQLQuerier) ListImages(ctx context.Context) ([]string, error)
- func (s *SQLQuerier) ListPackages(ctx context.Context) ([]string, error)
- func (s *SQLQuerier) ListRegistryBundles(ctx context.Context) ([]*registry.Bundle, error)
- func (s *SQLQuerier) ListTables(ctx context.Context) ([]string, error)
- func (s *SQLQuerier) PackageFromDefaultChannelHeadBundle(ctx context.Context, bundle string) (string, error)
- func (s *SQLQuerier) SendBundles(ctx context.Context, stream registry.BundleSender) error
- type SQLRemover
- type SQLStrandedBundleRemover
- type SQLiteQuerierOption
- type StrandedBundleRemover
Constants ¶
const ( ConfigMapCRDName = "customResourceDefinitions" ConfigMapCSVName = "clusterServiceVersions" ConfigMapPackageName = "packages" )
const ( DefaultMigrationsTable = "schema_migrations" NilVersion = -1 )
const ClusterServiceVersionKind = "ClusterServiceVersion"
Variables ¶
var DeprecationMessage = fmt.Sprintf(noticeColor, `DEPRECATION NOTICE:
Sqlite-based catalogs and their related subcommands are deprecated. Support for
them will be removed in a future release. Please migrate your catalog workflows
to the new file-based catalog format.`)
Functions ¶
func EnableForeignKeys ¶
EnableForeignKeys appends the option to enable foreign keys on connections note that without this option, PRAGMAs about foreign keys will lie.
func EnableImmutable ¶
Immutable appends the option to mark the db immutable on connections
func LogSqliteDeprecation ¶
func LogSqliteDeprecation()
func Open ¶
Open opens a connection to a sqlite db. It should be used everywhere instead of sql.Open so that foreign keys are ensured.
func OpenReadOnly ¶
Open opens a connection to a sqlite db. It is
Types ¶
type BundleDeprecator ¶
type BundleDeprecator struct {
// contains filtered or unexported fields
}
BundleDeprecator removes bundles from the database
func NewSQLDeprecatorForBundles ¶
func NewSQLDeprecatorForBundles(store registry.Load, bundles []string) *BundleDeprecator
func (*BundleDeprecator) Deprecate ¶
func (d *BundleDeprecator) Deprecate() error
type ConfigMapLoader ¶
type ConfigMapLoader struct {
// contains filtered or unexported fields
}
ConfigMapLoader loads a configmap of resources into the database entries under "customResourceDefinitions" will be parsed as CRDs entries under "clusterServiceVersions" will be parsed as CSVs entries under "packages" will be parsed as Packages
func NewSQLLoaderForConfigMap ¶
func NewSQLLoaderForConfigMap(store registry.Load, configMap v1.ConfigMap) *ConfigMapLoader
func NewSQLLoaderForConfigMapData ¶
func NewSQLLoaderForConfigMapData(logger *logrus.Entry, store registry.Load, configMapData map[string]string) *ConfigMapLoader
NewSQLLoaderForConfigMapData is useful when the operator manifest(s) originate from a different source than a configMap. For example, operator manifest(s) can be downloaded from a remote registry like quay.io.
func (*ConfigMapLoader) Populate ¶
func (c *ConfigMapLoader) Populate() error
type DeprecationAwareLoader ¶
type DeprecationAwareLoader struct {
// contains filtered or unexported fields
}
DeprecationAwareLoader understands how bundle deprecations are handled in SQLite and decorates the sqlLoader with proxy methods that handle deprecation related table housekeeping.
func NewDeprecationAwareLoader ¶
func NewDeprecationAwareLoader(db *sql.DB, opts ...DbOption) (*DeprecationAwareLoader, error)
NewDeprecationAwareLoader returns a new DeprecationAwareLoader.
func (DeprecationAwareLoader) AddBundlePackageChannels ¶
func (s DeprecationAwareLoader) AddBundlePackageChannels(manifest registry.PackageManifest, bundle *registry.Bundle) error
func (DeprecationAwareLoader) AddBundleSemver ¶
func (DeprecationAwareLoader) AddOperatorBundle ¶
func (DeprecationAwareLoader) AddPackageChannels ¶
func (s DeprecationAwareLoader) AddPackageChannels(manifest registry.PackageManifest) error
func (DeprecationAwareLoader) AddPackageChannelsFromGraph ¶
func (DeprecationAwareLoader) ClearNonHeadBundles ¶
func (s DeprecationAwareLoader) ClearNonHeadBundles() error
func (DeprecationAwareLoader) DeprecateBundle ¶
func (DeprecationAwareLoader) RemoveOverwrittenChannelHead ¶
RemoveOverwrittenChannelHead removes a bundle if it is the channel head and has nothing replacing it
func (*DeprecationAwareLoader) RemovePackage ¶
func (d *DeprecationAwareLoader) RemovePackage(pkg string) error
func (DeprecationAwareLoader) RemoveStrandedBundles ¶
func (s DeprecationAwareLoader) RemoveStrandedBundles() error
type DirectoryLoader ¶
type DirectoryLoader struct {
// contains filtered or unexported fields
}
DirectoryLoader loads a directory of resources into the database
func NewSQLLoaderForDirectory ¶
func NewSQLLoaderForDirectory(store registry.Load, directory string) *DirectoryLoader
func (*DirectoryLoader) LoadBundleWalkFunc ¶
LoadBundleWalkFunc walks the directory. When it sees a `.clusterserviceversion.yaml` file, it attempts to load the surrounding files in the same directory as a bundle, and stores them in the db for querying
func (*DirectoryLoader) LoadPackagesWalkFunc ¶
LoadPackagesWalkFunc attempts to unmarshal the file at the given path into a PackageManifest resource. If unmarshaling is successful, the PackageManifest is added to the loader's store.
func (*DirectoryLoader) Populate ¶
func (d *DirectoryLoader) Populate() error
type MigratableLoader ¶
func NewSQLLiteLoader ¶
func NewSQLLiteLoader(db *sql.DB, opts ...DbOption) (MigratableLoader, error)
type Migrator ¶
type Migrator interface { Migrate(ctx context.Context) error Up(ctx context.Context, migrations migrations.Migrations) error Down(ctx context.Context, migrations migrations.Migrations) error }
type PackageDeprecator ¶
type PackageDeprecator struct { *BundleDeprecator // contains filtered or unexported fields }
PackageDeprecator removes bundles and optionally entire packages from the index
func NewSQLDeprecatorForBundlesAndPackages ¶
func NewSQLDeprecatorForBundlesAndPackages(deprecator *BundleDeprecator, querier *SQLQuerier) *PackageDeprecator
func (*PackageDeprecator) MaybeRemovePackages ¶
func (d *PackageDeprecator) MaybeRemovePackages() error
MaybeRemovePackages queries the DB to establish if any provided bundles are the head of the default channel of a package. If so, the list of bundles must also contain the head of all other channels in the package, otherwise an error is produced. If the heads of all channels are being deprecated (including the default channel), the package is removed entirely from the index. MaybeRemovePackages deletes all bundles from the associated package from the bundles array, so that the subsequent Deprecate() call can proceed with deprecating other potential bundles from other packages.
type PackageRemover ¶
type PackageRemover struct {
// contains filtered or unexported fields
}
PackageRemover removes a package from the database
func NewSQLRemoverForPackages ¶
func NewSQLRemoverForPackages(store registry.Load, packages string) *PackageRemover
func (*PackageRemover) Remove ¶
func (d *PackageRemover) Remove() error
type Querier ¶
type Querier interface {
QueryContext(ctx context.Context, query string, args ...interface{}) (RowScanner, error)
}
type RowScanner ¶
type SQLDeprecator ¶
type SQLDeprecator interface {
Deprecate() error
}
type SQLGraphLoader ¶
func NewSQLGraphLoader ¶
func NewSQLGraphLoader(dbFilename string) (*SQLGraphLoader, error)
func NewSQLGraphLoaderFromDB ¶
func NewSQLGraphLoaderFromDB(db *sql.DB) (*SQLGraphLoader, error)
type SQLLiteMigrator ¶
type SQLLiteMigrator struct {
// contains filtered or unexported fields
}
func (*SQLLiteMigrator) Down ¶
func (m *SQLLiteMigrator) Down(ctx context.Context, migrations migrations.Migrations) error
func (*SQLLiteMigrator) Migrate ¶
func (m *SQLLiteMigrator) Migrate(ctx context.Context) error
Migrate gets the current version from the database, the latest version from the migrations, and migrates up the the latest
func (*SQLLiteMigrator) Up ¶
func (m *SQLLiteMigrator) Up(ctx context.Context, migrations migrations.Migrations) error
Up runs a specific set of migrations.
type SQLPopulator ¶
type SQLPopulator interface {
Populate() error
}
type SQLQuerier ¶
type SQLQuerier struct {
// contains filtered or unexported fields
}
func NewSQLLiteQuerier ¶
func NewSQLLiteQuerier(dbFilename string, opts ...SQLiteQuerierOption) (*SQLQuerier, error)
func NewSQLLiteQuerierFromDBQuerier ¶
func NewSQLLiteQuerierFromDBQuerier(q Querier, opts ...SQLiteQuerierOption) *SQLQuerier
func NewSQLLiteQuerierFromDb ¶
func NewSQLLiteQuerierFromDb(db *sql.DB, opts ...SQLiteQuerierOption) *SQLQuerier
func (*SQLQuerier) BundlePathForChannelHead ¶
func (s *SQLQuerier) BundlePathForChannelHead(ctx context.Context, pkg string, channel string) (string, error)
BundlePathForChannelHead returns the bundlepath for the given package and channel
func (*SQLQuerier) GetApisForEntry ¶
func (s *SQLQuerier) GetApisForEntry(ctx context.Context, entryID int64) (provided []*api.GroupVersionKind, required []*api.GroupVersionKind, err error)
func (*SQLQuerier) GetBundleForChannel ¶
func (*SQLQuerier) GetBundlePathIfExists ¶
func (*SQLQuerier) GetBundlePathsForPackage ¶
func (*SQLQuerier) GetBundleThatProvides ¶
func (s *SQLQuerier) GetBundleThatProvides(ctx context.Context, group, apiVersion, kind string) (*api.Bundle, error)
Get the the latest bundle that provides the API in a default channel, error unless there is ONLY one
func (*SQLQuerier) GetBundleThatReplaces ¶
func (*SQLQuerier) GetBundleVersion ¶
func (*SQLQuerier) GetBundlesForPackage ¶
func (*SQLQuerier) GetChannelEntriesFromPackage ¶
func (s *SQLQuerier) GetChannelEntriesFromPackage(ctx context.Context, packageName string) ([]registry.ChannelEntryAnnotated, error)
func (*SQLQuerier) GetChannelEntriesThatProvide ¶
func (s *SQLQuerier) GetChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*registry.ChannelEntry, err error)
func (*SQLQuerier) GetChannelEntriesThatReplace ¶
func (s *SQLQuerier) GetChannelEntriesThatReplace(ctx context.Context, name string) (entries []*registry.ChannelEntry, err error)
func (*SQLQuerier) GetCurrentCSVNameForChannel ¶
func (*SQLQuerier) GetDefaultChannelForPackage ¶
func (*SQLQuerier) GetDefaultPackage ¶
func (*SQLQuerier) GetDependenciesForBundle ¶
func (s *SQLQuerier) GetDependenciesForBundle(ctx context.Context, name, version, path string) (dependencies []*api.Dependency, err error)
func (*SQLQuerier) GetImagesForBundle ¶
func (*SQLQuerier) GetLatestChannelEntriesThatProvide ¶
func (s *SQLQuerier) GetLatestChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*registry.ChannelEntry, err error)
Get latest channel entries that provide an api
func (*SQLQuerier) GetPackage ¶
func (s *SQLQuerier) GetPackage(ctx context.Context, name string) (*registry.PackageManifest, error)
func (*SQLQuerier) GetPropertiesForBundle ¶
func (*SQLQuerier) ListBundles ¶
func (*SQLQuerier) ListChannels ¶
func (*SQLQuerier) ListImages ¶
func (s *SQLQuerier) ListImages(ctx context.Context) ([]string, error)
func (*SQLQuerier) ListPackages ¶
func (s *SQLQuerier) ListPackages(ctx context.Context) ([]string, error)
ListPackages returns a list of package names as strings
func (*SQLQuerier) ListRegistryBundles ¶
ListRegistryBundles returns a set of registry bundles. The set can be filtered by package by setting the given context's 'package' key to a desired package name. e.g. ctx := ContextWithPackage(context.TODO(), "etcd") bundles, err := querier.ListRegistryBundles(ctx) // ...
func (*SQLQuerier) ListTables ¶
func (s *SQLQuerier) ListTables(ctx context.Context) ([]string, error)
func (*SQLQuerier) PackageFromDefaultChannelHeadBundle ¶
func (s *SQLQuerier) PackageFromDefaultChannelHeadBundle(ctx context.Context, bundle string) (string, error)
PackageFromDefaultChannelHeadBundle returns the package name if the provided bundle is the head of its default channel.
func (*SQLQuerier) SendBundles ¶
func (s *SQLQuerier) SendBundles(ctx context.Context, stream registry.BundleSender) error
type SQLRemover ¶
type SQLRemover interface {
Remove() error
}
type SQLStrandedBundleRemover ¶
type SQLStrandedBundleRemover interface {
Remove() error
}
type SQLiteQuerierOption ¶
type SQLiteQuerierOption func(*querierConfig)
func OmitManifests ¶
func OmitManifests(b bool) SQLiteQuerierOption
If true, ListBundles will omit inline manifests (the object and csvJson fields) from response elements that contain a bundle image reference.
type StrandedBundleRemover ¶
type StrandedBundleRemover struct {
// contains filtered or unexported fields
}
StrandedBundleRemover removes stranded bundles from the database
func NewSQLStrandedBundleRemover ¶
func NewSQLStrandedBundleRemover(store registry.Load) *StrandedBundleRemover
func (*StrandedBundleRemover) Remove ¶
func (d *StrandedBundleRemover) Remove() error