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

Commit

Permalink
add multiple option support and remove unused modules
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonYangShadow committed Dec 25, 2021
1 parent 6e72185 commit c8bebb8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 31 deletions.
5 changes: 0 additions & 5 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
# go-tests = true
# unused-packages = true


[[constraint]]
branch = "master"
name = "github.com/bradfitz/gomemcache"

[[constraint]]
name = "github.com/docker/distribution"
version = "2.7.1"
Expand Down
Binary file modified build/linux/x86_64/Linux-x86_64-lpmx
Binary file not shown.
12 changes: 3 additions & 9 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ func DockerReset(name string) *Error {
return err
}

func CommonFastRun(name, volume_map, command, engine, execmaps, mountfile string) *Error {
func CommonFastRun(name, volume_map, engine, execmaps, mountfile string, args ...string) *Error {
configmap, err := generateContainer(name, "", volume_map, engine, mountfile)
if err != nil {
return err
Expand All @@ -2467,7 +2467,7 @@ func CommonFastRun(name, volume_map, command, engine, execmaps, mountfile string
if len(execmaps) > 0 {
(*configmap)["execmaps"] = execmaps
}
err = Run(configmap, command)
err = Run(configmap, args...)
//remove container
if err != nil {
err = Destroy(id)
Expand Down Expand Up @@ -2623,7 +2623,7 @@ func Expose(id string, ipath string, name string) *Error {
ppath := fmt.Sprintf("%s/%s", currdir, os.Args[0])
ppath = path.Clean(ppath)
code := "#!/bin/bash\n" + ppath +
" resume " + id + " \"" + ipath + " " + "$@\"" +
" resume " + id + " -- " + ipath + " " + "\"$@\"" +
"\n"

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

LOGGER.WithFields(logrus.Fields{
"shell": con.UserShell,
"env": env,
"rootpath": con.RootPath,
"args": args,
}).Debug("bashShell debug, before shellenvpid is called")
cerr := ShellEnvPid(con.UserShell, env, con.RootPath, args...)
if cerr != nil {
return cerr
Expand Down
15 changes: 8 additions & 7 deletions docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

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

//Docker load image structure
Expand All @@ -41,15 +41,16 @@ type DockerSaveInfo struct {
//Skopeo manifest item structure
type SkopeoManifestItem struct {
MediaType string `json:"mediaType"`
Size uint `json:"size"`
Digest string `json:"digest"`
Size uint `json:"size"`
Digest string `json:"digest"`
}

//Skopeo manifest structure
type SkopeoManifest struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config SkopeoManifestItem `json:"config"`
Layers []SkopeoManifestItem `json:"layers"`
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config SkopeoManifestItem `json:"config"`
Layers []SkopeoManifestItem `json:"layers"`
}

func ListRepositories(username string, pass string) ([]string, *Error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/JasonYangShadow/lpmx
go 1.16

require (
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737 // indirect
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
github.com/gorilla/mux v1.8.0 // indirect
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
)

const (
VERSION = "alpha-1.8.3"
VERSION = "alpha-1.9.0"
)

func checkCompleteness() *Error {
Expand Down Expand Up @@ -469,7 +469,7 @@ func main() {
Use: "fastrun",
Short: "run container in a fast way without switching into shell",
Long: "docker run sub-command is the advanced command of lpmx, which is used for fast running the container created from Docker image",
Args: cobra.ExactArgs(2),
Args: cobra.MinimumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
err := checkCompleteness()
if err != nil {
Expand All @@ -478,7 +478,7 @@ func main() {
}
},
Run: func(cmd *cobra.Command, args []string) {
err := CommonFastRun(args[0], DockerRunVolume, args[1], DockerRunMode, DockerRunExecMap, DockerRunMountFile)
err := CommonFastRun(args[0], DockerRunVolume, DockerRunMode, DockerRunExecMap, DockerRunMountFile, args[1:]...)
if err != nil {
LOGGER.Fatal(err.Error())
return
Expand Down Expand Up @@ -795,7 +795,7 @@ func main() {
Use: "fastrun",
Short: "run container in a fast way without switching into shell",
Long: "singularity run sub-command is the advanced command of lpmx, which is used for fast running the container created from singularity image",
Args: cobra.ExactArgs(2),
Args: cobra.MinimumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
err := checkCompleteness()
if err != nil {
Expand All @@ -804,7 +804,7 @@ func main() {
}
},
Run: func(cmd *cobra.Command, args []string) {
err := CommonFastRun(args[0], DockerRunVolume, args[1], SingularityRunMode, SingularityRunExecMap, SingularityMountFile)
err := CommonFastRun(args[0], DockerRunVolume, SingularityRunMode, SingularityRunExecMap, SingularityMountFile, args[1:]...)
if err != nil {
LOGGER.Fatal(err.Error())
return
Expand Down
10 changes: 6 additions & 4 deletions paeudo/paeudo.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ func ShellEnvPid(sh string, env map[string]string, dir string, arg ...string) *E
var args []string
if len(arg) > 0 {
args = append(args, "-c")
for _, ar := range arg {
args = append(args, ar)
}
//here we need to merge all other arg as a string
args = append(args, strings.Join(arg, " "))
}

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

LOGGER.WithFields(logrus.Fields{
"env": envstrs,
"env": envstrs,
"shpath": shpath,
"args": args,
"length": len(args),
}).Debug("shell env debug")
err = cmd.Start()
if err != nil {
Expand Down

0 comments on commit c8bebb8

Please sign in to comment.