@@ -38,6 +38,7 @@ import (
3838 "os"
3939 "path/filepath"
4040 "sort"
41+ "strconv"
4142 "strings"
4243)
4344
@@ -65,11 +66,16 @@ func (s *PlatformKeysRewriteLoader) Run(context map[string]interface{}) error {
6566 for _ , key := range keys {
6667 keyParts := strings .Split (key , "." )
6768 if keyParts [0 ] == constants .PLATFORM_REWRITE_OLD {
69+ index , err := strconv .Atoi (keyParts [1 ])
70+ if err != nil {
71+ return utils .WrapError (err )
72+ }
6873 rewriteKey := strings .Join (keyParts [2 :], "." )
6974 oldValue := txt [key ]
7075 newValue := txt [constants .PLATFORM_REWRITE_NEW + "." + strings .Join (keyParts [1 :], "." )]
7176 platformKeyRewrite := types.PlatforKeyRewrite {Key : rewriteKey , OldValue : oldValue , NewValue : newValue }
72- platformKeysRewrite .Rewrites = append (platformKeysRewrite .Rewrites , platformKeyRewrite )
77+ platformKeysRewrite .Rewrites = growSliceOfRewrites (platformKeysRewrite .Rewrites , index )
78+ platformKeysRewrite .Rewrites [index ] = platformKeyRewrite
7379 }
7480 }
7581
@@ -92,3 +98,12 @@ func findPlatformKeysRewriteTxt(folders []string) (string, error) {
9298
9399 return constants .EMPTY_STRING , nil
94100}
101+
102+ func growSliceOfRewrites (originalSlice []types.PlatforKeyRewrite , maxIndex int ) []types.PlatforKeyRewrite {
103+ if cap (originalSlice ) > maxIndex {
104+ return originalSlice
105+ }
106+ newSlice := make ([]types.PlatforKeyRewrite , maxIndex + 1 )
107+ copy (newSlice , originalSlice )
108+ return newSlice
109+ }
0 commit comments