-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat: add permitOnlyProjectScopedClusters flag #10237
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,7 +419,17 @@ func (m *appStateManager) CompareAppState(app *v1alpha1.Application, project *ap | |
|
||
// filter out all resources which are not permitted in the application project | ||
for k, v := range liveObjByKey { | ||
if !project.IsLiveResourcePermitted(v, app.Spec.Destination.Server, app.Spec.Destination.Name) { | ||
permitted, err := project.IsLiveResourcePermitted(v, app.Spec.Destination.Server, app.Spec.Destination.Name, func(project string) ([]*appv1.Cluster, error) { | ||
return m.db.GetProjectClusters(context.TODO(), project) | ||
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 added |
||
}) | ||
|
||
if err != 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. Not sure if this block is the right way to do this; I suspect that this also needs tests |
||
conditions = append(conditions, v1alpha1.ApplicationCondition{Type: v1alpha1.ApplicationConditionComparisonError, Message: err.Error(), LastTransitionTime: &now}) | ||
failedToLoadObjs = true | ||
continue | ||
} | ||
|
||
if !permitted { | ||
delete(liveObjByKey, k) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,8 +226,18 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha | |
if !proj.IsGroupKindPermitted(un.GroupVersionKind().GroupKind(), res.Namespaced) { | ||
return fmt.Errorf("resource %s:%s is not permitted in project %s", un.GroupVersionKind().Group, un.GroupVersionKind().Kind, proj.Name) | ||
} | ||
if res.Namespaced && !proj.IsDestinationPermitted(v1alpha1.ApplicationDestination{Namespace: un.GetNamespace(), Server: app.Spec.Destination.Server, Name: app.Spec.Destination.Name}) { | ||
return fmt.Errorf("namespace %v is not permitted in project '%s'", un.GetNamespace(), proj.Name) | ||
if res.Namespaced { | ||
permitted, err := proj.IsDestinationPermitted(v1alpha1.ApplicationDestination{Namespace: un.GetNamespace(), Server: app.Spec.Destination.Server, Name: app.Spec.Destination.Name}, func(project string) ([]*v1alpha1.Cluster, error) { | ||
return m.db.GetProjectClusters(context.TODO(), project) | ||
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 added context.TODO() as a placeholder, but should probably be something else |
||
}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
if !permitted { | ||
return fmt.Errorf("namespace %v is not permitted in project '%s'", un.GetNamespace(), proj.Name) | ||
} | ||
} | ||
return nil | ||
}), | ||
|
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 not a big fan of silencing errors, we should probably change the signature of
IterateHierarchy
to return an error itself