mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 06:56:29 +00:00
recoverable provisioning
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -271,3 +272,20 @@ func IsSupportedDockerVersion(info types.Info, K8sVersion string) (bool, error)
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func ReadFileFromContainer(ctx context.Context, dClient *client.Client, hostname, container, filePath string) (string, error) {
|
||||
reader, _, err := dClient.CopyFromContainer(ctx, container, filePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to copy file [%s] from container [%s] on host [%s]: %v", filePath, container, hostname, err)
|
||||
}
|
||||
defer reader.Close()
|
||||
tarReader := tar.NewReader(reader)
|
||||
if _, err := tarReader.Next(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
file, err := ioutil.ReadAll(tarReader)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(file), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user