提交 e4a75d02 编写于 作者: O openeuler-ci-bot 提交者: yangfeiyu

load: add usage doc for load command

fix: #I1PFQX

reason: add usage doc for load command
Signed-off-by: Nyangfeiyu <yangfeiyu2@huawei.com>
......@@ -260,12 +260,13 @@ func parseStaticBuildOpts() (*pb.BuildStatic, error) {
func runBuild(ctx context.Context, cli Cli) (string, error) {
var (
err error
content string
dest string
isIsulad bool
imageID string
msg *pb.BuildResponse
isIsulad bool
msg *pb.BuildResponse
err error
content string
dest string
imageID string
imageIDFilePath string
)
if dest, isIsulad, err = checkAndProcessOutput(); err != nil {
......@@ -277,6 +278,12 @@ func runBuild(ctx context.Context, cli Cli) (string, error) {
if err = encryptBuildArgs(); err != nil {
return "", errors.Wrap(err, "encrypt --build-arg failed")
}
imageIDFilePath, err = getAbsPath(buildOpts.imageIDFile)
if err != nil {
return "", err
}
buildOpts.imageIDFile = imageIDFilePath
buildStatic, err := parseStaticBuildOpts()
if err != nil {
return "", err
......@@ -457,3 +464,18 @@ func resolveDockerfilePath() (string, error) {
}
return resolvedPath, nil
}
func getAbsPath(path string) (string, error) {
if path == "" {
return "", nil
}
if filepath.IsAbs(path) {
return path, nil
}
pwd, err := os.Getwd()
if err != nil {
return "", err
}
return util.MakeAbsolute(path, pwd), nil
}
......@@ -613,3 +613,41 @@ func TestEncryptBuildArgs(t *testing.T) {
})
}
}
func TestGetAbsPath(t *testing.T) {
pwd, _ := os.Getwd()
type args struct {
path string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "TC1 - normal case with relative path",
args: args{path: "./imageID.txt"},
want: filepath.Join(pwd, "imageID.txt"),
wantErr: false,
},
{
name: "TC2 - normal case with abs path",
args: args{path: filepath.Join(pwd, "imageID.txt")},
want: filepath.Join(pwd, "imageID.txt"),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getAbsPath(tt.args.path)
if (err != nil) != tt.wantErr {
t.Errorf("getAbsPath() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("getAbsPath() got = %v, want %v", got, tt.want)
}
})
}
}
......@@ -24,6 +24,7 @@
* [-a, --all](#-a---all-1)
* [Version query](#version-query)
* [Tag an image](#tag-an-image)
* [Load an image](#load-an-image)
<!-- vim-markdown-toc -->
# Usage
......@@ -387,3 +388,31 @@ $ sudo isula-build ctr-img images
---------------------------------------------- ----------- ----------------- -------------------------- ------------
```
### Load an image
We can use the `load` command to load an image from the tarfile.
Usage:
`isula-build ctr-img load [flags]`
Currently, the following flags are supported:
```bash
Flags:
-i, --input string Path to local tarball
```
Use this command as follow:
```bash
$ sudo isula-build ctr-img load -i image.tar
Getting image source signatures
Copying blob sha256:37841116ad3b1eeea972c75ab8bad05f48f721a7431924bc547fc91c9076c1c8
Copying blob sha256:6eb4c21cc3fcb729a9df230ae522c1d3708ca66e5cf531713dbfa679837aa287
Copying config sha256:76a4dd2d5d6a18323ac8d90f959c3c8562bf592e2a559bab9b462ab600e9e5fc
Writing manifest to image destination
Storing signatures
Loaded image as 76a4dd2d5d6a18323ac8d90f959c3c8562bf592e2a559bab9b462ab600e9e5fc
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册