Skip to content

Commit 6b34dfb

Browse files
Bump godo to v1.189.0 to fix App Ingress authority empty-string matching (#1782) (#1839)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2c818af commit 6b34dfb

9 files changed

Lines changed: 311 additions & 16 deletions

File tree

commands/apps_test.go

Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,289 @@ services:
955955
})
956956
}
957957

958+
func TestRunAppSpecGet_AuthoritySerialization(t *testing.T) {
959+
exactEmpty := ""
960+
exactDomain := "example.com"
961+
pathPrefixSlash := "/"
962+
pathPrefixEmpty := ""
963+
964+
tests := []struct {
965+
name string
966+
exact *string
967+
pathPrefix *string // nil means use "/"
968+
wantJSON string
969+
wantYAML string
970+
}{
971+
{
972+
name: "authority with empty exact string",
973+
exact: &exactEmpty,
974+
pathPrefix: nil,
975+
wantJSON: `{
976+
"name": "test",
977+
"services": [
978+
{
979+
"name": "service",
980+
"github": {
981+
"repo": "digitalocean/doctl",
982+
"branch": "main"
983+
}
984+
}
985+
],
986+
"ingress": {
987+
"rules": [
988+
{
989+
"match": {
990+
"path": {
991+
"prefix": "/"
992+
},
993+
"authority": {
994+
"exact": ""
995+
}
996+
},
997+
"component": {
998+
"name": "service"
999+
}
1000+
}
1001+
]
1002+
}
1003+
}
1004+
`,
1005+
wantYAML: `ingress:
1006+
rules:
1007+
- component:
1008+
name: service
1009+
match:
1010+
authority:
1011+
exact: ""
1012+
path:
1013+
prefix: /
1014+
name: test
1015+
services:
1016+
- github:
1017+
branch: main
1018+
repo: digitalocean/doctl
1019+
name: service
1020+
`,
1021+
},
1022+
{
1023+
name: "authority with non-empty exact string",
1024+
exact: &exactDomain,
1025+
pathPrefix: nil,
1026+
wantJSON: `{
1027+
"name": "test",
1028+
"services": [
1029+
{
1030+
"name": "service",
1031+
"github": {
1032+
"repo": "digitalocean/doctl",
1033+
"branch": "main"
1034+
}
1035+
}
1036+
],
1037+
"ingress": {
1038+
"rules": [
1039+
{
1040+
"match": {
1041+
"path": {
1042+
"prefix": "/"
1043+
},
1044+
"authority": {
1045+
"exact": "example.com"
1046+
}
1047+
},
1048+
"component": {
1049+
"name": "service"
1050+
}
1051+
}
1052+
]
1053+
}
1054+
}
1055+
`,
1056+
wantYAML: `ingress:
1057+
rules:
1058+
- component:
1059+
name: service
1060+
match:
1061+
authority:
1062+
exact: example.com
1063+
path:
1064+
prefix: /
1065+
name: test
1066+
services:
1067+
- github:
1068+
branch: main
1069+
repo: digitalocean/doctl
1070+
name: service
1071+
`,
1072+
},
1073+
{
1074+
name: "no authority set",
1075+
exact: nil,
1076+
pathPrefix: nil,
1077+
wantJSON: `{
1078+
"name": "test",
1079+
"services": [
1080+
{
1081+
"name": "service",
1082+
"github": {
1083+
"repo": "digitalocean/doctl",
1084+
"branch": "main"
1085+
}
1086+
}
1087+
],
1088+
"ingress": {
1089+
"rules": [
1090+
{
1091+
"match": {
1092+
"path": {
1093+
"prefix": "/"
1094+
}
1095+
},
1096+
"component": {
1097+
"name": "service"
1098+
}
1099+
}
1100+
]
1101+
}
1102+
}
1103+
`,
1104+
wantYAML: `ingress:
1105+
rules:
1106+
- component:
1107+
name: service
1108+
match:
1109+
path:
1110+
prefix: /
1111+
name: test
1112+
services:
1113+
- github:
1114+
branch: main
1115+
repo: digitalocean/doctl
1116+
name: service
1117+
`,
1118+
},
1119+
{
1120+
name: "authority with empty exact string and empty path prefix",
1121+
exact: &exactEmpty,
1122+
pathPrefix: &pathPrefixEmpty,
1123+
wantJSON: `{
1124+
"name": "test",
1125+
"services": [
1126+
{
1127+
"name": "service",
1128+
"github": {
1129+
"repo": "digitalocean/doctl",
1130+
"branch": "main"
1131+
}
1132+
}
1133+
],
1134+
"ingress": {
1135+
"rules": [
1136+
{
1137+
"match": {
1138+
"path": {
1139+
"prefix": ""
1140+
},
1141+
"authority": {
1142+
"exact": ""
1143+
}
1144+
},
1145+
"component": {
1146+
"name": "service"
1147+
}
1148+
}
1149+
]
1150+
}
1151+
}
1152+
`,
1153+
wantYAML: `ingress:
1154+
rules:
1155+
- component:
1156+
name: service
1157+
match:
1158+
authority:
1159+
exact: ""
1160+
path:
1161+
prefix: ""
1162+
name: test
1163+
services:
1164+
- github:
1165+
branch: main
1166+
repo: digitalocean/doctl
1167+
name: service
1168+
`,
1169+
},
1170+
}
1171+
1172+
for _, tc := range tests {
1173+
t.Run(tc.name, func(t *testing.T) {
1174+
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
1175+
var authority *godo.AppIngressSpecRuleStringMatch
1176+
if tc.exact != nil {
1177+
authority = &godo.AppIngressSpecRuleStringMatch{Exact: tc.exact}
1178+
}
1179+
1180+
pathForMatch := &pathPrefixSlash
1181+
if tc.pathPrefix != nil {
1182+
pathForMatch = tc.pathPrefix
1183+
}
1184+
1185+
spec := &godo.AppSpec{
1186+
Name: "test",
1187+
Services: []*godo.AppServiceSpec{
1188+
{
1189+
Name: "service",
1190+
GitHub: &godo.GitHubSourceSpec{
1191+
Repo: "digitalocean/doctl",
1192+
Branch: "main",
1193+
},
1194+
},
1195+
},
1196+
Ingress: &godo.AppIngressSpec{
1197+
Rules: []*godo.AppIngressSpecRule{
1198+
{
1199+
Match: &godo.AppIngressSpecRuleMatch{
1200+
Path: &godo.AppIngressSpecRuleStringMatch{Prefix: pathForMatch},
1201+
Authority: authority,
1202+
},
1203+
Component: &godo.AppIngressSpecRuleRoutingComponent{Name: "service"},
1204+
},
1205+
},
1206+
},
1207+
}
1208+
1209+
app := &godo.App{
1210+
ID: uuid.New().String(),
1211+
Spec: spec,
1212+
}
1213+
1214+
tm.apps.EXPECT().Get(app.ID).Times(2).Return(app, nil)
1215+
1216+
t.Run("json", func(t *testing.T) {
1217+
var buf bytes.Buffer
1218+
config.Doit.Set(config.NS, doctl.ArgFormat, "json")
1219+
config.Args = append(config.Args, app.ID)
1220+
config.Out = &buf
1221+
1222+
err := RunAppsSpecGet(config)
1223+
require.NoError(t, err)
1224+
require.Equal(t, tc.wantJSON, buf.String())
1225+
})
1226+
1227+
t.Run("yaml", func(t *testing.T) {
1228+
var buf bytes.Buffer
1229+
config.Doit.Set(config.NS, doctl.ArgFormat, "yaml")
1230+
config.Args = append(config.Args, app.ID)
1231+
config.Out = &buf
1232+
1233+
err := RunAppsSpecGet(config)
1234+
require.NoError(t, err)
1235+
require.Equal(t, tc.wantYAML, buf.String())
1236+
})
1237+
})
1238+
})
1239+
}
1240+
}
9581241
func TestRunAppsListRegions(t *testing.T) {
9591242
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
9601243
regions := []*godo.AppRegion{{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.25.0
55
require (
66
github.com/blang/semver v3.5.1+incompatible
77
github.com/creack/pty v1.1.21
8-
github.com/digitalocean/godo v1.187.0
8+
github.com/digitalocean/godo v1.189.0
99
github.com/docker/cli v24.0.5+incompatible
1010
github.com/docker/docker v25.0.6+incompatible
1111
github.com/docker/docker-credential-helpers v0.7.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
9191
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9292
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
9393
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
94-
github.com/digitalocean/godo v1.187.0 h1:Ga+pkJdebdhnzWmIjusyehDzm+WZ/joLiXM00tPOXVs=
95-
github.com/digitalocean/godo v1.187.0/go.mod h1:xQsWpVCCbkDrWisHA72hPzPlnC+4W5w/McZY5ij9uvU=
94+
github.com/digitalocean/godo v1.189.0 h1:93hHWsZdbJdkMsfZ21lMkOmd+BPMCTzu/+FIJ5FvAL4=
95+
github.com/digitalocean/godo v1.189.0/go.mod h1:xQsWpVCCbkDrWisHA72hPzPlnC+4W5w/McZY5ij9uvU=
9696
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
9797
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
9898
github.com/docker/cli v24.0.5+incompatible h1:WeBimjvS0eKdH4Ygx+ihVq1Q++xg36M/rMi4aXAvodc=

vendor/github.com/digitalocean/godo/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/digitalocean/godo/apps.gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/digitalocean/godo/apps_accessors.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/digitalocean/godo/godo.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/digitalocean/godo/kubernetes.go

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)