mirror of
https://github.com/linka-cloud/d2vm.git
synced 2024-11-25 09: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
3417f50e11
commit
1721146c7d
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ bin/
|
||||
dist/
|
||||
images
|
||||
wstation
|
||||
/d2vm
|
||||
|
@ -25,7 +25,7 @@ COPY . .
|
||||
|
||||
RUN make .build
|
||||
|
||||
FROM ubuntu
|
||||
FROM ubuntu:20.04
|
||||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
||||
|
2
Makefile
2
Makefile
@ -70,6 +70,8 @@ check-fmt:
|
||||
vet:
|
||||
@go list ./...|grep -v scratch|GOOS=linux xargs go vet
|
||||
|
||||
build-dev: docker-build .build
|
||||
|
||||
.build:
|
||||
@go generate ./...
|
||||
@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"
|
||||
)
|
||||
|
||||
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 {
|
||||
Image string
|
||||
Password string
|
||||
@ -78,14 +87,26 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo
|
||||
case ReleaseAlpine:
|
||||
d.tmpl = alpineDockerfileTemplate
|
||||
net = NetworkManagerIfupdown2
|
||||
if networkManager == NetworkManagerNetplan {
|
||||
return d, fmt.Errorf("netplan is not supported on alpine")
|
||||
}
|
||||
case ReleaseCentOS:
|
||||
d.tmpl = centOSDockerfileTemplate
|
||||
net = NetworkManagerNone
|
||||
if networkManager != "" && networkManager != NetworkManagerNone {
|
||||
return Dockerfile{}, fmt.Errorf("network manager is not supported on centos")
|
||||
}
|
||||
default:
|
||||
return Dockerfile{}, fmt.Errorf("unsupported distribution: %s", release.ID)
|
||||
}
|
||||
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
|
||||
}
|
||||
if err := d.NetworkManager.Validate(); err != nil {
|
||||
return Dockerfile{}, err
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
@ -102,6 +102,9 @@ func RunD2VM(ctx context.Context, image, version, cmd string, args ...string) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if image == "" {
|
||||
image = "linkacloud/d2vm"
|
||||
}
|
||||
if version == "" {
|
||||
version = "latest"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user