This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
[Add] Support for other Install strategies #772
Closed
varshaprasad96
wants to merge
1
commit into
operator-framework:main
from
varshaprasad96:support/watchnamespaces
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ type Plain struct { | |
Objects []client.Object | ||
} | ||
|
||
func RegistryV1ToPlain(rv1 fs.FS) (fs.FS, error) { | ||
func RegistryV1ToPlain(rv1 fs.FS, watchNamespaces []string) (fs.FS, error) { | ||
reg := RegistryV1{} | ||
fileData, err := fs.ReadFile(rv1, filepath.Join("metadata", "annotations.yaml")) | ||
if err != nil { | ||
|
@@ -102,7 +102,7 @@ func RegistryV1ToPlain(rv1 fs.FS) (fs.FS, error) { | |
} | ||
} | ||
|
||
plain, err := Simple(reg) | ||
plain, err := Simple(reg, watchNamespaces) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -165,8 +165,8 @@ func validateTargetNamespaces(supportedInstallModes sets.Set[string], installNam | |
return fmt.Errorf("supported install modes %v do not support target namespaces %v", sets.List[string](supportedInstallModes), targetNamespaces) | ||
} | ||
|
||
func Simple(in RegistryV1) (*Plain, error) { | ||
return Convert(in, "", nil) | ||
func Simple(in RegistryV1, watchNamespaces []string) (*Plain, error) { | ||
return Convert(in, "", watchNamespaces) | ||
} | ||
Comment on lines
+168
to
170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd just drop the |
||
|
||
func saNameOrDefault(saName string) string { | ||
|
@@ -189,9 +189,6 @@ func Convert(in RegistryV1, installNamespace string, targetNamespaces []string) | |
supportedInstallModes.Insert(string(im.Type)) | ||
} | ||
} | ||
if !supportedInstallModes.Has(string(v1alpha1.InstallModeTypeAllNamespaces)) { | ||
return nil, fmt.Errorf("AllNamespace install mode must be enabled") | ||
} | ||
if targetNamespaces == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind changing this to check for len=0 instead please? |
||
if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeAllNamespaces)) { | ||
targetNamespaces = []string{""} | ||
|
@@ -274,15 +271,18 @@ func Convert(in RegistryV1, installNamespace string, targetNamespaces []string) | |
permissions = nil | ||
} | ||
|
||
for _, permission := range permissions { | ||
saName := saNameOrDefault(permission.ServiceAccountName) | ||
name, err := generateName(fmt.Sprintf("%s-%s", in.CSV.Name, saName), permission) | ||
if err != nil { | ||
return nil, err | ||
for _, ns := range targetNamespaces { | ||
ncdc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, permission := range permissions { | ||
saName := saNameOrDefault(permission.ServiceAccountName) | ||
name, err := generateName(fmt.Sprintf("%s-%s", in.CSV.Name, saName), permission) | ||
if err != nil { | ||
return nil, err | ||
} | ||
roles = append(roles, newRole(ns, name, permission.Rules)) | ||
roleBindings = append(roleBindings, newRoleBinding(ns, name, name, installNamespace, saName)) | ||
} | ||
roles = append(roles, newRole(installNamespace, name, permission.Rules)) | ||
roleBindings = append(roleBindings, newRoleBinding(installNamespace, name, name, installNamespace, saName)) | ||
} | ||
|
||
for _, permission := range clusterPermissions { | ||
saName := saNameOrDefault(permission.ServiceAccountName) | ||
name, err := generateName(fmt.Sprintf("%s-%s", in.CSV.Name, saName), permission) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmm. I had imagined that we'd put this on the BundleDeployment, not the Bundle. But the wrinkle with needing to generate extra RBAC during the conversion means this is essential information in that step.
One possible solution here would be to make a registry BundleDeployment provisioner and move the conversion logic there. If we did that, we could probably make the Bundle provisioner super generic and reusable for registry/plain/helm/etc. Basically it would just be a "give me the filesystem with no format-specific validation" provisioner. And then the BD would be the place for registry/plain/helm to have separate provisioners and do whatever specific validation was necessary.
From an API design standpoint, I argue that configuration of the templating of the bundle belongs in the BundleDeployment.
All of this highlights the weird dichotomy between Bundle and BundleDeployment, and I think it's another good reason to move to a single API for "source/template/apply" like the Carvel App API. I think moving toward a super-generic Bundle provisioner gets us more aligned with that concept anyway, so perhaps that would be a good step in that direction?
What do you think?
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 missed this was on Bundle and not BundleDeployment. +100 to getting rid of Bundle. @varshaprasad96 if you're around this week and want help, please let me know.
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.
@joelanford @ncdc fair. The reason for having this on template, was to be able to pass this to bundle provisioner which handles the conversion. If we move that logic to
Bundle
, there doesn't seem to be much value in having a separate API.Removing Bundle would change the BundleDeployment API, we would need an alpha2? Nevertheless, I'll get a draft PR ready, and we can discuss the specifics of the API there.
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.
Yes to alpha2