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 support for multiple config files #13

Merged
merged 16 commits into from
Aug 31, 2022

Conversation

yusufhm
Copy link
Contributor

@yusufhm yusufhm commented Aug 24, 2022

First pass at the merge; currently it can merge the following scenario.

Given the following files:

# initial-config.yml
checks:
  file:
    - name: '[FILE] Illegal files'
      path: web/sites/default/files
      disallowed-pattern: '^(adminer|phpmyadmin|bigdump)?\.php$'
# config-override.yml
checks:
  file:
    - name: '[FILE] Illegal files'
      path: ./

Running go run . -f initial-config.yml -f config-override.yml --dump-config will provide the following config:

project-dir: /Users/yusuf/projects/shipshape
fail-severity: high
checks:
  file:
    - name: '[FILE] Illegal files'
      severity: normal
      path: ./
      disallowed-pattern: ^(adminer|phpmyadmin|bigdump)?\.php$

Note: I did some major refactoring:

  • Broke out the code for each struct in its own file
  • Added a check suffix to the check files - a future refactoring would be to move the checks out into a separate directory altogether
  • In the tests, I'm moving away from using Ensure* and the like, to instead use assert.*

Still a work in progress, and the next step is to allow the following config override to work:

checks:
  file:
    - path: ./

The intention would be to replace the path for all file checks in the config.

@yusufhm yusufhm added DO NOT MERGE Merging is blocked by another dependency DO NOT REVIEW Work is ongoing, review not required labels Aug 24, 2022
@yusufhm yusufhm removed DO NOT MERGE Merging is blocked by another dependency DO NOT REVIEW Work is ongoing, review not required labels Aug 27, 2022
@yusufhm
Copy link
Contributor Author

yusufhm commented Aug 27, 2022

The merge is now working as required; given the following files:

# initial-config.yml
checks:
  file:
    - name: '[FILE] Illegal files'
      path: web/sites/default/files
      disallowed-pattern: '^(adminer|phpmyadmin|bigdump)?\.php$'
# config-override.yml
checks:
  file:
    - path: ./

Running go run . -f initial-config.yml -f config-override.yml --dump-config will produce the following config:

project-dir: /Users/yusuf/projects/shipshape
fail-severity: high
checks:
  file:
    - name: '[FILE] Illegal files'
      severity: normal
      path: ./
      disallowed-pattern: ^(adminer|phpmyadmin|bigdump)?\.php$

@yusufhm yusufhm added the Needs review Dev complete ready for review label Aug 27, 2022
@yusufhm yusufhm merged commit 573fa91 into main Aug 31, 2022
@yusufhm yusufhm deleted the feature/GOVCMS-8092-multiple-configs branch August 31, 2022 06:17
@yusufhm yusufhm removed the Needs review Dev complete ready for review label Nov 28, 2022
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.

None yet

3 participants