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

Fix scraping Refs from attributes containing lists #441

Merged
merged 3 commits into from
Oct 7, 2024

Commits on Oct 5, 2024

  1. bug: Surface bug - scraping lists of references does not work

    Scraping does not handle `TupleConsExpr` when parsing example HCL code from
    Terraform documentation.
    
    Example 1):
    
    ```hcl
        require_attestations_by = [google_binary_authorization_attestor.attestor.name]
    ```
    
    Does not add:
    
    ```
    cluster_admission_rules.require_attestations_by: google_binary_authorization_attestor.attestor.name
    ```
    
    As it should since the reference is contained in a _list_.
    
    1) https://github.com/hashicorp/terraform-provider-google/blob/v5.39.0/website/docs/r/binary_authorization_policy.html.markdown?plain=1#L49
    
    Signed-off-by: Rickard von Essen <rickard.von.essen@gmail.com>
    rickard-von-essen committed Oct 5, 2024
    Configuration menu
    Copy the full SHA
    ed6ae5a View commit details
    Browse the repository at this point in the history
  2. Fix scraping Refs from attributes containing lists

    This correctly parses references contained in lists and adds them to the map of
    references.
    
    Example 1):
    
    ```hcl
        require_attestations_by = [google_binary_authorization_attestor.attestor.name]
    ```
    
    Correctly generates a ref and building `provider-upjet-gcp` with this change
    produces the expected `examples-generated/binaryauthorization/v1beta2/policy.yaml`
    with this diff compared to without this change.
    
    ```
    @@ -14,8 +14,8 @@ spec:
         - cluster: us-central1-a.prod-cluster
           enforcementMode: ENFORCED_BLOCK_AND_AUDIT_LOG
           evaluationMode: REQUIRE_ATTESTATION
    -      requireAttestationsBy:
    -      - ${google_binary_authorization_attestor.attestor.name}
    +      requireAttestationsByRefs:
    +      - name: attestor
         defaultAdmissionRule:
         - enforcementMode: ENFORCED_BLOCK_AND_AUDIT_LOG
           evaluationMode: ALWAYS_ALLOW
    ```
    
    1) https://github.com/hashicorp/terraform-provider-google/blob/v5.39.0/website/docs/r/binary_authorization_policy.html.markdown?plain=1#L49
    
    Signed-off-by: Rickard von Essen <rickard.von.essen@gmail.com>
    rickard-von-essen committed Oct 5, 2024
    Configuration menu
    Copy the full SHA
    6dae02b View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2024

  1. Add license header

    Signed-off-by: Rickard von Essen <rickard.von.essen@gmail.com>
    rickard-von-essen committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    1ae4c81 View commit details
    Browse the repository at this point in the history