use hardcoded old str as tfvars is not being changed
This commit is contained in:
parent
36091ab4c2
commit
0d97747fda
1 changed files with 11 additions and 8 deletions
|
|
@ -63,14 +63,17 @@ func getNewContent(gitFs *GitFS, currIp, newIp net.IP) (string, error) {
|
||||||
// extract old and new ip
|
// extract old and new ip
|
||||||
// line example:
|
// line example:
|
||||||
// bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, "<current_ip>", "<new_ip>")
|
// bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, "<current_ip>", "<new_ip>")
|
||||||
lineToAdd = strings.Replace(lineToAdd, "\"", "", -1) // remove all quotes
|
// lineToAdd = strings.Replace(lineToAdd, "\"", "", -1) // remove all quotes
|
||||||
lineToAdd = strings.Replace(lineToAdd, ")", "", -1) // remove the trailing closing bracket
|
// lineToAdd = strings.Replace(lineToAdd, ")", "", -1) // remove the trailing closing bracket
|
||||||
splitByComma := strings.Split(lineToAdd, ",")
|
// splitByComma := strings.Split(lineToAdd, ",")
|
||||||
if len(splitByComma) != 3 {
|
// if len(splitByComma) != 3 {
|
||||||
return "", fmt.Errorf("invalid line; got: %s", line)
|
// return "", fmt.Errorf("invalid line; got: %s", line)
|
||||||
}
|
// }
|
||||||
newIpStr := strings.ReplaceAll(splitByComma[2], " ", "")
|
// newIpStr := strings.ReplaceAll(splitByComma[2], " ", "")
|
||||||
lineToAdd = fmt.Sprintf(" bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, \"%s\", \"%s\")", newIpStr, newIp.String())
|
// lineToAdd = fmt.Sprintf(" bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, \"%s\", \"%s\")", newIpStr, newIp.String())
|
||||||
|
|
||||||
|
// Since we're not changing tfvars, only update the replacement value
|
||||||
|
lineToAdd = fmt.Sprintf(" bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, \"85.130.108.6\", \"%s\")", newIp.String())
|
||||||
}
|
}
|
||||||
newLines = append(newLines, lineToAdd)
|
newLines = append(newLines, lineToAdd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue