Skip to content

Commit 818ce2b

Browse files
committed
feat(registry): Add operator version dependency metadata
The operator-version based dependency information can be added to a bundle via dependencies.yaml in /metadata. The dependencies info will be parsed and is added to the DB in a new table named `dependencies`. Each dependency entry is linked to a specific operator bundle that it belongs to. A new registry API `ListBundles` is added to return all available bundles in the database. This information is to serve as input to the new resolver. Signed-off-by: Vu Dinh <[email protected]>
1 parent 489146a commit 818ce2b

File tree

9 files changed

+641
-13
lines changed

9 files changed

+641
-13
lines changed

pkg/api/registry.proto

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ service Registry {
1212
rpc GetChannelEntriesThatProvide(GetAllProvidersRequest) returns (stream ChannelEntry) {}
1313
rpc GetLatestChannelEntriesThatProvide(GetLatestProvidersRequest) returns (stream ChannelEntry) {}
1414
rpc GetDefaultBundleThatProvides(GetDefaultProviderRequest) returns (Bundle) {}
15+
rpc ListBundles() returns (stream Bundle) {}
1516
}
1617

1718

@@ -37,6 +38,14 @@ message GroupVersionKind{
3738
string plural = 4;
3839
}
3940

41+
message Dependency{
42+
string type = 1;
43+
string name = 2;
44+
string group = 3;
45+
string version = 4;
46+
string kind = 5;
47+
}
48+
4049
message Bundle{
4150
string csvName = 1;
4251
string packageName = 2;
@@ -48,6 +57,7 @@ message Bundle{
4857
repeated GroupVersionKind requiredApis = 8;
4958
string version = 9;
5059
string skipRange = 10;
60+
repeated Dependency dependencies = 11;
5161
}
5262

5363
message ChannelEntry{
@@ -104,4 +114,3 @@ message GetDefaultProviderRequest{
104114
string kind = 3;
105115
string plural = 4;
106116
}
107-

pkg/registry/bundle.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ func init() {
2828
}
2929

3030
type Bundle struct {
31-
Name string
32-
Objects []*unstructured.Unstructured
33-
Package string
34-
Channels []string
35-
BundleImage string
36-
csv *ClusterServiceVersion
37-
crds []*v1beta1.CustomResourceDefinition
38-
cacheStale bool
31+
Name string
32+
Objects []*unstructured.Unstructured
33+
Package string
34+
Channels []string
35+
BundleImage string
36+
csv *ClusterServiceVersion
37+
crds []*v1beta1.CustomResourceDefinition
38+
Dependencies []Dependency
39+
cacheStale bool
3940
}
4041

4142
func NewBundle(name, pkgName string, channels []string, objs ...*unstructured.Unstructured) *Bundle {

pkg/registry/interface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ type Query interface {
5151
ListChannels(ctx context.Context, pkgName string) ([]string, error)
5252
// Get CurrentCSV name for channel and package
5353
GetCurrentCSVNameForChannel(ctx context.Context, pkgName, channel string) (string, error)
54+
// List all available bundles in the database
55+
ListBundles(ctx context.Context) (bundles []*api.Bundle, err error)
56+
// Get the list of dependencies for a bundle
57+
GetDependenciesForBundle(ctx context.Context, name, version, path string) (dependencies []*api.Dependency, err error)
5458
}
5559

5660
// GraphLoader generates a graph

pkg/registry/types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,71 @@ type Annotations struct {
114114
DefaultChannelName string `json:"operators.operatorframework.io.bundle.channel.default.v1" yaml:"operators.operatorframework.io.bundle.channel.default.v1"`
115115
}
116116

117+
// DependenciesFile holds dependency information about a bundle
118+
type DependenciesFile struct {
119+
// Dependencies is a list of dependencies for a given bundle
120+
Dependencies []Dependency `json:"dependencies" yaml:"dependencies"`
121+
}
122+
123+
// Dependencies is a list of dependencies for a given bundle
124+
type Dependency struct {
125+
// The type of dependency. It can be `olm.package` for operator-version based
126+
// dependency or `olm.gvk` for gvk based dependency. This field is required.
127+
Type string `json:"type" yaml:"type"`
128+
129+
// The name of dependency such as 'etcd'. This field is required.
130+
Name string `json:"name" yaml:"name"`
131+
132+
// The group of GVK based dependency.
133+
Group string `json:"group,omitempty" yaml:"group"`
134+
135+
// The kind of GVK based dependency.
136+
Kind string `json:"kind,omitempty" yaml:"kind"`
137+
138+
// The version of dependency in semver format
139+
Version string `json:"version" yaml:"version"`
140+
}
141+
142+
// GetType returns the type of dependency
143+
func (e *Dependency) GetType() string {
144+
if e.Type != "" {
145+
return e.Type
146+
}
147+
return ""
148+
}
149+
150+
// GetName returns the package name of dependency
151+
func (e *Dependency) GetName() string {
152+
if e.Name != "" {
153+
return e.Name
154+
}
155+
return ""
156+
}
157+
158+
// GetGroup returns the group name of dependency
159+
func (e *Dependency) GetGroup() string {
160+
if e.Group != "" {
161+
return e.Group
162+
}
163+
return ""
164+
}
165+
166+
// GetKind returns the kind of dependency
167+
func (e *Dependency) GetKind() string {
168+
if e.Kind != "" {
169+
return e.Kind
170+
}
171+
return ""
172+
}
173+
174+
// GetVersion returns the version of dependency
175+
func (e *Dependency) GetVersion() string {
176+
if e.Version != "" {
177+
return e.Version
178+
}
179+
return ""
180+
}
181+
117182
// GetName returns the package name of the bundle
118183
func (a *AnnotationsFile) GetName() string {
119184
if a.Annotations.PackageName != "" {

0 commit comments

Comments
 (0)