update cl-k8s

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
Jess Frazelle 2018-03-20 03:02:29 -04:00
parent 098b76c017
commit d65ed3203e
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
2 changed files with 32 additions and 28 deletions

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8d28ea2d1f67cefed35b70f0b7a314da38b5764dd40b4635d2e475470d1fad65
size 30784767
oid sha256:f2e161341cf9636f3d72281432f443cf2772495b7f00bec62affaeaacc695a25
size 30769935

View file

@ -2,7 +2,6 @@ package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
@ -26,6 +25,8 @@ var (
root string
file string
dir string
shortpath string
)
func init() {
@ -42,28 +43,6 @@ func init() {
if flag.NArg() < 1 {
logrus.Fatal("pass a file to run with cl-k8s")
}
// Get the file args passed.
file := flag.Arg(0)
// Get the absolute path.
var err error
file, err = filepath.Abs(file)
if err != nil {
logrus.Fatal(err)
}
// Check if its directory.
fi, err := os.Stat(file)
if err != nil {
logrus.Fatal(err)
}
if !fi.Mode().IsDir() {
// Copy the file to a temporary directory.
file, err = copyFile(file)
if err != nil {
logrus.Fatal(err)
}
fmt.Printf("new file is %s\n", file)
}
}
//go:generate go run generate.go
@ -73,6 +52,32 @@ func main() {
return
}
// Get the file args passed.
file = flag.Arg(0)
// Get the absolute path.
var err error
file, err = filepath.Abs(file)
if err != nil {
logrus.Fatal(err)
}
// Check if its directory.
fi, err := os.Stat(file)
if err != nil {
logrus.Fatal(err)
}
dir = file
if !fi.Mode().IsDir() {
// Copy the file to a temporary directory.
file, err = copyFile(file)
if err != nil {
logrus.Fatal(err)
}
dir = filepath.Dir(file)
}
// Create a new container spec with the following options.
opts := container.SpecOpts{
Rootless: true,
@ -82,12 +87,11 @@ func main() {
{
Destination: "/home/user/scripts/",
Type: "bind",
Source: filepath.Dir(file),
Source: dir,
Options: []string{"bind", "ro"},
},
},
}
fmt.Printf("opts %#v\n", opts)
spec := container.Spec(opts)
// Initialize the container object.