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

Define and implement an OpenAPI spec in the backend #141

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

aliok
Copy link
Member

@aliok aliok commented Jan 7, 2025

Instead of #138

Changes

Switched to using a /getEventMesh path, instead of serving from / directly.

No other behavior change!

Motivation:

  • We can have more structure
  • We can generate a JS/TS client in the plugin
  • When we make changes in the behavior, we can make sure we're doing it explicitly by updating the OpenAPI spec

/kind

Fixes #

Release Note


Docs


Copy link

knative-prow bot commented Jan 7, 2025

@aliok: The label(s) kind/<kind> cannot be applied, because the repository doesn't have them.

In response to this:

Instead of #138

No behavior change.

  • Define and implement an OpenAPI spec in the backend

Changes

/kind

Fixes #

Release Note


Docs


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.

@knative-prow knative-prow bot requested review from Leo6Leo and pierDipi January 7, 2025 13:02
@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 7, 2025
@knative-prow knative-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 7, 2025
Signed-off-by: Ali Ok <[email protected]>
@aliok
Copy link
Member Author

aliok commented Jan 7, 2025

cc @pierDipi

Comment on lines +18 to +36
// TODO: remove
// convertEventType converts a Knative Eventing EventType to a simplified representation that is easier to consume by the Backstage plugin.
// see EventType.
func convertEventType(et *v1beta2.EventType) EventType {
return EventType{
Name: et.Name,
Namespace: et.Namespace,
Type: et.Spec.Type,
UID: string(et.UID),
Description: et.Spec.Description,
SchemaData: et.Spec.SchemaData,
SchemaURL: et.Spec.Schema.String(),
Uid: string(et.UID),
Description: ToStrPtrOrNil(et.Spec.Description),
SchemaData: ToStrPtrOrNil(et.Spec.SchemaData),
SchemaURL: ToStrPtrOrNil(et.Spec.Schema.String()),
Labels: et.Labels,
Annotations: FilterAnnotations(et.Annotations),
Reference: ToStrPtrOrNil(NamespacedRefName(et.Spec.Reference)),
// this field will be populated later on, when we have process the triggers
ConsumedBy: make([]string, 0),
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to be removed when we're switching to v1beta3 EventTypes

Comment on lines +40 to 67
func convertEventTypev1beta3(et *v1beta3.EventType) EventType {
cet := EventType{
Name: et.Name,
Namespace: et.Namespace,
Uid: string(et.UID),
Description: ToStrPtrOrNil(et.Spec.Description),
Labels: et.Labels,
Annotations: FilterAnnotations(et.Annotations),
Reference: NamespacedRefName(et.Spec.Reference),
Reference: ToStrPtrOrNil(NamespacedRefName(et.Spec.Reference)),
// this field will be populated later on, when we have process the triggers
ConsumedBy: make([]string, 0),
}

if len(et.Spec.Attributes) == 0 {
return cet
}

for _, attr := range et.Spec.Attributes {
switch attr.Name {
case "type": // TODO: any CE constant for these?
cet.Type = attr.Value
case "schemadata":
cet.SchemaURL = ToStrPtrOrNil(attr.Value)
}
}

return cet
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I can actually remove this part as we don't use v1beta3 EventTypes at this stage of this PR

@aliok
Copy link
Member Author

aliok commented Jan 7, 2025

/test e2e-tests

then
echo "${REPO_ROOT_DIR} is up to date."
else
echo "ERROR: ${REPO_ROOT_DIR} is out of date. Please run ./hack/update-templates.sh"
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the message be ... Please run ./hack/update-go-codegen.sh ?

Copy link
Member

Choose a reason for hiding this comment

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

I think we need to call this in https://github.com/knative-extensions/backstage-plugins/blob/main/hack/update-codegen.sh as that's the one the bots call or everyone contributing to Knative runs

Copy link
Member

Choose a reason for hiding this comment

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

I think we need to call this script in https://github.com/knative-extensions/backstage-plugins/blob/main/hack/verify-codegen.sh as that's the one tests run to verify the code generated

Signed-off-by: Ali Ok <[email protected]>
@aliok
Copy link
Member Author

aliok commented Jan 14, 2025

@pierDipi can you take a new look?

Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 15, 2025
Copy link

knative-prow bot commented Jan 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliok, pierDipi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot merged commit a625a17 into knative-extensions:main Jan 15, 2025
22 of 23 checks passed
@aliok aliok deleted the 2025-01-03-openapi-spec-2 branch January 15, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants