mirror of
https://github.com/linka-cloud/d2vm.git
synced 2024-11-29 11:06:24 +00:00
network-manager: validate flag value
Dockerfile: fix ubuntu version to 20.04 Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
35a50b79f1
commit
506919cbad
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ bin/
|
|||||||
dist/
|
dist/
|
||||||
images
|
images
|
||||||
wstation
|
wstation
|
||||||
|
/d2vm
|
||||||
|
@ -25,7 +25,7 @@ COPY . .
|
|||||||
|
|
||||||
RUN make .build
|
RUN make .build
|
||||||
|
|
||||||
FROM ubuntu
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
||||||
|
2
Makefile
2
Makefile
@ -70,6 +70,8 @@ check-fmt:
|
|||||||
vet:
|
vet:
|
||||||
@go list ./...|grep -v scratch|GOOS=linux xargs go vet
|
@go list ./...|grep -v scratch|GOOS=linux xargs go vet
|
||||||
|
|
||||||
|
build-dev: docker-build .build
|
||||||
|
|
||||||
.build:
|
.build:
|
||||||
@go generate ./...
|
@go generate ./...
|
||||||
@go build -o d2vm -ldflags "-s -w -X '$(MODULE).Version=$(VERSION)' -X '$(MODULE).BuildDate=$(shell date)'" ./cmd/d2vm
|
@go build -o d2vm -ldflags "-s -w -X '$(MODULE).Version=$(VERSION)' -X '$(MODULE).BuildDate=$(shell date)'" ./cmd/d2vm
|
||||||
|
Binary file not shown.
@ -50,6 +50,15 @@ const (
|
|||||||
NetworkManagerNetplan NetworkManager = "netplan"
|
NetworkManagerNetplan NetworkManager = "netplan"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (n NetworkManager) Validate() error {
|
||||||
|
switch n {
|
||||||
|
case NetworkManagerNone, NetworkManagerIfupdown2, NetworkManagerNetplan:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported network manager: %s", n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type Dockerfile struct {
|
type Dockerfile struct {
|
||||||
Image string
|
Image string
|
||||||
Password string
|
Password string
|
||||||
@ -78,14 +87,26 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo
|
|||||||
case ReleaseAlpine:
|
case ReleaseAlpine:
|
||||||
d.tmpl = alpineDockerfileTemplate
|
d.tmpl = alpineDockerfileTemplate
|
||||||
net = NetworkManagerIfupdown2
|
net = NetworkManagerIfupdown2
|
||||||
|
if networkManager == NetworkManagerNetplan {
|
||||||
|
return d, fmt.Errorf("netplan is not supported on alpine")
|
||||||
|
}
|
||||||
case ReleaseCentOS:
|
case ReleaseCentOS:
|
||||||
d.tmpl = centOSDockerfileTemplate
|
d.tmpl = centOSDockerfileTemplate
|
||||||
|
net = NetworkManagerNone
|
||||||
|
if networkManager != "" && networkManager != NetworkManagerNone {
|
||||||
|
return Dockerfile{}, fmt.Errorf("network manager is not supported on centos")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return Dockerfile{}, fmt.Errorf("unsupported distribution: %s", release.ID)
|
return Dockerfile{}, fmt.Errorf("unsupported distribution: %s", release.ID)
|
||||||
}
|
}
|
||||||
if d.NetworkManager == "" {
|
if d.NetworkManager == "" {
|
||||||
logrus.Warnf("no network manager specified, using distribution defaults: %s", net)
|
if release.ID != ReleaseCentOS {
|
||||||
|
logrus.Warnf("no network manager specified, using distribution defaults: %s", net)
|
||||||
|
}
|
||||||
d.NetworkManager = net
|
d.NetworkManager = net
|
||||||
}
|
}
|
||||||
|
if err := d.NetworkManager.Validate(); err != nil {
|
||||||
|
return Dockerfile{}, err
|
||||||
|
}
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,9 @@ func RunD2VM(ctx context.Context, image, version, cmd string, args ...string) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if image == "" {
|
||||||
|
image = "linkacloud/d2vm"
|
||||||
|
}
|
||||||
if version == "" {
|
if version == "" {
|
||||||
version = "latest"
|
version = "latest"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user