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

core: -target option to also select resources in descendant modules #15314

Merged
merged 2 commits into from
Jun 16, 2017

Commits on Jun 16, 2017

  1. core: ResourceAddress.Contains method

    This is similar in purpose to Equals but it takes a hierarchical approach
    where modules contain their child modules, resources are contained by
    their modules, and indexed resource instances are contained by their
    resource names.
    
    Unlike "Equals", Contains is intended to be transitive, so if A contains B
    and B contains C, then C necessarily contains A. It is also directional:
    if A contains B then B does not also contain A unless A and B are
    identical. This results in more intuitive behavior for use-cases where
    the goal is to select a portion of the address space for an operation.
    apparentlymart committed Jun 16, 2017
    Configuration menu
    Copy the full SHA
    fd9943a View commit details
    Browse the repository at this point in the history
  2. core: -target option to also select resources in descendant modules

    Previously the behavior for -target when given a module address was to
    target only resources directly within that module, ignoring any resources
    defined in child modules.
    
    This behavior turned out to be counter-intuitive, since users expected
    the -target address to be interpreted hierarchically.
    
    We'll now use the new "Contains" function for addresses, which provides
    a hierarchical "containment" concept that is more consistent with user
    expectations. In particular, it allows module.foo to match
    module.foo.module.bar.aws_instance.baz, where before that would not have
    been true.
    
    Since Contains isn't commutative (unlike Equals) this requires some
    special handling for targeting specific indices. When given an argument
    like -target=aws_instance.foo[0], the initial graph construction (for
    both plan and refresh) is for the resource nodes from configuration, which
    have not yet been expanded to separate indexed instances. Thus we need
    to do the first pass of TargetsTransformer in mode where indices are
    ignored, with the work then completed by the DynamicExpand method which
    re-applies the TargetsTransformer in index-sensitive mode.
    
    This is a breaking change for anyone depending on the previous behavior
    of -target, since it will now select more resources than before. There is
    no way provided to obtain the previous behavior. Eventually we may support
    negative targeting, which could then combine with positive targets to
    regain the previous behavior as an explicit choice.
    apparentlymart committed Jun 16, 2017
    Configuration menu
    Copy the full SHA
    0bb649e View commit details
    Browse the repository at this point in the history