Skip to content

Commit d7dc88a

Browse files
committed
Merge branch 'main' of https://github.com/metal-stack/api into vpn-service
2 parents abfdf6f + 48e63cc commit d7dc88a

File tree

17 files changed

+210
-178
lines changed

17 files changed

+210
-178
lines changed

doc/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,6 +7278,13 @@ <h3 id="metalstack.api.v2.MachineAllocationQuery">MachineAllocationQuery</h3>
72787278
<td><p>Labels for which this machine allocation should get filtered </p></td>
72797279
</tr>
72807280

7281+
<tr>
7282+
<td>vpn</td>
7283+
<td><a href="#metalstack.api.v2.MachineVPN">MachineVPN</a></td>
7284+
<td>optional</td>
7285+
<td><p>VPN query if this machine has a vpn configuration </p></td>
7286+
</tr>
7287+
72817288
</tbody>
72827289
</table>
72837290

generate/generate.go

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -143,48 +143,27 @@ func servicePermissions(root string) (*permissions.ServicePermissions, error) {
143143
}
144144
auditable[methodName] = true
145145
// Tenant
146-
switch *methodOpt.IdentifierValue {
147-
case v1.TenantRole_TENANT_ROLE_OWNER.String():
148-
roles.Tenant[v1.TenantRole_TENANT_ROLE_OWNER.String()] = append(roles.Tenant[v1.TenantRole_TENANT_ROLE_OWNER.String()], methodName)
149-
visibility.Tenant[methodName] = true
150-
case v1.TenantRole_TENANT_ROLE_EDITOR.String():
151-
roles.Tenant[v1.TenantRole_TENANT_ROLE_EDITOR.String()] = append(roles.Tenant[v1.TenantRole_TENANT_ROLE_EDITOR.String()], methodName)
152-
visibility.Tenant[methodName] = true
153-
case v1.TenantRole_TENANT_ROLE_VIEWER.String():
154-
roles.Tenant[v1.TenantRole_TENANT_ROLE_VIEWER.String()] = append(roles.Tenant[v1.TenantRole_TENANT_ROLE_VIEWER.String()], methodName)
155-
visibility.Tenant[methodName] = true
156-
case v1.TenantRole_TENANT_ROLE_GUEST.String():
157-
roles.Tenant[v1.TenantRole_TENANT_ROLE_GUEST.String()] = append(roles.Tenant[v1.TenantRole_TENANT_ROLE_GUEST.String()], methodName)
146+
switch role := *methodOpt.IdentifierValue; role {
147+
case v1.TenantRole_TENANT_ROLE_OWNER.String(), v1.TenantRole_TENANT_ROLE_EDITOR.String(), v1.TenantRole_TENANT_ROLE_VIEWER.String(), v1.TenantRole_TENANT_ROLE_GUEST.String():
148+
roles.Tenant[role] = append(roles.Tenant[role], methodName)
158149
visibility.Tenant[methodName] = true
159150
case v1.TenantRole_TENANT_ROLE_UNSPECIFIED.String():
160151
// noop
161152
// Project
162-
case v1.ProjectRole_PROJECT_ROLE_OWNER.String():
163-
roles.Project[v1.ProjectRole_PROJECT_ROLE_OWNER.String()] = append(roles.Project[v1.ProjectRole_PROJECT_ROLE_OWNER.String()], methodName)
164-
visibility.Project[methodName] = true
165-
case v1.ProjectRole_PROJECT_ROLE_EDITOR.String():
153+
case v1.ProjectRole_PROJECT_ROLE_OWNER.String(), v1.ProjectRole_PROJECT_ROLE_EDITOR.String(), v1.ProjectRole_PROJECT_ROLE_VIEWER.String():
154+
roles.Project[role] = append(roles.Project[role], methodName)
166155
visibility.Project[methodName] = true
167-
roles.Project[v1.ProjectRole_PROJECT_ROLE_EDITOR.String()] = append(roles.Project[v1.ProjectRole_PROJECT_ROLE_EDITOR.String()], methodName)
168-
case v1.ProjectRole_PROJECT_ROLE_VIEWER.String():
169-
visibility.Project[methodName] = true
170-
roles.Project[v1.ProjectRole_PROJECT_ROLE_VIEWER.String()] = append(roles.Project[v1.ProjectRole_PROJECT_ROLE_VIEWER.String()], methodName)
171156
case v1.ProjectRole_PROJECT_ROLE_UNSPECIFIED.String():
172157
// noop
173158
// Admin
174-
case v1.AdminRole_ADMIN_ROLE_EDITOR.String():
175-
roles.Admin[v1.AdminRole_ADMIN_ROLE_EDITOR.String()] = append(roles.Admin[v1.AdminRole_ADMIN_ROLE_EDITOR.String()], methodName)
176-
visibility.Admin[methodName] = true
177-
case v1.AdminRole_ADMIN_ROLE_VIEWER.String():
178-
roles.Admin[v1.AdminRole_ADMIN_ROLE_VIEWER.String()] = append(roles.Admin[v1.AdminRole_ADMIN_ROLE_VIEWER.String()], methodName)
159+
case v1.AdminRole_ADMIN_ROLE_EDITOR.String(), v1.AdminRole_ADMIN_ROLE_VIEWER.String():
160+
roles.Admin[role] = append(roles.Admin[role], methodName)
179161
visibility.Admin[methodName] = true
180162
case v1.AdminRole_ADMIN_ROLE_UNSPECIFIED.String():
181163
// noop
182164
// Infra
183-
case v1.InfraRole_INFRA_ROLE_EDITOR.String():
184-
roles.Infra[v1.InfraRole_INFRA_ROLE_EDITOR.String()] = append(roles.Infra[v1.InfraRole_INFRA_ROLE_EDITOR.String()], methodName)
185-
visibility.Infra[methodName] = true
186-
case v1.InfraRole_INFRA_ROLE_VIEWER.String():
187-
roles.Infra[v1.InfraRole_INFRA_ROLE_VIEWER.String()] = append(roles.Infra[v1.InfraRole_INFRA_ROLE_VIEWER.String()], methodName)
165+
case v1.InfraRole_INFRA_ROLE_EDITOR.String(), v1.InfraRole_INFRA_ROLE_VIEWER.String():
166+
roles.Infra[role] = append(roles.Infra[role], methodName)
188167
visibility.Infra[methodName] = true
189168
case v1.InfraRole_INFRA_ROLE_UNSPECIFIED.String():
190169
// noop

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/metal-stack/api
33
go 1.25
44

55
require (
6-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1
7-
buf.build/go/protovalidate v1.0.1
6+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20251209175733-2a1774d88802.1
7+
buf.build/go/protovalidate v1.1.0
88
connectrpc.com/connect v1.19.1
99
github.com/bufbuild/protocompile v0.14.1
1010
github.com/go-task/slim-sprig/v3 v3.0.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 h1:31on4W/yPcV4nZHL4+UCiCvLPsMqe/vJcNg8Rci0scc=
2-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4=
3-
buf.build/go/protovalidate v1.0.1 h1:Fwmf08OOUuKVeMvEnDmcKxQam4PJc/zFgvVX64BhTms=
4-
buf.build/go/protovalidate v1.0.1/go.mod h1:SoZmvk/3ZzOVg9YSkTdm4grMAByjf8zgZq4ZNaLZXoQ=
1+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20251209175733-2a1774d88802.1 h1:ZnX3qpF/pDiYrf+Q3p+/zCzZ5ELSpszy5hdVarDMSV4=
2+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20251209175733-2a1774d88802.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4=
3+
buf.build/go/protovalidate v1.1.0 h1:pQqEQRpOo4SqS60qkvmhLTTQU9JwzEvdyiqAtXa5SeY=
4+
buf.build/go/protovalidate v1.1.0/go.mod h1:bGZcPiAQDC3ErCHK3t74jSoJDFOs2JH3d7LWuTEIdss=
55
cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=
66
cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
77
connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14=

go/metalstack/api/v2/machine.pb.go

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

go/tests/mocks/client/Adminv2.go

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

go/tests/validation/filesystem_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,18 @@ func TestValidateFilesystem(t *testing.T) {
2525
Device: "/",
2626
},
2727
wantErr: true,
28-
wantErrorMessage: `validation error:
29-
- device: value length must be at least 2 characters [string.min_len]
30-
- format: value is required [required]`,
28+
wantErrorMessage: `validation errors:
29+
- device: value length must be at least 2 characters
30+
- format: value is required`,
3131
},
3232
{
3333
name: "Invalid Filesystem, device to short, format invalid",
3434
msg: &apiv2.Filesystem{
3535
Device: "/dev/sda3",
3636
Format: apiv2.Format(99),
3737
},
38-
wantErr: true,
39-
wantErrorMessage: `validation error:
40-
- format: value must be one of the defined enum values [enum.defined_only]`,
38+
wantErr: true,
39+
wantErrorMessage: `validation error: format: value must be one of the defined enum values`,
4140
},
4241
{
4342
name: "Valid FilesystemLayout minimal config",
@@ -62,9 +61,8 @@ func TestValidateFilesystem(t *testing.T) {
6261
Name: proto.String("c"),
6362
Description: proto.String("c1-large"),
6463
},
65-
wantErr: true,
66-
wantErrorMessage: `validation error:
67-
- name: must be within 2 and 128 characters [string.is_name]`},
64+
wantErr: true,
65+
wantErrorMessage: `validation error: name: must be within 2 and 128 characters`},
6866
}
6967

