Skip to content

Commit 36679ec

Browse files
committed
Merge branch 'main' into bpmct/add-docker-builds
2 parents e2d007b + 841b792 commit 36679ec

File tree

9 files changed

+222
-23858
lines changed

9 files changed

+222
-23858
lines changed

cli/cliflag/cliflag.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string
4040
func StringArrayVarP(flagset *pflag.FlagSet, ptr *[]string, name string, shorthand string, env string, def []string, usage string) {
4141
val, ok := os.LookupEnv(env)
4242
if ok {
43-
def = strings.Split(val, ",")
43+
if val == "" {
44+
def = []string{}
45+
} else {
46+
def = strings.Split(val, ",")
47+
}
4448
}
4549
flagset.StringArrayVarP(ptr, name, shorthand, def, usage)
4650
}

cli/cliflag/cliflag_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ func TestCliflag(t *testing.T) {
9696
require.Equal(t, []string{"wow", "test"}, got)
9797
})
9898

99+
t.Run("StringArrayEnvVarEmpty", func(t *testing.T) {
100+
var ptr []string
101+
flagset, name, shorthand, env, usage := randomFlag()
102+
t.Setenv(env, "")
103+
cliflag.StringArrayVarP(flagset, &ptr, name, shorthand, env, nil, usage)
104+
got, err := flagset.GetStringArray(name)
105+
require.NoError(t, err)
106+
require.Equal(t, []string{}, got)
107+
})
108+
99109
t.Run("IntDefault", func(t *testing.T) {
100110
var ptr uint8
101111
flagset, name, shorthand, env, usage := randomFlag()

cli/ssh.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
var autostopPollInterval = 30 * time.Second
30-
var autostopNotifyCountdown = []time.Duration{5 * time.Minute}
30+
var autostopNotifyCountdown = []time.Duration{30 * time.Minute}
3131

3232
func ssh() *cobra.Command {
3333
var (

docker-compose.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ services:
55
ports:
66
- "7080:7080"
77
environment:
8-
CODER_PG_CONNECTION_URL: "postgresql://username:password@database/coder?sslmode=disable"
8+
CODER_PG_CONNECTION_URL: "postgresql://${POSTGRES_USER:-username}:${POSTGRES_PASSWORD:-password}@database/${POSTGRES_DB:-coder}?sslmode=disable"
99
CODER_ADDRESS: "0.0.0.0:7080"
10+
volumes:
11+
- /var/run/docker.sock:/var/run/docker.sock
1012
depends_on:
1113
database:
1214
condition: service_healthy

examples/docker-image-builds/main.tf

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ provider "docker" {
4141
host = "unix:///var/run/docker.sock"
4242
}
4343

44+
provider "coder" {
45+
url = "http://host.docker.internal:7080"
46+
}
47+
4448
data "coder_workspace" "me" {
4549
}
4650

@@ -93,6 +97,10 @@ resource "docker_container" "workspace" {
9397
dns = ["1.1.1.1"]
9498
command = ["sh", "-c", coder_agent.dev.init_script]
9599
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
100+
host {
101+
host = "host.docker.internal"
102+
ip = "host-gateway"
103+
}
96104
volumes {
97105
container_path = "/home/coder/"
98106
volume_name = docker_volume.home_volume.name

examples/docker/main.tf

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ provider "docker" {
4848
host = "unix:///var/run/docker.sock"
4949
}
5050

51+
provider "coder" {
52+
url = "http://host.docker.internal:7080"
53+
}
54+
5155
data "coder_workspace" "me" {
5256
}
5357

@@ -86,6 +90,10 @@ resource "docker_container" "workspace" {
8690
dns = ["1.1.1.1"]
8791
command = ["sh", "-c", coder_agent.dev.init_script]
8892
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
93+
host {
94+
host = "host.docker.internal"
95+
ip = "host-gateway"
96+
}
8997
volumes {
9098
container_path = "/home/coder/"
9199
volume_name = docker_volume.home_volume.name

0 commit comments

Comments
 (0)