Skip to content
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

Add Tagging to lattice target group resource #59

Merged
merged 6 commits into from
Dec 1, 2022

Conversation

liwenwu-amazon
Copy link
Contributor

Issue #, if available:

Description of changes:
Today, gateway controller create a lattice target group if a K8S service is referenced by K8S serviceexport object or referenced by a backendref of a HTTPRoute.

By adding the tags, gateway controller can track which serviceexport and httproute triggered creation of target group. And gateway controller can use it to delete unused target groups #15

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

createTargetGroupInput.Tags[latticemodel.K8SIsServiceExportKey] = &value
} else {
value := latticemodel.K8SIsNotServiceExport
createTargetGroupInput.Tags[latticemodel.K8SIsServiceExportKey] = &value
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i prefer string types instead of bool types for extensibility(in case targetGroup needed for other resources)
e.g. Tags[resourceType] = "serviceExport"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further, you can use a library to pointer-ify these for you inline: lo.ToPtr(string) or aws.String(string)

Comment on lines +39 to +43
IsServiceExport bool `json:"serviceexport"`
K8SServiceName string `json:"k8sservice"`
K8SServiceNamespace string `json:"k8sservicenamespace"`
K8SHTTPRouteName string `json:"k8shttproutename"`
K8SHTTPRouteNamespace string `json:"k8shttproutenamespace"`
Copy link
Contributor

@ellistarn ellistarn Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in thinking that this is a user facing API?

  1. We shouldn't be using k8s in the api field name
  2. The field should use camelcase
  3. Instead of hardcoding name and namespace, we should use something like this
ref:
    kind: HTTPRoute
    name: myname
    namespace: mynamespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these fields are internal.

Comment on lines 13 to 14
K8SIsServiceExport = "true"
K8SIsNotServiceExport = "false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
K8SIsServiceExport = "true"
K8SIsNotServiceExport = "false"
TrueString = "true"
FalseString = "false"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants