Skip to content

Commit 574aecf

Browse files
authored
Merge pull request #985 from alecmerdler/OLM-1211-proposal
Proposal for PackageManifest Icon Subresource
2 parents aa1fc6c + dc36069 commit 574aecf

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Operator Package Logos
2+
3+
Status: Pending
4+
5+
Version: Alpha
6+
7+
Implementation Owner: [@alecmerdler](github.com/alecmerdler)
8+
9+
# Motivation
10+
11+
Having logo icons for Operator packages is important. Currently, we include the base64-encoded representation of the image data in the `PackageManifest` API object itself. This data is not small. Even for a trivial number of Operator packages, the API response is quite large, which is a poor experience for clients. For example, a `PackageManifestList` with 65 Operators is ~1.9MB _with logos_; removing the logos reduces the size to ~450 KB.
12+
13+
# Proposed Changes
14+
15+
Add a new [API subresource](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds) to `PackageManifest` which serves the associated logo image file.
16+
17+
## Implementation
18+
19+
Add subresource following `pods/log` example in [core Kubernetes apiserver code](https://sourcegraph.com/github.com/kubernetes/kubernetes@master/-/blob/pkg/registry/core/rest/storage_core.go#L230).
20+
21+
22+
**Add subresource to both API groups:**
23+
24+
`pkg/package-server/apiserver/generic/storage.go`
25+
```go
26+
func BuildStorage(providers *ProviderConfig) []generic.APIGroupInfo {
27+
// Build storage for packages.operators.coreos.com
28+
operatorInfo := generic.NewDefaultAPIGroupInfo(v1.Group, Scheme, metav1.ParameterCodec, Codecs)
29+
operatorStorage := storage.NewStorage(v1.Resource("packagemanifests"), providers.Provider, Scheme)
30+
logoStorage := storage.NewLogoStorage(providers.Provider)
31+
operatorResources := map[string]rest.Storage{
32+
"packagemanifests": operatorStorage,
33+
"packagemanifests/logo": logoStorage,
34+
}
35+
operatorInfo.VersionedResourcesStorageMap[v1.Version] = operatorResources
36+
37+
// Build storage for packages.apps.redhat.com
38+
appInfo := generic.NewDefaultAPIGroupInfo(v1alpha1.Group, Scheme, metav1.ParameterCodec, Codecs)
39+
40+
// Use storage for package.operators.coreos.com since types are identical
41+
appResources := map[string]rest.Storage{
42+
"packagemanifests": operatorStorage,
43+
"packagemanifests/logo": logoStorage,
44+
}
45+
appInfo.VersionedResourcesStorageMap[v1alpha1.Version] = appResources
46+
47+
return []generic.APIGroupInfo{
48+
operatorInfo,
49+
appInfo,
50+
}
51+
}
52+
```
53+
54+
**Implement logo storage struct**
55+
56+
`pkg/package-server/storage/subresources.go`
57+
```go
58+
type LogoStorage struct {
59+
prov provider.PackageManifestProvider
60+
}
61+
62+
var _ rest.Connecter = &LogoStorage{}
63+
var _ rest.StorageMetadata = &LogoStorage{}
64+
65+
// Implement the necessary methods below...
66+
```
67+
68+
# Next Stage
69+
70+
Once the logos are being served from the subresource, console will be updated to fetch the images from those endpoints. Then we can remove the `icon` field completely from the `PackageManifest` object and benefit from the size reduction.
71+

0 commit comments

Comments
 (0)