Skip to content

feat: add crn parser submodule #2

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

Merged
merged 10 commits into from
Sep 11, 2024
Merged

feat: add crn parser submodule #2

merged 10 commits into from
Sep 11, 2024

Conversation

MatthewLemmond
Copy link
Member

Description

Add the crn parser submodule and initial module cleanup from template

Release required?

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

Add CRN parser submodule

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.

@MatthewLemmond
Copy link
Member Author

/run pipeline

@MatthewLemmond
Copy link
Member Author

/run pipeline

Copy link
Contributor

@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.

Left some comments.
Also can you address these:

  • remove the root level tf files
  • we dont need an upgrade test do we? we are not creating any resources in the crn parser module
  • since there is no root level module, I would move the Usage, Required IAM access policies, and Requirements section to the individual subnmodule readme. And then delete the terraform-ibm-common-utilities heading

README.md Outdated
@@ -20,16 +20,19 @@ For information, see "Module names and descriptions" at
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions
-->

TODO: Replace this with a description of the modules in this repo.
This module serves as a repository to hold common Terraform utilities used in other modules in the terraform-ibm-modules organization.
Copy link
Contributor

Choose a reason for hiding this comment

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

"This module" seems wrong wording here. There is no root level module. It should probably start with "This repository serves as a ..."

