Skip to content

Commit

Permalink
Remove control patchfile after revert
Browse files Browse the repository at this point in the history
  • Loading branch information
dusansalestrekker committed Jul 17, 2021
1 parent 43a5815 commit 4ed0f4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Close() {
}

if fdRevert != nil {
fdRevert.WriteString(fmt.Sprintf("rm -rf %s\n", patchFilesControlFile))
fdRevert.Sync()
fdRevert.Close()
}
Expand Down
13 changes: 8 additions & 5 deletions generator/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,21 @@ func writePatch(p *parser.Result, environment string, log *zap.Logger) (err erro
bodyCommented = strings.Trim(bodyCommented, "\n")

// generate payload
p.Patch.Body = fmt.Sprintf("\n%s PATCHFILES START\n%s\n%s PATCHFILES END\n", p.Patch.CommentCharacter, p.Patch.Body, p.Patch.CommentCharacter)
payload := base64.StdEncoding.EncodeToString([]byte(p.Patch.Body))
if p.Patch.Mode == "append" {
p.Patch.Body = fmt.Sprintf("\n%s PATCHFILES START\n%s\n%s PATCHFILES END\n", p.Patch.CommentCharacter, p.Patch.Body, p.Patch.CommentCharacter)
}
payload := base64.StdEncoding.EncodeToString([]byte(p.Patch.Body + "\n"))

// write mode
commandsAfter := p.Patch.CommandsAfter
writeMode := ">"
if p.Patch.Mode == "append" {
writeMode = ">>"
} else {
command := fmt.Sprintf("cp -r %s %s.oldpatchfile", p.Patch.Output, p.Patch.Output)
commandsAfter = append(commandsAfter, command)
}

commandsAfter := p.Patch.CommandsAfter
command := fmt.Sprintf("cp -r %s %s.oldpatchfile", p.Patch.Output, p.Patch.Output)
commandsAfter = append(commandsAfter, command)
var (
buf = new(bytes.Buffer)
)
Expand Down

0 comments on commit 4ed0f4a

Please sign in to comment.