forked from LaconicNetwork/kompose
remove tag experimental
This commit is contained in:
parent
327f96943e
commit
670d8423e5
@ -64,15 +64,13 @@ $ make binary
|
|||||||
Or `go build`:
|
Or `go build`:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ go build -tags experimental -o kompose ./cli/main
|
$ go build -o kompose ./cli/main
|
||||||
```
|
```
|
||||||
|
|
||||||
You need `-tags experimental` because the current `bundlefile` package of docker/libcompose is still experimental.
|
|
||||||
|
|
||||||
If you have `go` v1.5, it's still good to build `kompose` with the following settings:
|
If you have `go` v1.5, it's still good to build `kompose` with the following settings:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ CGO_ENABLED=0 GO15VENDOREXPERIMENT=1 go build -o kompose -tags experimental ./cli/main
|
$ CGO_ENABLED=0 GO15VENDOREXPERIMENT=1 go build -o kompose ./cli/main
|
||||||
```
|
```
|
||||||
|
|
||||||
To create a multi-platform binary, use the `binary-cross` command via `make`:
|
To create a multi-platform binary, use the `binary-cross` command via `make`:
|
||||||
|
|||||||
@ -17,21 +17,48 @@ limitations under the License.
|
|||||||
package bundle
|
package bundle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/cli/command/bundlefile"
|
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bundle struct {
|
type Bundle struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bundlefile stores the contents of a bundlefile
|
||||||
|
type Bundlefile struct {
|
||||||
|
Version string
|
||||||
|
Services map[string]Service
|
||||||
|
}
|
||||||
|
|
||||||
|
// Service is a service from a bundlefile
|
||||||
|
type Service struct {
|
||||||
|
Image string
|
||||||
|
Command []string `json:",omitempty"`
|
||||||
|
Args []string `json:",omitempty"`
|
||||||
|
Env []string `json:",omitempty"`
|
||||||
|
Labels map[string]string `json:",omitempty"`
|
||||||
|
Ports []Port `json:",omitempty"`
|
||||||
|
WorkingDir *string `json:",omitempty"`
|
||||||
|
User *string `json:",omitempty"`
|
||||||
|
Networks []string `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Port is a port as defined in a bundlefile
|
||||||
|
type Port struct {
|
||||||
|
Protocol string
|
||||||
|
Port uint32
|
||||||
|
}
|
||||||
|
|
||||||
// load image from dab file
|
// load image from dab file
|
||||||
func loadImage(service bundlefile.Service) (string, string) {
|
func loadImage(service Service) (string, string) {
|
||||||
character := "@"
|
character := "@"
|
||||||
if strings.Contains(service.Image, character) {
|
if strings.Contains(service.Image, character) {
|
||||||
return service.Image[0:strings.Index(service.Image, character)], ""
|
return service.Image[0:strings.Index(service.Image, character)], ""
|
||||||
@ -40,7 +67,7 @@ func loadImage(service bundlefile.Service) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load environment variables from dab file
|
// load environment variables from dab file
|
||||||
func loadEnvVars(service bundlefile.Service) ([]kobject.EnvVar, string) {
|
func loadEnvVars(service Service) ([]kobject.EnvVar, string) {
|
||||||
envs := []kobject.EnvVar{}
|
envs := []kobject.EnvVar{}
|
||||||
for _, env := range service.Env {
|
for _, env := range service.Env {
|
||||||
character := "="
|
character := "="
|
||||||
@ -77,7 +104,7 @@ func loadEnvVars(service bundlefile.Service) ([]kobject.EnvVar, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load ports from dab file
|
// load ports from dab file
|
||||||
func loadPorts(service bundlefile.Service) ([]kobject.Ports, string) {
|
func loadPorts(service Service) ([]kobject.Ports, string) {
|
||||||
ports := []kobject.Ports{}
|
ports := []kobject.Ports{}
|
||||||
for _, port := range service.Ports {
|
for _, port := range service.Ports {
|
||||||
var p api.Protocol
|
var p api.Protocol
|
||||||
@ -109,7 +136,7 @@ func (b *Bundle) LoadFile(file string) kobject.KomposeObject {
|
|||||||
logrus.Fatalf("Failed to read bundles file: ", err)
|
logrus.Fatalf("Failed to read bundles file: ", err)
|
||||||
}
|
}
|
||||||
reader := strings.NewReader(string(buf))
|
reader := strings.NewReader(string(buf))
|
||||||
bundle, err := bundlefile.LoadFile(reader)
|
bundle, err := loadFile(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Failed to parse bundles file: ", err)
|
logrus.Fatalf("Failed to parse bundles file: ", err)
|
||||||
}
|
}
|
||||||
@ -150,3 +177,28 @@ func (b *Bundle) LoadFile(file string) kobject.KomposeObject {
|
|||||||
|
|
||||||
return komposeObject
|
return komposeObject
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadFile loads a bundlefile from a path to the file
|
||||||
|
func loadFile(reader io.Reader) (*Bundlefile, error) {
|
||||||
|
bundlefile := &Bundlefile{}
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(reader)
|
||||||
|
if err := decoder.Decode(bundlefile); err != nil {
|
||||||
|
switch jsonErr := err.(type) {
|
||||||
|
case *json.SyntaxError:
|
||||||
|
return nil, fmt.Errorf(
|
||||||
|
"JSON syntax error at byte %v: %s",
|
||||||
|
jsonErr.Offset,
|
||||||
|
jsonErr.Error())
|
||||||
|
case *json.UnmarshalTypeError:
|
||||||
|
return nil, fmt.Errorf(
|
||||||
|
"Unexpected type at byte %v. Expected %s but received %s.",
|
||||||
|
jsonErr.Offset,
|
||||||
|
jsonErr.Type,
|
||||||
|
jsonErr.Value)
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return bundlefile, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
GITCOMMIT=$(git rev-parse --short HEAD)
|
GITCOMMIT=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
BUILD_FLAGS=(-tags experimental -ldflags="-w -X github.com/kubernetes-incubator/kompose/version.GITCOMMIT=${GITCOMMIT}")
|
BUILD_FLAGS=(-ldflags="-w -X github.com/kubernetes-incubator/kompose/version.GITCOMMIT=${GITCOMMIT}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user