Skip to content

chore: Add Struct required tags and Server Struct Validator#5371

Merged
X-Guardian merged 11 commits intorunatlantis:mainfrom
X-Guardian:validator
Mar 9, 2025
Merged

chore: Add Struct required tags and Server Struct Validator#5371
X-Guardian merged 11 commits intorunatlantis:mainfrom
X-Guardian:validator

Conversation

@X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented Mar 1, 2025

what

  • Adds the validate:"required" tag to required fields of structs that are used by the main Server struct.
  • Adds validator code to the main Server struct to validate all the fields in the struct and child structs.
  • Renames the validator variable to parserValidator to avoid clashing with the validator package.
  • Removes the redundant TestCommandRunnerVCSClientInitialized test.

why

Currently, if required fields are not specified in the Server struct or child structs, the unit tests will not detect this, and are likely to only be exposed in panics deeper in the code.

tests

Tested locally.

If a required field has not been specified, the following runtime error will occur at server initialization:

Error: initializing server: Key: 'Server.APIController.CommitStatusUpdater' Error:Field validation for 'CommitStatusUpdater' failed on the 'required' tag

references

Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
@X-Guardian X-Guardian requested review from a team as code owners March 1, 2025 19:18
@X-Guardian X-Guardian requested review from GenPage, lukemassa and nitrocode and removed request for a team March 1, 2025 19:18
@dosubot dosubot bot added feature New functionality/enhancement go Pull requests that update Go code labels Mar 1, 2025
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
@X-Guardian X-Guardian changed the title chore: Add Validator to Server Struct chore: Add Struct required tags and Server Struct Validator Mar 2, 2025
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 3, 2025
@X-Guardian X-Guardian enabled auto-merge (squash) March 9, 2025 11:31
@X-Guardian X-Guardian merged commit 4bea4e9 into runatlantis:main Mar 9, 2025
40 checks passed
inkel pushed a commit to inkel/atlantis that referenced this pull request Mar 18, 2025
…antis#5371)

Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
CaioAugustoo pushed a commit to CaioAugustoo/atlantis that referenced this pull request Mar 27, 2025
…antis#5371)

Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
joe1981al pushed a commit to joe1981al/atlantis that referenced this pull request Jun 20, 2025
…antis#5371)

Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
Signed-off-by: Joseph McDonald <jojosr2000@gmail.com>
dimisjim pushed a commit to dimisjim/atlantis that referenced this pull request Oct 29, 2025
…antis#5371)

Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
Signed-off-by: dimisjim <dimitris.moraitidis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality/enhancement go Pull requests that update Go code lgtm This PR has been approved by a maintainer provider/github

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants