-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Doer-org/feature/tar.gz
Feature/tar.gz
- Loading branch information
Showing
13 changed files
with
107 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,5 @@ | |
go.work | ||
|
||
dist/ | ||
tmp-tar/ | ||
tmp-tar/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
package docker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreateContainer(t *testing.T){ | ||
resp_id, err := CreateContainer() | ||
assert.NotEmpty(t, resp_id) | ||
t.Logf("resp_id: %s", resp_id) | ||
assert.NoError(t, err) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package docker | ||
|
||
import ( | ||
"compress/gzip" | ||
"context" | ||
"os" | ||
|
||
"github.com/Doer-org/ketos/internal/docker" | ||
"github.com/docker/docker/client" | ||
) | ||
|
||
func DecompressTarGzToImage() error { | ||
// tar.gzをimageに展開 | ||
ctx := context.Background() | ||
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) | ||
if err != nil { | ||
return err | ||
} | ||
tarGzFileName := "../../../tmp-tar" + "/" + docker.ImageName + ".tar.gz" | ||
|
||
gzFile, err := os.Open(tarGzFileName) | ||
if err != nil { | ||
return err | ||
} | ||
defer gzFile.Close() | ||
|
||
gzReader, err := gzip.NewReader(gzFile) | ||
if err != nil { | ||
return err | ||
} | ||
defer gzReader.Close() | ||
|
||
loadResponse, err := cli.ImageLoad(ctx, gzReader, true) | ||
if err != nil { | ||
return err | ||
} | ||
defer loadResponse.Body.Close() | ||
|
||
// tar.gzファイルを削除するコードはコメントアウトされていますが、必要に応じて有効化してください | ||
// err = os.Remove(tarGzFileName) | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package docker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDecompressTarGzToImage(t *testing.T) { | ||
err := DecompressTarGzToImage() | ||
assert.NoError(t, err) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
package docker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRunContainer(t *testing.T){ | ||
respId, err := CreateContainer() | ||
assert.NotEmpty(t, respId) | ||
t.Logf("respId: %s", respId) | ||
assert.NoError(t, err) | ||
err = RunContainer(respId) | ||
assert.NoError(t, err) | ||
} |