terraform {
required_version = ">= 1.3.0"
# If your module requires any terraform providers, uncomment the "required_providers" section below and add all required providers.
# Each required provider's version should be a flexible range to future proof the module's usage with upcoming minor and patch versions.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think remove the code comments

SKIP UPGRADE TEST because we moved the examples from the basic/advanced to one example for the submodule upgrade test fails
@MatthewLemmond
Copy link
Member Author

/run pipeline

Copy link
Contributor

@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.

final few comments

README.md Outdated
@@ -20,46 +20,22 @@ For information, see "Module names and descriptions" at
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions
-->

TODO: Replace this with a description of the modules in this repo.
This repository serves as a repository to hold common Terraform utilities used in other modules in the terraform-ibm-modules organization.
Copy link
Contributor

Choose a reason for hiding this comment

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

"This repository serves as a library" maybe reads batter? - cc @SirSpidey

@@ -1,2 +1,2 @@
# Primary owner should be listed first in list of global owners, followed by any secondary owners
* @SirSpidey @ocofaigh
* @MatthewLemmond
Copy link
Contributor

Choose a reason for hiding this comment

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

add a secondary owner

region = var.region
key_protect_name = "${var.prefix}-kp"
access_tags = var.resource_tags
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We really don't need to provision key protect instance here, or a resource group. It kind of doesn't make sense as a real use case, because that module already supports outputting region, guid etc, so you wouldn't use the CRN parser here.
I suggest that the example just takes in a CRN as a single input variable. In the test we can then pass it a mock CRN value. (it means updating the test to use TestOptionsDefault instead of TestOptionsDefaultWithVars)

Copy link

@SirSpidey SirSpidey left a comment

Choose a reason for hiding this comment

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

some style suggestions

README.md Outdated
@@ -20,46 +20,22 @@ For information, see "Module names and descriptions" at
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions
-->

TODO: Replace this with a description of the modules in this repo.
This repository serves as a repository to hold common Terraform utilities used in other modules in the terraform-ibm-modules organization.

Choose a reason for hiding this comment

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

Suggested change
This repository serves as a repository to hold common Terraform utilities used in other modules in the terraform-ibm-modules organization.
Common Terraform utilities that are used in other modules in the terraform-ibm-modules GitHub organization.

I think you can shorten to get to the core info

README.md Outdated

Each utility is placed under the [modules](./modules) directory so they may be individually referenced within a Terraform project, see the [Overview](#overview) section below for a list of available submodules.

Choose a reason for hiding this comment

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

Suggested change
Each utility is placed under the [modules](./modules) directory so they may be individually referenced within a Terraform project, see the [Overview](#overview) section below for a list of available submodules.
You can reference any utility in this repo from your Terraform project by pointing to the utility in the [modules](/modules) directory. For a list of available submodules, see the Submodules in the [Overview](#overview) section.

Comment on lines 3 to 8
An example that will provision the following:

- A new resource group if one is not passed in.
- A new Key Protect instance.

The output of the example will be the CRN of the Key Protect instance and the parsed fields of the CRN using the CRN parser submodule.

Choose a reason for hiding this comment

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

Suggested change
An example that will provision the following:
- A new resource group if one is not passed in.
- A new Key Protect instance.
The output of the example will be the CRN of the Key Protect instance and the parsed fields of the CRN using the CRN parser submodule.
This example provisions the following resources:
- A new resource group, if one is not passed in.
- A new Key Protect instance.
The outputs are the CRN of the Key Protect instance and the fields of the CRN that are parsed by using the CRN parser utility.

Using utility instead of submodule to stay consistent with the main readme file.

But it looks like this won't need the KP instance, based on Conall's comment. So readme could have something instead like,

This example takes a CRN as the input. The outputs are the fields of the CRN that are parsed by using the CRN parser utility.

Choose a reason for hiding this comment

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

@MatthewLemmond You should use segments instead of fields for the parts of the CRN to stay internally consistent and consistent with the cloud docs.

terraform {
required_version = ">= 1.3.0"

# As the CRN parser does not utilize the IBM Terraform provider, the provider does not need to be locked to any version

Choose a reason for hiding this comment

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

Not critical, but I'd replace As with Because to make it easier for non-native English speakers to understand. And replace utilize with use.

Suggested change
# As the CRN parser does not utilize the IBM Terraform provider, the provider does not need to be locked to any version
# Because the CRN parser doesn't use the IBM Terraform provider, the provider doesn't need to be locked to a version.

Copy link
Member Author

Choose a reason for hiding this comment

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

No longer necessary, version.tf is now just the required terraform version and dropped the need for the IBM provider.

@@ -0,0 +1,51 @@
# Terraform IBM common utilities CRN parser

This module takes a CRN string input and returns each of the fields in the provided CRN as a separate output, for more information on what each of these fields represent see <https://cloud.ibm.com/docs/account?topic=account-crn>.

Choose a reason for hiding this comment

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

Suggested change
This module takes a CRN string input and returns each of the fields in the provided CRN as a separate output, for more information on what each of these fields represent see <https://cloud.ibm.com/docs/account?topic=account-crn>.
This module takes a CRN string input, parses the CRN, and returns the segments in the CRN as separate output fields. For more information about what each CRN segment represents, see [Cloud Resource Names](https://cloud.ibm.com/docs/account?topic=account-crn).

#}
variable "crn" {
type = string
description = "The CRN to be parsed."

Choose a reason for hiding this comment

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

Suggested change
description = "The CRN to be parsed."
description = "The CRN to parse."

@MatthewLemmond
Copy link
Member Author

/run pipeline

@MatthewLemmond
Copy link
Member Author

/run pipeline

Copy link

@SirSpidey SirSpidey left a comment

Choose a reason for hiding this comment

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

one really small update. otherwise 👍

- A new Key Protect instance.

The output of the example will be the CRN of the Key Protect instance and the parsed fields of the CRN using the CRN parser submodule.
This example takes a CRN as the input. The outputs are the fields of the CRN that are parsed by using the CRN parser utility.

Choose a reason for hiding this comment

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

Suggested change
This example takes a CRN as the input. The outputs are the fields of the CRN that are parsed by using the CRN parser utility.
This example takes a CRN as the input. The outputs are the segments of the CRN that are parsed by using the CRN parser utility.

just want to keep this consistent with modules/crn-parser/README.md

@MatthewLemmond
Copy link
Member Author

/run pipeline

@MatthewLemmond
Copy link
Member Author

@ocofaigh one thing I thought about while fixing a test failure, do we need the CRA scan since this is just a local? I presume any utilities we'd add in the future would be similar in that they don't need the provider so might be better to just pull it from the module

@MatthewLemmond
Copy link
Member Author

/run pipeline

@MatthewLemmond
Copy link
Member Author

/run pipeline

@ocofaigh ocofaigh merged commit 116534d into main Sep 11, 2024
2 checks passed
@ocofaigh ocofaigh deleted the crn-parser branch September 11, 2024 08:23
@terraform-ibm-modules-ops
Copy link
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants