Add support for reading metadata.yaml in CFT-format, fallack to har…#1841
Merged
Conversation
tpdownes
suggested changes
Oct 14, 2023
tpdownes
left a comment
Contributor
There was a problem hiding this comment.
The function GetMetadata does not appear to error if I give an invalid format. For example, if I add community/modules/scheduler/schedmd-slurm-gcp-v5-controller/metadata.yaml with this content:
spec:
requirements:
services: yadayadayadait returns a nil error and the empty list for mtd.Spec.Requirements.Services.
Other than that, I believe this is a very valuable addition to the Toolkit.
Please also add a label to the PR that will include it in the release notes.
…dcoded logic.
* Remove `RequiredApis` from `ModuleInfo`, replace with `Metadata`;
* Refactor `resreader_test.go` to re-use embedded files for localFS test;
* Use `LastIndex` instead `Index` on module source trimming to avoid potential errors;
* Move `defaultAPIList` to `metadata_legacy.go`.
Created BP:
```yaml
...
- id: gg
source: github.com/terraform-google-modules/terraform-google-vm//modules/mig
```
Modified `metadata.go:GetMetadataSafe`:
```go
panic(fmt.Sprintf("%#v", mtd.Spec.Requirements.Services))
```
Got:
```sh
> make && ./ghpc create gg.yaml
panic: []string{"cloudresourcemanager.googleapis.com", "storage-api.googleapis.com", "serviceusage.googleapis.com", "compute.googleapis.com", "iam.googleapis.com"}
```
Matches: https://github.com/terraform-google-modules/terraform-google-vm/blob/master/modules/mig/metadata.yaml#L294
Collaborator
Author
|
@tpdownes thank you for being so thorough with review! There was a typo, fixed. |
tpdownes
approved these changes
Oct 14, 2023
tpdownes
left a comment
Contributor
There was a problem hiding this comment.
That change will certainly do it. LGTM.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…dcoded logic.
RequiredApisfromModuleInfo, replace withMetadata;resreader_test.goto re-use embedded files for localFS test;LastIndexinsteadIndexon module source trimming to avoid potential errors;defaultAPIListtometadata_legacy.go.Created BP:
Modified
metadata.go:GetMetadataSafe:Got:
Matches: https://github.com/terraform-google-modules/terraform-google-vm/blob/master/modules/mig/metadata.yaml#L294