Skip to content

Updating the Java-SDK to the CDEvents Spec - v0.1.0#12

Closed
adamkenihan wants to merge 8 commits intocdevents:mainfrom
adamkenihan:sdk-update
Closed

Updating the Java-SDK to the CDEvents Spec - v0.1.0#12
adamkenihan wants to merge 8 commits intocdevents:mainfrom
adamkenihan:sdk-update

Conversation

@adamkenihan
Copy link
Copy Markdown
Contributor

@adamkenihan adamkenihan commented Nov 23, 2022

Updated events to align with version 0.1.0 spec as described with issue #11



private static String getVersion() {
return "0.1.0";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add this as static final constant class level variable.

@afrittoli
Copy link
Copy Markdown
Member

Thanks, @adamkenihan for this!

How do you plan on managing the migration to the new format?
If we merge this to main it might be worth adding a note to the README about only using a released version of this and not main - since the SDK would be in a mixed state until the migration is complete.

public static CloudEvent createTaskRunStartedEvent(
final String eventType, final String id,
final URI source, final String taskName,
final String pipelineRun, final URI url,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here the pipelineRun is an object of PipelineRun Event defined at https://github.com/cdevents/spec/blob/v0.1.0/core.md#pipelinerun instead of String

public static CloudEvent createTaskRunFinishedEvent(
final String eventType, final String id,
final URI source, final String taskName,
final String pipelineRun, final URI url,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above pipelineRun should be an object of PipelineRun Event

* @param pipelineName
* @param url
* @param errors
* @param outcome
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use Auto "generate element comment" for each method to add this Java doc and avoid declaring missing params, this resolves many of Lint code errors

.withExtension("name", name)
.withExtension("owner",owner)
.withExtension("url", url)
.withExtension("view", view)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

update this with the ("viewUrl", viewUrl), this field is viewUrl as per the spec

.withExtension("name", name)
.withExtension("owner",owner)
.withExtension("url", url)
.withExtension("view", view)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

update this with the ("viewUrl", viewUrl),

.withExtension("name", name)
.withExtension("owner",owner)
.withExtension("url", url)
.withExtension("view", view)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

update this with the ("viewUrl", viewUrl),

*/
public static CloudEvent createBranchCreatedEvent(
final String eventType, final String id,
final URI source, final String repository,
Copy link
Copy Markdown
Contributor

@rjalander rjalander Jan 9, 2023

Choose a reason for hiding this comment

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

repository should be an object of Repository, defined at https://github.com/cdevents/spec/blob/v0.1.0/source-code-version-control.md#repository,
Need the same change for all of the Branch and Change events below

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

@rjalander rjalander Jan 25, 2023

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

.withExtension("id", id)
.withExtension("source", source)
.withExtension("taskname", taskName)
.withExtension("pipelinerun", pipelineRun.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this pipelineRun as String, say objectMapper.writeValueAsString(pipelineRun)

.withExtension("id", id)
.withExtension("source", source)
.withExtension("taskname", taskName)
.withExtension("pipelinerun", pipelineRun.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this pipelineRun as String, say objectMapper.writeValueAsString(pipelineRun)

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("source", source)
.withExtension("repository", repository.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this repository as String, say objectMapper.writeValueAsString(repository)

CloudEvent cdToSend =
buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("environment", environment.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this environment as String, say objectMapper.writeValueAsString(environment)

CloudEvent cdToSend =
buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("environment", environment.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this environment as String, say objectMapper.writeValueAsString(environment)

CloudEvent cdToSend =
buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("environment", environment.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this environment as String, say objectMapper.writeValueAsString(environment)

CloudEvent cdToSend =
buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("environment", environment.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this environment as String, say objectMapper.writeValueAsString(environment)

CloudEvent cdToSend =
buildCloudEvent(eventType, data)
.withExtension("id", id)
.withExtension("environment", environment.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use jackson-databind to write this environment as String, say objectMapper.writeValueAsString(environment)

@e-backmark-ericsson
Copy link
Copy Markdown

@rjalander , will you be able to review this so it can be merged?

@rjalander rjalander changed the title Updated pipeline events for new CDEvents Spec Updating the Java-SDK to the CDEvents Spec - v0.1.0 Feb 15, 2023
@rjalander
Copy link
Copy Markdown
Contributor

@adamkenihan please update the PR description as the changes are not only for pipeline events and mention the changes along with the issue #11

@rjalander
Copy link
Copy Markdown
Contributor

Thank you @adamkenihan
Reviewed and the changes looks good to me.

@rjalander
Copy link
Copy Markdown
Contributor

Closing this PR as the same changes raised through Nordix repo https://github.com/Nordix/sdk-java
with PR #14

@rjalander rjalander closed this Feb 22, 2023
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.

4 participants