-
Notifications
You must be signed in to change notification settings - Fork 67
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: print all resources #78
Conversation
Skipping CI for Draft Pull Request. |
72189f5
to
f8d7498
Compare
f8d7498
to
247fa79
Compare
247fa79
to
2f0df00
Compare
2f0df00
to
b5c5996
Compare
b5c5996
to
2028440
Compare
2028440
to
304eac6
Compare
304eac6
to
c431794
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.
Thank you @mlavacca!
I have some questions regarding a few things but overall it's seems like another great contribution to me.
b74031a
to
a540b97
Compare
@@ -39,7 +38,7 @@ func (r *resourceReader) readResourcesFromCluster(ctx context.Context) (*storage | |||
// read apisix related resources from cluster. | |||
storage := newResourcesStorage() | |||
|
|||
ingresses, err := common.ReadIngressesFromCluster(ctx, r.conf.Client, ApisixIngressClass) | |||
ingresses, err := i2gw.ReadIngressesFromCluster(ctx, r.conf.Client, ApisixIngressClass) |
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.
why ?
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 needed to move the resource-reader
files to the i2gw package to avoid the import cycle as with this change we read resources not only from the provider packages but from i2gw as well, as we want to read resources that do not have to be converted.
if _, ok := FilteredResources[o.GetObjectKind().GroupVersionKind().GroupKind()]; ok { | ||
continue |
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.
Trying to think if there is a different way to do it. I less like the fact that every provider needs to register its resources and that we depends on it.. I have not thought on anything smart yet.
But.. we should have all the resources the provider cares about (which are the resources that we need to filter out from the file) in its storage
.. Maybe we can leverage that?
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 guess we can add a GetCRDs()
method to the provider
interface. We have access to all the providers in i2gw
package, so we can do the registration in this package. Instead of having each one registering his own CRDs
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 followed @levikobi's suggestion and added a GetCRDs
method to the provider interface. Let me know if it looks better now. In that case, I'll add documentation about the new method for the providers to implement.
if _, ok := FilteredResources[o.GetObjectKind().GroupVersionKind().GroupKind()]; ok { | ||
continue |
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 guess we can add a GetCRDs()
method to the provider
interface. We have access to all the providers in i2gw
package, so we can do the registration in this package. Instead of having each one registering his own CRDs
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.
@mlavacca you moved some logic from common
to i2gw
, can you please explain why?
a540b97
to
5de027b
Compare
I needed to move the resource-reader files to the i2gw package to avoid the import cycle as with this change we read resources not only from the provider packages but from i2gw as well, as we want to read resources that do not have to be converted. |
Signed-off-by: Mattia Lavacca <[email protected]>
5de027b
to
25cff88
Compare
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
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.
Thanks @mlavacca, left some comments.
the move of logic from common to i2gw a bit bothers me because the function moved are actually common functions. Maybe we can come up with different package structure that will still accommodate the changes you introduced?
@@ -30,7 +32,7 @@ import ( | |||
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" | |||
) | |||
|
|||
func ToGatewayAPIResources(ctx context.Context, namespace string, inputFile string, providers []string, providerSpecificFlags map[string]map[string]string) ([]GatewayResources, error) { | |||
func GetResources(ctx context.Context, namespace string, inputFile string, allresources bool, providers []string, providerSpecificFlags map[string]map[string]string) ([]client.Object, error) { |
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 we leave some version of the old name (ToGatewayAPIResources
) and return []client.Object, []client.Object, error
? GetResources does not really reflect what the function is doing
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.
or []GatewayResources, []client.Object, error
return append(gatewayResourcesToObjects(gatewayResources), genericResources...), nil | ||
} | ||
|
||
func gatewayResourcesToObjects(gatewayResources []GatewayResources) []client.Object { |
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 we add a small function comment, also mention the order it returns the resources
for _, p := range providerByName { | ||
for _, crd := range p.GetCRDs() { | ||
FilteredResources[crd] = struct{}{} | ||
} | ||
} |
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.
haven't thought much about it, but what are your thoughts on this approach VS every provider registers the resources he cares about in init()
.
I am not sure what I prefer, slight preference to what you currently have but wanted to discuss this
func (p *Provider) GetCRDs() []schema.GroupKind { | ||
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.
similar comment below on how we handle, provider == kong
but ingress is gce. The implemented approach here would not print the gce ingress (although it hasn't been converted)
ingressClassGK: {}, | ||
ingressGK: {}, | ||
} |
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.
re mentioning the comment about not differentiating between ingress of different providers when running with --all-resources
networkingv1beta1 "k8s.io/api/networking/v1beta1" | ||
) | ||
|
||
func GetIngressClass(ingress networkingv1.Ingress) 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.
we already have similar function in common, why not using it?
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
When reading the resources from a file, it is now possible to display all the resources, not only the Gateway API ones. Besides, the
PROVIDER.md
file has been properly formatted.Which issue(s) this PR fixes:
Fixes #73
Does this PR introduce a user-facing change?: