mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-08 21:38:39 +02:00
add another snapshotter
This commit is contained in:
@@ -17,8 +17,10 @@ limitations under the License.
|
||||
package buildcontext
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||
@@ -37,6 +39,25 @@ func (g *GCS) UnpackTarFromBuildContext() (string, error) {
|
||||
return constants.BuildContextDir, unpackTarFromGCSBucket(bucket, item, constants.BuildContextDir)
|
||||
}
|
||||
|
||||
func UploadToBucket(r io.Reader, dest string) error {
|
||||
ctx := context.Background()
|
||||
context := strings.SplitAfter(dest, "://")[1]
|
||||
bucketName, item := util.GetBucketAndItem(context)
|
||||
client, err := storage.NewClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bucket := client.Bucket(bucketName)
|
||||
w := bucket.Object(item).NewWriter(ctx)
|
||||
if _, err := io.Copy(w, r); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// unpackTarFromGCSBucket unpacks the context.tar.gz file in the given bucket to the given directory
|
||||
func unpackTarFromGCSBucket(bucketName, item, directory string) error {
|
||||
// Get the tar from the bucket
|
||||
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
// output set.
|
||||
// * Add all ancestors of each path to the output set.
|
||||
func ResolvePaths(paths []string, wl []util.IgnoreListEntry) (pathsToAdd []string, err error) {
|
||||
logrus.Infof("Resolving %d paths", len(paths))
|
||||
logrus.Tracef("Resolving paths %s", paths)
|
||||
|
||||
fileSet := make(map[string]bool)
|
||||
|
||||
+1
-2
@@ -126,7 +126,7 @@ func RedoHasher() func(string) (string, error) {
|
||||
}
|
||||
h.Write([]byte(fi.Mode().String()))
|
||||
h.Write([]byte(fi.ModTime().String()))
|
||||
h.Write([]byte(strconv.FormatInt(fi.Size(), 64)))
|
||||
h.Write([]byte(strconv.FormatInt(fi.Size(), 16)))
|
||||
h.Write([]byte(strconv.FormatUint(uint64(fi.Sys().(*syscall.Stat_t).Uid), 36)))
|
||||
h.Write([]byte(","))
|
||||
h.Write([]byte(strconv.FormatUint(uint64(fi.Sys().(*syscall.Stat_t).Gid), 36)))
|
||||
@@ -136,7 +136,6 @@ func RedoHasher() func(string) (string, error) {
|
||||
return hasher
|
||||
}
|
||||
|
||||
|
||||
// SHA256 returns the shasum of the contents of r
|
||||
func SHA256(r io.Reader) (string, error) {
|
||||
hasher := sha256.New()
|
||||
|
||||
Reference in New Issue
Block a user