Skip to content

Commit 34a9e52

Browse files
authored
Merge pull request #515 from rawmind0/clustertemplate
Fix flattenClusterTemplateRevisions func to avoid crash
2 parents f04b2ca + 0e888a6 commit 34a9e52

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 1.10.6 (November 11, 2020)
2+
3+
FEATURES:
4+
5+
6+
7+
ENHANCEMENTS:
8+
9+
10+
11+
BUG FIXES:
12+
13+
* Fixed `flattenClusterTemplateRevisions` func to avoid crash on `rancher2_cluster_template` resource at some circunstances
14+
115
## 1.10.5 (November 11, 2020)
216

317
FEATURES:

rancher2/structure_cluster_template.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,24 @@ func flattenClusterTemplateRevisions(input []managementClient.ClusterTemplateRev
123123
}
124124
}
125125
}
126-
sortedInput := make([]managementClient.ClusterTemplateRevision, len(input))
126+
inputLen := len(input)
127+
pLen := len(p)
128+
sortedInput := make([]managementClient.ClusterTemplateRevision, inputLen)
127129
newCTR := []managementClient.ClusterTemplateRevision{}
128130
lastIndex := 0
129131
for i := range sortedInput {
130132
if v, ok := pIndexID[input[i].ID]; ok {
133+
if v > i && pLen > inputLen {
134+
v = v - (v - i)
135+
}
131136
sortedInput[v] = input[i]
132137
lastIndex++
133138
continue
134139
}
135140
if v, ok := pIndexName[input[i].Name]; ok {
141+
if v > i && pLen > inputLen {
142+
v = v - (v - i)
143+
}
136144
sortedInput[v] = input[i]
137145
lastIndex++
138146
continue

0 commit comments

Comments
 (0)