I am creating a service which programmatically creates and runs an OpenVPN Docker container (pschiffe/openvpn which extends kylemanna/openvpn) using the Golang SDK.
At some point in the process, the command easyrsa init-pki
is ran in the ovpn_initpki
script, which requires user input (typing "yes") to proceed. Is there any way using the SDK that I can either override this or programmatically input "yes" when it's required?
Code currently (error handling removed):
ctx := context.Context()
cli := client.NewClientWithOpts(client.WithAPIVersionNegotiation())
// pull image
// create volume
resp := cli.ContainerCreate(
ctx,
&container.Config{
Image: "pschiffe/openvpn",
Cmd: []string{"openvpn_initpki"}
Env: []string{"CA_KEY=xxxxxx","CA_CN=xxxxxx"},
},
&container.HostConfig{
Mounts: []mount.Mount{
{
Type: mount.TypeVolume,
Source: "volume_name",
Target: "/etc/openvpn",
},
},
}, nil, "")
cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{})