Skip to content

Commit fbe246a

Browse files
ecordellankitathomas
authored andcommitted
Merge pull request openshift#1 from ecordell/basic-registry
Data storage for registry API (upstream operator-registry commit: 3ebf38cfd6d676230293c4588e5b3e6e5e90559e)
1 parent 15b0a40 commit fbe246a

File tree

466 files changed

+83033
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

466 files changed

+83033
-7
lines changed

staging/operator-registry/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ RUN apk update && apk add sqlite build-base
44
WORKDIR /go/src/github.com/operator-framework/operator-registry
55

66
COPY vendor vendor
7-
COPY cmd cmd
8-
COPY pkg pkg
9-
RUN go build --tags json1 -o ./initializer ./cmd/init/...
7+
COPY init init
8+
COPY store store
9+
RUN go build --tags json1 -o ./initializer ./init/...
1010

1111
COPY manifests manifests
1212
RUN ./initializer

staging/operator-registry/Gopkg.lock

Lines changed: 154 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/operator-registry/Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
name = "github.com/mattn/go-sqlite3"
3030
version = "1.9.0"
3131

32+
[[constraint]]
33+
name = "github.com/operator-framework/operator-lifecycle-manager"
34+
version = "0.7.1"
35+
3236
[[constraint]]
3337
name = "github.com/sirupsen/logrus"
3438
version = "1.0.6"

staging/operator-registry/init.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE operatorbundle (
2+
id INTEGER,
3+
name TEXT,
4+
csv TEXT,
5+
bundle TEXT
6+
);
7+
CREATE TABLE package (
8+
id INTEGER,
9+
name TEXT,
10+
);
11+
CREATE TABLE channel (
12+
name TEXT,
13+
package_id INTEGER,
14+
operatorbundle_id INTEGER,
15+
FOREIGN KEY(package_id) REFERENCES package(id),
16+
FOREIGN KEY(operatorbundle_id) REFERENCES operatorbundle(id)
17+
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package main
2+
3+
import (
4+
"github.com/operator-framework/operator-registry/store"
5+
"github.com/sirupsen/logrus"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func main() {
10+
var rootCmd = &cobra.Command{
11+
Short: "initializer",
12+
Long: `initializer takes a directory of OLM manifests and outputs a sqlite database containing them`,
13+
14+
PreRunE: func(cmd *cobra.Command, args []string) error {
15+
if debug, _ := cmd.Flags().GetBool("debug"); debug {
16+
logrus.SetLevel(logrus.DebugLevel)
17+
}
18+
return nil
19+
},
20+
21+
RunE: runCmdFunc,
22+
}
23+
24+
rootCmd.Flags().Bool("debug", false, "enable debug logging")
25+
rootCmd.Flags().StringP("manifests", "m", "manifests", "relative path to directory of manifests")
26+
rootCmd.Flags().StringP("output", "o", "bundles.db", "relative path to a sqlite file to create or overwrite")
27+
if err := rootCmd.Flags().MarkHidden("debug"); err != nil {
28+
panic(err)
29+
}
30+
31+
if err := rootCmd.Execute(); err != nil {
32+
panic(err)
33+
}
34+
}
35+
36+
func runCmdFunc(cmd *cobra.Command, args []string) error {
37+
outFilename, err := cmd.Flags().GetString("output")
38+
if err != nil {
39+
return err
40+
}
41+
manifestDir, err := cmd.Flags().GetString("manifests")
42+
if err != nil {
43+
return err
44+
}
45+
46+
dbLoader, err := store.NewSQLLiteLoader(outFilename)
47+
if err != nil {
48+
logrus.Fatal(err)
49+
}
50+
defer dbLoader.Close()
51+
52+
loader := store.NewSQLLoaderForDirectory(dbLoader, manifestDir)
53+
if err := loader.Populate(); err != nil {
54+
logrus.Fatal(err)
55+
}
56+
57+
return nil
58+
}

0 commit comments

Comments
 (0)