summaryrefslogtreecommitdiff
path: root/libpod/network
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/network')
-rw-r--r--libpod/network/config.go11
-rw-r--r--libpod/network/create.go4
-rw-r--r--libpod/network/netconflist.go9
3 files changed, 24 insertions, 0 deletions
diff --git a/libpod/network/config.go b/libpod/network/config.go
index 294e23509..ac4478602 100644
--- a/libpod/network/config.go
+++ b/libpod/network/config.go
@@ -149,7 +149,18 @@ type DNSNameConfig struct {
Capabilities map[string]bool `json:"capabilities"`
}
+// PodmanMachineConfig enables port handling on the host OS
+type PodmanMachineConfig struct {
+ PluginType string `json:"type"`
+ Capabilities map[string]bool `json:"capabilities"`
+}
+
// Bytes outputs the configuration as []byte
func (d DNSNameConfig) Bytes() ([]byte, error) {
return json.MarshalIndent(d, "", "\t")
}
+
+// Bytes outputs the configuration as []byte
+func (p PodmanMachineConfig) Bytes() ([]byte, error) {
+ return json.MarshalIndent(p, "", "\t")
+}
diff --git a/libpod/network/create.go b/libpod/network/create.go
index 4fe9b445f..aca8150b5 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -231,6 +231,10 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
plugins = append(plugins, NewDNSNamePlugin(DefaultPodmanDomainName))
}
}
+ // Add the podman-machine CNI plugin if we are in a machine
+ if runtimeConfig.MachineEnabled() { // check if we are in a machine vm
+ plugins = append(plugins, NewPodmanMachinePlugin())
+ }
ncList["plugins"] = plugins
b, err := json.MarshalIndent(ncList, "", " ")
if err != nil {
diff --git a/libpod/network/netconflist.go b/libpod/network/netconflist.go
index 08816f2bd..d2031df6d 100644
--- a/libpod/network/netconflist.go
+++ b/libpod/network/netconflist.go
@@ -293,3 +293,12 @@ func getCreatedTimestamp(config *config.Config, netconf *libcni.NetworkConfigLis
created := time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec)) // nolint: unconvert
return &created, nil
}
+
+func NewPodmanMachinePlugin() PodmanMachineConfig {
+ caps := make(map[string]bool, 1)
+ caps["portMappings"] = true
+ return PodmanMachineConfig{
+ PluginType: "podman-machine",
+ Capabilities: caps,
+ }
+}