From 0d97747fdabaa13531bbfdd1d09852a89f91d6ce Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Wed, 10 May 2023 17:47:59 +0000 Subject: [PATCH] use hardcoded old str as tfvars is not being changed --- cli/update_viktorbarzin_me.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cli/update_viktorbarzin_me.go b/cli/update_viktorbarzin_me.go index 0bf4fff0..1d174206 100644 --- a/cli/update_viktorbarzin_me.go +++ b/cli/update_viktorbarzin_me.go @@ -63,14 +63,17 @@ func getNewContent(gitFs *GitFS, currIp, newIp net.IP) (string, error) { // extract old and new ip // line example: // bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, "", "") - lineToAdd = strings.Replace(lineToAdd, "\"", "", -1) // remove all quotes - lineToAdd = strings.Replace(lineToAdd, ")", "", -1) // remove the trailing closing bracket - splitByComma := strings.Split(lineToAdd, ",") - if len(splitByComma) != 3 { - return "", fmt.Errorf("invalid line; got: %s", line) - } - newIpStr := strings.ReplaceAll(splitByComma[2], " ", "") - lineToAdd = fmt.Sprintf(" bind_db_viktorbarzin_me = replace(var.bind_db_viktorbarzin_me, \"%s\", \"%s\")", newIpStr, newIp.String()) + // lineToAdd = strings.Replace(lineToAdd, "\"", "", -1) // remove all quotes + // lineToAdd = strings.Replace(lineToAdd, ")", "", -1) // remove the trailing closing bracket + // splitByComma := strings.Split(lineToAdd, ",") + // if len(splitByComma) != 3 { + // return "", fmt.Errorf("invalid line; got: %s", line) + // } + // newIpStr := strings.ReplaceAll(splitByComma[2], " ", "") + // 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) }