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 1d95b0a02a
commit b9808eb70c

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.