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

Allow targeting orphan nodes #3912

Merged
merged 2 commits into from
Nov 13, 2015
Merged

Allow targeting orphan nodes #3912

merged 2 commits into from
Nov 13, 2015

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented Nov 13, 2015

Fixes #3852.

This replicates the issue reported in #3852.
resourceOrphans = append(resourceOrphans, resourceOrphansExcludingTargets[i])
}
}
}
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 going about this filter in the other direction might be a bit more straightforward. Let's see how it looks:

resourceOrphans := state.Orphans(config)
if len(t.Targets) > 0 {
  var targetedOrphans []string
  for _, o := range resourceOrphans {
    targeted := false
    for _, t := range t.Targets {
      prefix := fmt.Sprintf("%s.%s.%d", t.Type, t.Name, t.Index)
      if strings.HasPrefix(o, prefix) {
        targeted = true
      }
    }
    if targeted {
      targetedOrphans = append(targetedOrphans, o)
    }
  }
  resourceOrphans = targetedOrphans
}

Seems sort of nice to have the targeting behavior all behind the guard and the normal case is the straight-through code path. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Likely better, I'll update.

@phinze
Copy link
Contributor

phinze commented Nov 13, 2015

This looks 100% correct! One question about style inline, but this is some super solid graph work here. 👍

Fixes #3852. We now run the OrphanTransformer even when targeting, and
pass it the list of targets following resource expansion.
@phinze
Copy link
Contributor

phinze commented Nov 13, 2015

LGTM

jen20 added a commit that referenced this pull request Nov 13, 2015
@jen20 jen20 merged commit 205640a into master Nov 13, 2015
@jen20 jen20 deleted the b-target-orphans branch November 13, 2015 20:39
@ghost
Copy link

ghost commented Apr 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot plan -target to delete resources
2 participants