Skip to content

Commit

Permalink
config: added tty option (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
towe75 committed Mar 11, 2021
1 parent e9a502d commit 0502b79
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased

* config: Added tty option
* config: Support for sysctl configuration [[GH-82](https://github.com/hashicorp/nomad-driver-podman/issues/82)]
* config: Fixed a bug where we always pulled an image if image name has a transport prefix [[GH-88](https://github.com/hashicorp/nomad-driver-podman/pull/88)]

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ config {
}
```

* **tty** - (Optional) true or false (default). Allocate a pseudo-TTY for the container.


## Example job

```
Expand Down
18 changes: 10 additions & 8 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
"ports": hclspec.NewAttr("ports", "list(string)", false),
"sysctl": hclspec.NewAttr("sysctl", "list(map(string))", false),
"tmpfs": hclspec.NewAttr("tmpfs", "list(string)", false),
"tty": hclspec.NewAttr("tty", "bool", false),
"volumes": hclspec.NewAttr("volumes", "list(string)", false),
})
)
Expand All @@ -83,24 +84,25 @@ type PluginConfig struct {

// TaskConfig is the driver configuration of a task within a job
type TaskConfig struct {
Args []string `codec:"args"`
Ports []string `codec:"ports"`
Tmpfs []string `codec:"tmpfs"`
Volumes []string `codec:"volumes"`
CapAdd []string `codec:"cap_add"`
CapDrop []string `codec:"cap_drop"`
Dns []string `codec:"dns"`
Command string `codec:"command"`
Entrypoint string `codec:"entrypoint"`
Args []string `codec:"args"`
WorkingDir string `codec:"working_dir"`
Hostname string `codec:"hostname"`
Image string `codec:"image"`
Init bool `codec:"init"`
InitPath string `codec:"init_path"`
MemoryReservation string `codec:"memory_reservation"`
MemorySwap string `codec:"memory_swap"`
NetworkMode string `codec:"network_mode"`
MemorySwappiness int64 `codec:"memory_swappiness"`
PortMap hclutils.MapStrInt `codec:"port_map"`
Ports []string `codec:"ports"`
Sysctl hclutils.MapStrStr `codec:"sysctl"`
Tmpfs []string `codec:"tmpfs"`
Volumes []string `codec:"volumes"`
CapAdd []string `codec:"cap_add"`
CapDrop []string `codec:"cap_drop"`
Dns []string `codec:"dns"`
Init bool `codec:"init"`
Tty bool `codec:"tty"`
}
1 change: 1 addition & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
createOpts.ContainerBasicConfig.Env = cfg.Env
createOpts.ContainerBasicConfig.Hostname = driverConfig.Hostname
createOpts.ContainerBasicConfig.Sysctl = driverConfig.Sysctl
createOpts.ContainerBasicConfig.Terminal = driverConfig.Tty

createOpts.ContainerBasicConfig.LogConfiguration.Path = cfg.StdoutPath

Expand Down
9 changes: 9 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,15 @@ func TestPodmanDriver_Caps(t *testing.T) {
require.NotContains(t, inspectData.EffectiveCaps, "CAP_CHOWN")
}

// check enabled tty option
func TestPodmanDriver_Tty(t *testing.T) {
taskCfg := newTaskConfig("", busyboxLongRunningCmd)
taskCfg.Tty = true
inspectData := startDestroyInspect(t, taskCfg, "tty")

require.True(t, inspectData.Config.Tty)
}

// check dns server configuration
func TestPodmanDriver_Dns(t *testing.T) {
if !tu.IsCI() {
Expand Down

0 comments on commit 0502b79

Please sign in to comment.