Skip to content

Use get from envvars logic when using old CasC format#524

Merged
afontan merged 2 commits into
masterfrom
alejandro.fontan/fix-null-port-in-old-CasC-format
Oct 2, 2025
Merged

Use get from envvars logic when using old CasC format#524
afontan merged 2 commits into
masterfrom
alejandro.fontan/fix-null-port-in-old-CasC-format

Conversation

@afontan

@afontan afontan commented Sep 29, 2025

Copy link
Copy Markdown
Collaborator

What does this PR do?

  • Improved backward compatibility when using CasC, some users were having NPE when not providing custom value to the port, the code wasn't handling this properly making the plugin to create the agent with null pointer

Description of the Change

  • use the DatadogAgentConfiguration.DatadogAgentConfigurationDescriptor.getXXXFromEnvVars inside DatadogGlobalConfiguration old code

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@nikita-tkachenko-datadog nikita-tkachenko-datadog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Would be nice to add a test case covering this to org.datadog.jenkins.plugins.datadog.DatadogGlobalConfigurationAsCodeTest. There's already an example with test-config-legacy.yml, you could reuse it and set some env vars to test that they have higher priority than the YAML.
com.github.stefanbirkner.systemlambda.SystemLambda#withEnvironmentVariable can be used to set an env var in a unit test

@afontan

afontan commented Sep 29, 2025

Copy link
Copy Markdown
Collaborator Author

@nikita-tkachenko-datadog I'll do it! I was considering extracting all the getXXXFromEnvVars to a util/help, but it might be overkill just to keep retrocompatibility

@afontan
afontan force-pushed the alejandro.fontan/fix-null-port-in-old-CasC-format branch from eb481de to 9607284 Compare September 30, 2025 13:17
@afontan
afontan marked this pull request as ready for review September 30, 2025 13:33
@afontan
afontan merged commit a4baf7c into master Oct 2, 2025
19 checks passed
@afontan
afontan deleted the alejandro.fontan/fix-null-port-in-old-CasC-format branch October 2, 2025 06:59
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.

2 participants