1
+ // Package utils provides some utility functions to compress and decompress tar and tar.gz.
2
+ // It also provides a logger that can output in color and implements io.Writer.
1
3
package utils
2
4
3
5
import (
@@ -13,8 +15,7 @@ import (
13
15
14
16
const MaxFileSizeBytes = 50 * 1024 * 1024 // 50MB
15
17
16
- // Compress takes a path to a file or directory and creates a .tar.gzip file
17
- // at the outputPath location
18
+ // Compress takes a path to a file or directory and creates a .tar.gzip file at the outputPath location.
18
19
func Compress (path , outputPath string ) error {
19
20
tarFile , err := os .Create (filepath .Clean (outputPath ))
20
21
if err != nil {
@@ -58,8 +59,7 @@ func Compress(path, outputPath string) error {
58
59
})
59
60
}
60
61
61
- // Decompress takes a location to a .tar.gzip file and a base path and
62
- // decompresses the contents wrt the base path
62
+ // Decompress takes a location to a .tar.gzip file and a base path and decompresses the contents wrt the base path.
63
63
func Decompress (tarPath , baseDir string ) error {
64
64
tarFile , err := os .Open (filepath .Clean (tarPath ))
65
65
if err != nil {
@@ -107,8 +107,7 @@ func Decompress(tarPath, baseDir string) error {
107
107
}
108
108
}
109
109
110
- // CompressTar takes a path to a file or directory and creates a .tar file
111
- // at the outputPath location
110
+ // CompressTar takes a path to a file or directory and creates a .tar file at the outputPath location.
112
111
func CompressTar (path , outputPath string ) error {
113
112
tarFile , err := os .Create (filepath .Clean (outputPath ))
114
113
if err != nil {
@@ -149,8 +148,7 @@ func CompressTar(path, outputPath string) error {
149
148
})
150
149
}
151
150
152
- // DecompressTar takes a location to a .tar file and a base path and
153
- // decompresses the contents wrt the base path
151
+ // DecompressTar takes a location to a .tar file and a base path and decompresses the contents wrt the base path.
154
152
func DecompressTar (tarPath , baseDir string ) error {
155
153
tarFile , err := os .Open (filepath .Clean (tarPath ))
156
154
if err != nil {
@@ -192,7 +190,7 @@ func DecompressTar(tarPath, baseDir string) error {
192
190
}
193
191
}
194
192
195
- // TarCopy uses tar archive to copy src to dst to preserve the folder structure
193
+ // TarCopy uses tar archive to copy src to dst to preserve the folder structure.
196
194
func TarCopy (src , dst , tempDir string ) error {
197
195
f , err := os .CreateTemp (tempDir , "tarcopy-*.tar.gzip" )
198
196
if err != nil {
0 commit comments