7068
validateProtos(t, tests)

go/tests/validation/firewall-rule_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ func TestValidateFirewallRules(t *testing.T) {
1717
Comment: "a rule",
1818
},
1919
wantErr: true,
20-
wantErrorMessage: `validation error:
21-
- protocol: value must be one of the defined enum values [enum.defined_only]
22-
- ports[0]: value must be less than or equal to 65532 [uint32.lte]
23-
- to: given prefixes must be valid [repeated.prefixes]`,
20+
wantErrorMessage: `validation errors:
21+
- protocol: value must be one of the defined enum values
22+
- ports[0]: value must be less than or equal to 65532
23+
- to: given prefixes must be valid`,
2424
},
2525
{
2626
name: "Invalid Rule with invalid comment",
@@ -31,7 +31,7 @@ func TestValidateFirewallRules(t *testing.T) {
3131
Comment: "a # invalid 3 rule",
3232
},
3333
wantErr: true,
34-
wantErrorMessage: "validation error:\n - comment: value does not match regex pattern `^[a-z_ -]*$` [string.pattern]",
34+
wantErrorMessage: "validation error: comment: value does not match regex pattern `^[a-z_ -]*$`",
3535
},
3636
}
3737

go/tests/validation/image_test.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ func TestValidateImage(t *testing.T) {
2727
Url: "not-a-uri",
2828
Features: []apiv2.ImageFeature{apiv2.ImageFeature_IMAGE_FEATURE_MACHINE},
2929
},
30-
wantErr: true,
31-
wantErrorMessage: `validation error:
32-
- url: given uri must be valid [string.uri]`,
30+
wantErr: true,
31+
wantErrorMessage: `validation error: url: given uri must be valid`,
3332
},
3433
{
3534
name: "Invalid Image, no features",
@@ -38,9 +37,8 @@ func TestValidateImage(t *testing.T) {
3837
Url: "http://download.org/debian:12.0",
3938
Features: []apiv2.ImageFeature{3},
4039
},
41-
wantErr: true,
42-
wantErrorMessage: `validation error:
43-
- features[0]: value must be one of the defined enum values [enum.defined_only]`,
40+
wantErr: true,
41+
wantErrorMessage: `validation error: features[0]: value must be one of the defined enum values`,
4442
},
4543
{
4644
name: "Valid ImageUpdate minimal config",
@@ -62,9 +60,8 @@ func TestValidateImage(t *testing.T) {
6260
Features: []apiv2.ImageFeature{apiv2.ImageFeature_IMAGE_FEATURE_MACHINE, apiv2.ImageFeature_IMAGE_FEATURE_MACHINE},
6361
Classification: apiv2.ImageClassification_IMAGE_CLASSIFICATION_PREVIEW,
6462
},
65-
wantErr: true,
66-
wantErrorMessage: `validation error:
67-
- features: repeated value must contain unique items [repeated.unique]`,
63+
wantErr: true,
64+
wantErrorMessage: `validation error: features: repeated value must contain unique items`,
6865
},
6966
{
7067
name: "InValid ImageUpdate invalid Features",
@@ -75,9 +72,8 @@ func TestValidateImage(t *testing.T) {
7572
Features: []apiv2.ImageFeature{apiv2.ImageFeature_IMAGE_FEATURE_MACHINE, 3},
7673
Classification: apiv2.ImageClassification_IMAGE_CLASSIFICATION_PREVIEW,
7774
},
78-
wantErr: true,
79-
wantErrorMessage: `validation error:
80-
- features[1]: value must be one of the defined enum values [enum.defined_only]`,
75+
wantErr: true,
76+
wantErrorMessage: `validation error: features[1]: value must be one of the defined enum values`,
8177
},
8278
}
8379

0 commit comments

Comments
 (0)