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

Only show external changes which contributed to the plan #30486

Merged
merged 19 commits into from
Mar 18, 2022
Merged

Commits on Mar 4, 2022

  1. addrs: Reference.DisplayString method

    We've ended up implementing something approximately like this in a few
    places now, so this is a centralized version that we can consolidate on
    moving forward, gradually removing that duplication.
    apparentlymart authored and jbardin committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    2453025 View commit details
    Browse the repository at this point in the history
  2. providers: A type for all schemas for a particular provider

    Previously the "providers" package contained only a type for representing
    the schema of a particular object within a provider, and the terraform
    package had the responsibility of aggregating many of those together to
    describe the entire surface area of a provider.
    
    Here we move what was previously terraform.ProviderSchema to instead be
    providers.Schemas, retaining its existing API otherwise, and leave behind
    a type alias to allow us to gradually update other references over time.
    
    We've gradually been shrinking down the responsibilities of the
    "terraform" package to just representing the graph components and
    behaviors anyway, but the specific motivation for doing this _now_ is to
    allow for other packages to both be called by the terraform package _and_
    work with provider schemas at the same time, without creating a package
    dependency cycle: instead, these other packages can just import the
    "providers" package and not need to import the "terraform" package at all.
    
    For now this does still leave the responsibility for _building_ a
    providers.Schemas object over in the "terraform" package, because it's
    currently doing that as part of some larger work that isn't easily
    separable, and so reorganizing that would be a more involved and riskier
    change than just moving the existing type elsewhere.
    apparentlymart authored and jbardin committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    1425374 View commit details
    Browse the repository at this point in the history
  3. lang/globalref: Global reference analysis utilities

    Our existing functionality for dealing with references generally only has
    to concern itself with one level of references at a time, and only within
    one module, because we use it to draw a dependency graph which then ends
    up reflecting the broader context.
    
    However, there are some situations where it's handy to be able to ask
    questions about the indirect contributions to a particular expression in
    the configuration, particularly for additional hints in the user interface
    where we're just providing some extra context rather than changing
    behavior.
    
    This new "globalref" package therefore aims to be the home for algorithms
    for use-cases like this. It introduces its own special "Reference" type
    that wraps addrs.Reference to annotate it also with the usually-implied
    context about where the references would be evaluated.
    
    With that building block we can therefore ask questions whose answers
    might involve discussing references in multiple packages at once, such as
    "which resources directly or indirectly contribute to this expression?",
    including indirect hops through input variables or output values which
    would therefore change the evaluation context.
    
    The current implementations of this are around mapping references onto the
    static configuration expressions that they refer to, which is a pretty
    broad and conservative approach that unfortunately therefore loses
    accuracy when confronted with complex expressions that might take dynamic
    actions on the contents of an object. My hunch is that this'll be good
    enough to get some initial small use-cases solved, though there's plenty
    room for improvement in accuracy.
    
    It's somewhat ironic that this sort of "what is this value built from?"
    question is the use-case I had in mind when I designed the "marks" feature
    in cty, yet we've ended up putting it to an unexpected but still valid
    use in Terraform for sensitivity analysis and our currently handling of
    that isn't really tight enough to permit other concurrent uses of marks
    for other use-cases. I expect we can address that later and so maybe we'll
    try for a more accurate version of these analyses at a later date, but my
    hunch is that this'll be good enough for us to still get some good use out
    of it in the near future, particular related to helping understand where
    unknown values came from and in tailoring our refresh results in plan
    output to deemphasize detected changes that couldn't possibly have
    contributed to the proposed plan.
    apparentlymart authored and jbardin committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    055c432 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6d33de8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a151aae View commit details
    Browse the repository at this point in the history
  6. filter out non-relevant drift changes

    Only show drift changes which may have affected the plan output.
    jbardin committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    c5c7045 View commit details
    Browse the repository at this point in the history
  7. account for diagnostics when fetching schemas

    Maybe we can ensure schemas are all loaded at this point, but we can
    tackle that later.
    jbardin committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    a02d7cc View commit details
    Browse the repository at this point in the history
  8. comment fix

    jbardin committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    4181b6e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b3adcf0 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    f1e8aed View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    dc393cc View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2022

  1. globalref.Reference.ResourceAttr

    Convert a global reference to a specific AbsResource and attribute pair.
    The hcl.Traversal is converted to a cty.Path at this point because plan
    rendering is based on cty values.
    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    620caa9 View commit details
    Browse the repository at this point in the history
  2. change plan to store individual relevant attrs

    Storing individual contributing attributes will allow finer tuning of
    the plan rendering.
    
    add contributing to outputs
    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    c02e8bc View commit details
    Browse the repository at this point in the history
  3. decode change before creating diff

    This is functionally equivalent, but will allow us to filter the change
    values directly for reduced drift output.
    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    0e7cec8 View commit details
    Browse the repository at this point in the history
  4. filter attribute refresh changes from plan UI

    Filter the refresh changes from the normal plan UI at the attribute
    level. We do this by constructing fake plans.Change records for diff
    generation, reverting all attribute changes that do not match any of the
    plan's ContributingResourceReferences.
    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    25f4c0d View commit details
    Browse the repository at this point in the history
  5. track contributing instances

    Track individual instance drift rather than whole resources which
    contributed to the plan. This will allow the output to be more precise,
    and we can still use NoKey instances as a proxy for containing resources
    when needed.
    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    e2b7424 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    773f5b0 View commit details
    Browse the repository at this point in the history
  7. add whole resource references

    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    f0cd8be View commit details
    Browse the repository at this point in the history
  8. add relevant_attributes to the json plan format

    Add the resource instances and individual attributes which may have
    contributed to the planned changes to the json format of the plan. We
    use the existing path encoding for individual attributes, which is
    already used in the replace_paths change field.
    jbardin committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    8c5e11d View commit details
    Browse the repository at this point in the history