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

feat : Detect ibm_catalog.json #1067

Merged
merged 7 commits into from
Nov 19, 2024
Merged

feat : Detect ibm_catalog.json #1067

merged 7 commits into from
Nov 19, 2024

Conversation

arya-girish-k
Copy link
Contributor

@arya-girish-k arya-girish-k commented Nov 13, 2024

Description

This PR enhances the existing shell script by adding functionality to detect ibm_catalog.json files in a specified directory.After the changes the hook will run if ibm_catalog.json or .tf file is in the repo and if it exist it should mandate LICENSE file.
Issue:https://github.ibm.com/GoldenEye/issues/issues/8715

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (0.1.0)
  • Major release (X.x.x)
Release notes content

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

For mergers

  • Use a conventional commit message to set the release level. Follow the guidelines.
  • Include information that users need to know about the PR in the commit message. The commit message becomes part of the GitHub release notes.
  • Use the Squash and merge option.

@ocofaigh
Copy link
Member

@arya-girish-k This change looks good to me. I'm happy to merge if you want to mark the PR as ready for review?


# ensure LICENSE file exists if .tf file is detected incd root directory

count=$(find . -maxdepth 1 \( -name "*.tf" -o -name "ibm_catalog.json" \) 2>/dev/null | wc -l | xargs)
Copy link
Member

Choose a reason for hiding this comment

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

@ocofaigh Do we want to set maxdepth if looking for all .tf files?

Copy link
Member

Choose a reason for hiding this comment

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

This is a valid point. I ran this command against the terraform-ibm-common-utilities repo, and indeed it returned the count as 0 since the terraform code is not in the root of the repo.

However if we remove it I notice that it will pick up tf files from the common-dev-assets git submodule. e.g:

% find . \( -name "*.tf" -o -name "ibm_catalog.json" \) 2>/dev/null                
./examples/crn-parser/outputs.tf
./examples/crn-parser/main.tf
./examples/crn-parser/variables.tf
./examples/crn-parser/provider.tf
./examples/crn-parser/version.tf
./modules/crn-parser/outputs.tf
./modules/crn-parser/main.tf
./modules/crn-parser/variables.tf
./modules/crn-parser/version.tf
./common-dev-assets/examples/mock_tf_code/outputs.tf
./common-dev-assets/examples/mock_tf_code/main.tf
./common-dev-assets/examples/mock_tf_code/variables.tf
./common-dev-assets/examples/mock_tf_code/provider.tf
./common-dev-assets/examples/mock_tf_code/version.tf

@arya-girish-k can we update the logic to not use maxdepth but also to ignore git submodules?

@arya-girish-k arya-girish-k marked this pull request as ready for review November 14, 2024 04:20
@arya-girish-k
Copy link
Contributor Author

@ocofaigh ,I marked as ready for review.

@arya-girish-k
Copy link
Contributor Author

cc:@SarikaSinha

Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

@arya-girish-k
Copy link
Contributor Author

@ocofaigh @Ak-sky I have updated the logic.Kindly review


# ensure LICENSE file exists if .tf file or ibm_catalog.json is detected in root directory

var1=$(find ./*.tf 2>/dev/null | wc -l | xargs)
Copy link
Member

@ocofaigh ocofaigh Nov 15, 2024

Choose a reason for hiding this comment

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

This solution won't work - we need to scan the full repo for .tf files. Some repos (such as terraform-ibm-observability-da) will not have .tf files in the root, but will have them in other folders.

So what we need is to scan the full repo for .tf file, but ignore them if they are in a folder called common-dev-assets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ocofaigh ,Ok I will make the changes and update.

@arya-girish-k
Copy link
Contributor Author

@ocofaigh @Ak-sky :Please review the changes

@ocofaigh ocofaigh merged commit 42ebfad into main Nov 19, 2024
1 check passed
@ocofaigh ocofaigh deleted the 8715-lic branch November 19, 2024 09:33
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.

3 participants