Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

Commit c8bebb8

Browse files
add multiple option support and remove unused modules
1 parent 6e72185 commit c8bebb8

File tree

7 files changed

+23
-31
lines changed

7 files changed

+23
-31
lines changed

Gopkg.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
# go-tests = true
2525
# unused-packages = true
2626

27-
28-
[[constraint]]
29-
branch = "master"
30-
name = "github.com/bradfitz/gomemcache"
31-
3227
[[constraint]]
3328
name = "github.com/docker/distribution"
3429
version = "2.7.1"
-620 Bytes
Binary file not shown.

container/container.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ func DockerReset(name string) *Error {
24582458
return err
24592459
}
24602460

2461-
func CommonFastRun(name, volume_map, command, engine, execmaps, mountfile string) *Error {
2461+
func CommonFastRun(name, volume_map, engine, execmaps, mountfile string, args ...string) *Error {
24622462
configmap, err := generateContainer(name, "", volume_map, engine, mountfile)
24632463
if err != nil {
24642464
return err
@@ -2467,7 +2467,7 @@ func CommonFastRun(name, volume_map, command, engine, execmaps, mountfile string
24672467
if len(execmaps) > 0 {
24682468
(*configmap)["execmaps"] = execmaps
24692469
}
2470-
err = Run(configmap, command)
2470+
err = Run(configmap, args...)
24712471
//remove container
24722472
if err != nil {
24732473
err = Destroy(id)
@@ -2623,7 +2623,7 @@ func Expose(id string, ipath string, name string) *Error {
26232623
ppath := fmt.Sprintf("%s/%s", currdir, os.Args[0])
26242624
ppath = path.Clean(ppath)
26252625
code := "#!/bin/bash\n" + ppath +
2626-
" resume " + id + " \"" + ipath + " " + "$@\"" +
2626+
" resume " + id + " -- " + ipath + " " + "\"$@\"" +
26272627
"\n"
26282628

26292629
fmt.Fprintf(f, code)
@@ -2977,12 +2977,6 @@ func (con *Container) bashShell(envmap map[string]string, args ...string) *Error
29772977
env["FAKEROOTPID"] = strings.TrimSuffix(os.Getenv("FAKEROOTPID"), "\n")
29782978
}
29792979

2980-
LOGGER.WithFields(logrus.Fields{
2981-
"shell": con.UserShell,
2982-
"env": env,
2983-
"rootpath": con.RootPath,
2984-
"args": args,
2985-
}).Debug("bashShell debug, before shellenvpid is called")
29862980
cerr := ShellEnvPid(con.UserShell, env, con.RootPath, args...)
29872981
if cerr != nil {
29882982
return cerr

docker/docker.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
const (
3030
DOCKER_URL = "https://registry-1.docker.io"
31-
SETTING_URL = "https://raw.githubusercontent.com/JasonYangShadow/LPMXSettingRepository/master"
31+
SETTING_URL = "https://raw.githubusercontent.com/JasonYangShadow/LPMXSettingRepository/master/v1.9"
3232
)
3333

3434
//Docker load image structure
@@ -41,15 +41,16 @@ type DockerSaveInfo struct {
4141
//Skopeo manifest item structure
4242
type SkopeoManifestItem struct {
4343
MediaType string `json:"mediaType"`
44-
Size uint `json:"size"`
45-
Digest string `json:"digest"`
44+
Size uint `json:"size"`
45+
Digest string `json:"digest"`
4646
}
47+
4748
//Skopeo manifest structure
4849
type SkopeoManifest struct {
49-
SchemaVersion int `json:"schemaVersion"`
50-
MediaType string `json:"mediaType"`
51-
Config SkopeoManifestItem `json:"config"`
52-
Layers []SkopeoManifestItem `json:"layers"`
50+
SchemaVersion int `json:"schemaVersion"`
51+
MediaType string `json:"mediaType"`
52+
Config SkopeoManifestItem `json:"config"`
53+
Layers []SkopeoManifestItem `json:"layers"`
5354
}
5455

5556
func ListRepositories(username string, pass string) ([]string, *Error) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/JasonYangShadow/lpmx
33
go 1.16
44

55
require (
6-
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737
6+
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737 // indirect
77
github.com/docker/distribution v2.7.1+incompatible
88
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
99
github.com/gorilla/mux v1.8.0 // indirect

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
)
2121

2222
const (
23-
VERSION = "alpha-1.8.3"
23+
VERSION = "alpha-1.9.0"
2424
)
2525

2626
func checkCompleteness() *Error {
@@ -469,7 +469,7 @@ func main() {
469469
Use: "fastrun",
470470
Short: "run container in a fast way without switching into shell",
471471
Long: "docker run sub-command is the advanced command of lpmx, which is used for fast running the container created from Docker image",
472-
Args: cobra.ExactArgs(2),
472+
Args: cobra.MinimumNArgs(1),
473473
PreRun: func(cmd *cobra.Command, args []string) {
474474
err := checkCompleteness()
475475
if err != nil {
@@ -478,7 +478,7 @@ func main() {
478478
}
479479
},
480480
Run: func(cmd *cobra.Command, args []string) {
481-
err := CommonFastRun(args[0], DockerRunVolume, args[1], DockerRunMode, DockerRunExecMap, DockerRunMountFile)
481+
err := CommonFastRun(args[0], DockerRunVolume, DockerRunMode, DockerRunExecMap, DockerRunMountFile, args[1:]...)
482482
if err != nil {
483483
LOGGER.Fatal(err.Error())
484484
return
@@ -795,7 +795,7 @@ func main() {
795795
Use: "fastrun",
796796
Short: "run container in a fast way without switching into shell",
797797
Long: "singularity run sub-command is the advanced command of lpmx, which is used for fast running the container created from singularity image",
798-
Args: cobra.ExactArgs(2),
798+
Args: cobra.MinimumNArgs(1),
799799
PreRun: func(cmd *cobra.Command, args []string) {
800800
err := checkCompleteness()
801801
if err != nil {
@@ -804,7 +804,7 @@ func main() {
804804
}
805805
},
806806
Run: func(cmd *cobra.Command, args []string) {
807-
err := CommonFastRun(args[0], DockerRunVolume, args[1], SingularityRunMode, SingularityRunExecMap, SingularityMountFile)
807+
err := CommonFastRun(args[0], DockerRunVolume, SingularityRunMode, SingularityRunExecMap, SingularityMountFile, args[1:]...)
808808
if err != nil {
809809
LOGGER.Fatal(err.Error())
810810
return

paeudo/paeudo.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ func ShellEnvPid(sh string, env map[string]string, dir string, arg ...string) *E
7777
var args []string
7878
if len(arg) > 0 {
7979
args = append(args, "-c")
80-
for _, ar := range arg {
81-
args = append(args, ar)
82-
}
80+
//here we need to merge all other arg as a string
81+
args = append(args, strings.Join(arg, " "))
8382
}
8483

8584
cmd := exec.Command(shpath, args...)
@@ -102,7 +101,10 @@ func ShellEnvPid(sh string, env map[string]string, dir string, arg ...string) *E
102101
cmd.Stdout = os.Stdout
103102

104103
LOGGER.WithFields(logrus.Fields{
105-
"env": envstrs,
104+
"env": envstrs,
105+
"shpath": shpath,
106+
"args": args,
107+
"length": len(args),
106108
}).Debug("shell env debug")
107109
err = cmd.Start()
108110
if err != nil {

0 commit comments

Comments
 (0)