Skip to content

Package cleanup #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ RUN apk update && apk add sqlite build-base
WORKDIR /go/src/github.com/operator-framework/operator-registry

COPY vendor vendor
COPY init init
COPY store store
RUN go build --tags json1 -o ./initializer ./init/...
COPY cmd cmd
COPY pkg pkg
RUN go build --tags json1 -o ./initializer ./cmd/init/...

COPY manifests manifests
RUN ./initializer
Expand Down
158 changes: 4 additions & 154 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
name = "github.com/mattn/go-sqlite3"
version = "1.9.0"

[[constraint]]
name = "github.com/operator-framework/operator-lifecycle-manager"
version = "0.7.1"

[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.0.6"
Expand Down
6 changes: 3 additions & 3 deletions init/main.go → cmd/init/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/operator-framework/operator-registry/store"
"github.com/operator-framework/operator-registry/pkg/sqlite"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -43,13 +43,13 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {
return err
}

dbLoader, err := store.NewSQLLiteLoader(outFilename)
dbLoader, err := sqlite.NewSQLLiteLoader(outFilename)
if err != nil {
logrus.Fatal(err)
}
defer dbLoader.Close()

loader := store.NewSQLLoaderForDirectory(dbLoader, manifestDir)
loader := sqlite.NewSQLLoaderForDirectory(dbLoader, manifestDir)
if err := loader.Populate(); err != nil {
logrus.Fatal(err)
}
Expand Down
17 changes: 0 additions & 17 deletions init.sql

This file was deleted.

30 changes: 30 additions & 0 deletions pkg/registry/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package registry

import (
"context"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

type Load interface {
AddOperatorBundle(bundleObjs []*unstructured.Unstructured) error
AddPackageChannels(manifest PackageManifest) error
AddProvidedApis() error
}

type Query interface {
ListPackages(context context.Context) ([]string, error)
GetPackage(context context.Context, name string) (*PackageManifest, error)
GetBundleForChannel(context context.Context, pkgName string, channelName string) (string, error)
GetBundleForName(context context.Context, name string) (string, error)
// Get all channel entries that say they replace this one
GetChannelEntriesThatReplace(context context.Context, name string) (entries []ChannelEntry, err error)
// Get the bundle in a package/channel that replace this one
GetBundleThatReplaces(context context.Context, name, pkgName, channelName string) (string, error)
// Get all channel entries that provide an api
GetChannelEntriesThatProvide(context context.Context, groupOrName, version, kind string) (entries []ChannelEntry, err error)
// Get latest channel entries that provide an api
GetLatestChannelEntriesThatProvide(context context.Context, groupOrName, version, kind string) (entries []ChannelEntry, err error)
// Get the the latest bundle that provides the API in a default channel
GetBundleThatProvides(context context.Context, groupOrName, version, kind string) (string, error)
}
52 changes: 52 additions & 0 deletions pkg/registry/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package registry

// PackageManifest holds information about a package, which is a reference to one (or more)
// channels under a single package.
type PackageManifest struct {
// PackageName is the name of the overall package, ala `etcd`.
PackageName string `json:"packageName"`

// Channels are the declared channels for the package, ala `stable` or `alpha`.
Channels []PackageChannel `json:"channels"`

// DefaultChannelName is, if specified, the name of the default channel for the package. The
// default channel will be installed if no other channel is explicitly given. If the package
// has a single channel, then that channel is implicitly the default.
DefaultChannelName string `json:"defaultChannel"`
}

// GetDefaultChannel gets the default channel or returns the only one if there's only one. returns empty string if it
// can't determine the default
func (m PackageManifest) GetDefaultChannel() string {
if m.DefaultChannelName != "" {
return m.DefaultChannelName
}
if len(m.Channels) == 1 {
return m.Channels[0].Name
}
return ""
}

// PackageChannel defines a single channel under a package, pointing to a version of that
// package.
type PackageChannel struct {
// Name is the name of the channel, e.g. `alpha` or `stable`
Name string `json:"name"`

// CurrentCSVName defines a reference to the CSV holding the version of this package currently
// for the channel.
CurrentCSVName string `json:"currentCSV"`
}

// IsDefaultChannel returns true if the PackageChennel is the default for the PackageManifest
func (pc PackageChannel) IsDefaultChannel(pm PackageManifest) bool {
return pc.Name == pm.DefaultChannelName || len(pm.Channels) == 1
}

// ChannelEntry is a denormalized node in a channel graph
type ChannelEntry struct {
PackageName string
ChannelName string
BundleName string
Replaces string
}
Loading