Skip to content

Commit

Permalink
implement terraform import correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dweebo committed Oct 16, 2021
1 parent e27447c commit cbaef97
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions provider/resource_immutable_tag_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ func resourceImmutableTagRuleRead(d *schema.ResourceData, m interface{}) error {
for _, rule := range immutableTagRuleModels {
if rule.Id == tagId {
log.Printf("[DEBUG] found tag id %d", tagId)
d.Set("disabled", rule.Disabled)
d.Set("project_id", strings.ReplaceAll(projectImmutableTagRulePath, models.PathImmutableTagRules, ""))

switch rule.ImmutableTagRuleTagSelectors[0].Decoration {
case "matches":
d.Set("tag_matching", rule.ImmutableTagRuleTagSelectors[0].Pattern)
case "excludes":
d.Set("tag_excluding", rule.ImmutableTagRuleTagSelectors[0].Pattern)
}

switch rule.ScopeSelectors.Repository[0].Decoration {
case "repoMatches":
d.Set("repo_matching", rule.ScopeSelectors.Repository[0].Pattern)
case "excludes":
d.Set("repo_excluding", rule.ScopeSelectors.Repository[0].Pattern)
}

return nil
}
}
Expand Down

0 comments on commit cbaef97

Please sign in to comment.