-
Notifications
You must be signed in to change notification settings - Fork 78
Remove registry dependency #35
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
Remove registry dependency #35
Conversation
a2e7b64
to
2ce8cb5
Compare
2ce8cb5
to
6348456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On first pass, looks good. Some questions/nits.
pkg/manifests/bundle.go
Outdated
Channels []string | ||
DefaultChannel string | ||
BundleImage string | ||
Csv *operatorsv1alpha1.ClusterServiceVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Csv *operatorsv1alpha1.ClusterServiceVersion | |
CSV *operatorsv1alpha1.ClusterServiceVersion |
pkg/manifests/bundle.go
Outdated
DefaultChannel string | ||
BundleImage string | ||
Csv *operatorsv1alpha1.ClusterServiceVersion | ||
V1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition | |
V1beta1CRDs []*apiextensionsv1beta1.CustomResourceDefinition |
pkg/manifests/bundle.go
Outdated
BundleImage string | ||
Csv *operatorsv1alpha1.ClusterServiceVersion | ||
V1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition | ||
V1crds []*apiextensionsv1.CustomResourceDefinition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V1crds []*apiextensionsv1.CustomResourceDefinition | |
V1CRDs []*apiextensionsv1.CustomResourceDefinition |
} | ||
|
||
decoder := yaml.NewYAMLOrJSONDecoder(fileReader, 30) | ||
csv := unstructured.Unstructured{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be more than one manifest per file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is a totally fair point, and one we should address, currently the registry doesn't parse multi manifest yaml files either. IMO if we want to allow them we should update the registry first so that we aren't allowing things that won't work on the unpacking side.
@@ -0,0 +1,13 @@ | |||
apiVersion: apiextensions.k8s.io/v1beta1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename pkg/validation/test_data
to pkg/validation/testdata
?
@@ -0,0 +1,37 @@ | |||
package manifests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this makes more sense in a metadata
package?
pkg/manifests/loader.go
Outdated
return utilerrors.NewAggregate(errs) | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going away because it's still WIP?
Or is it going away because we now treat the union of CRDs in the bundle and spec.customresourcedefinitions as "provided", so this is less useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is still valid as a validation of the CSV itself to say "Hey you said you provided these APIs, is that actually the case in your bundle?"
My intention was actually that this check should be defined as part of the validation. It seems very weird to do this specifically for this subset when many of the other bundle validations are implemented in the validation package. It only happened initially that way, I assume, because this code was originally embedded into the registry serialization code.
Commenting it out was supposed to remind me to do that, but it seems like I just overlooked it. I'll update this to reimplement it.
// GetManifestsDir parses all bundles and a package manifest from dir, which | ||
// are returned if found along with any errors or warnings encountered while | ||
// parsing/validating found manifests. | ||
func GetManifestsDir(dir string) (registry.PackageManifest, []*registry.Bundle, []errors.ManifestResult) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still something the SDK needs for run packagemanifests
. Will a function that returns a PackageManifest
and []Bundle
exist somewhere else?
Worst case the SDK can implement it, but seeing as the package manifests format will be supported indefinitely and GetBundleFromDir
is implemented here, this should probably stick around right?
) | ||
|
||
// PackageManifestValidator implements Validator to validate package manifests. | ||
var PackageManifestValidator = internal.PackageManifestValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will be moved to operator-registry, like the bundle validator was? The SDK uses this validator but not the PackageUpdateGraphValidator
.
6348456
to
6175388
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
||
var errs []error | ||
bundle := &Bundle{ | ||
Name: csvName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick q: would this make more sense as a plain semver string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, definitely, especially given the future where a csv is no longer required in future bundle versions. For backwards compatibility though, we need to use this as the unique identifier because version itself is an optional field.
pkg/manifests/bundleloader.go
Outdated
return nil, fmt.Errorf("unsupported CRD version %s for %s", version, f.Name()) | ||
} | ||
default: | ||
bundle.Objects = append(bundle.Objects, obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One difference I found between this implementation and that in OR: all objects in a bundle, including CSVs and CRDs, are appended to Bundle.Objects
. Is it reasonable to have the same behavior here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, it is totally reasonable and the correct behavior. I'll push a change to this pr
6175388
to
6deb059
Compare
/lgtm |
var PackageManifestValidator interfaces.Validator = interfaces.ValidatorFunc(validatePackageManifests) | ||
|
||
func validatePackageManifests(objs ...interface{}) (results []errors.ManifestResult) { | ||
fmt.Println("trying to validate package manifests") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevinrizza some leftover print statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch, okay updated :)
switch v := obj.(type) { | ||
case *registry.PackageManifest: | ||
case *manifests.PackageManifest: | ||
fmt.Println("found a package manifest in the list of objects") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too
* Remove all references to operator-framework/operator-registry * Update the type serialization and validation to use a new external api type for operator bundle, which now explicitly parses the public CRD and CSV types * Redefine the serialization functions to simply provide the types without explicitly running validation against them
6deb059
to
eb083ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good but one comment.
version := obj.GetAPIVersion() | ||
if version == apiextensionsv1beta1.SchemeGroupVersion.String() { | ||
crd := apiextensionsv1beta1.CustomResourceDefinition{} | ||
err := runtime.DefaultUnstructuredConverter.FromUnstructured( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string-to-unstructured-to-crd conversion is the root cause of int64 to float64
error. So we should avoid converting unstructured
to a specific type. Should only use unstructured
to determine the object type and then convert string data straight to the object type like CRD. See: https://github.com/operator-framework/operator-registry/pull/334/files#diff-b754381164690e8ba263f719136845d3R320
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this behavior defined for unstructured conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this issue can be addressed in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with fixing this at another time. Please make a note somewhere so it won't get lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
No description provided.