From 68e032b8dc5ce9c610fe4bacf401f6ddfd3a9996 Mon Sep 17 00:00:00 2001 From: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Date: Fri, 22 Dec 2023 23:16:18 +0300 Subject: [PATCH 1/9] Added protocol in port configuration --- docs/docs/20-usage/60-services.md | 13 ++++++++ pipeline/backend/kubernetes/service.go | 20 +++++++---- pipeline/backend/kubernetes/service_test.go | 10 ++++-- pipeline/backend/types/network.go | 5 +++ pipeline/backend/types/step.go | 2 +- pipeline/frontend/yaml/compiler/convert.go | 33 +++++++++++++++++-- .../frontend/yaml/linter/schema/schema.json | 9 +---- pipeline/frontend/yaml/types/container.go | 2 +- .../frontend/yaml/types/container_test.go | 4 ++- 9 files changed, 76 insertions(+), 22 deletions(-) diff --git a/docs/docs/20-usage/60-services.md b/docs/docs/20-usage/60-services.md index f2f157e075..64457fbfce 100644 --- a/docs/docs/20-usage/60-services.md +++ b/docs/docs/20-usage/60-services.md @@ -22,6 +22,19 @@ services: image: redis ``` +You can define a port and a protocol explicitly: +```yamlservices: + database: + image: mysql + ports: + - 3306 + + wireguard: + image: wg + ports: + - 51820/udp +``` + ## Configuration Service containers generally expose environment variables to customize service startup such as default usernames, passwords and ports. Please see the official image documentation to learn more. diff --git a/pipeline/backend/kubernetes/service.go b/pipeline/backend/kubernetes/service.go index 2fa66a462b..42b49fd5b0 100644 --- a/pipeline/backend/kubernetes/service.go +++ b/pipeline/backend/kubernetes/service.go @@ -17,6 +17,7 @@ package kubernetes import ( "context" "fmt" + "strings" "github.com/rs/zerolog/log" "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" @@ -26,16 +27,12 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" ) -func mkService(namespace, name string, ports []uint16, selector map[string]string) (*v1.Service, error) { +func mkService(namespace, name string, ports []types.Port, selector map[string]string) (*v1.Service, error) { log.Trace().Str("name", name).Interface("selector", selector).Interface("ports", ports).Msg("Creating service") var svcPorts []v1.ServicePort for _, port := range ports { - svcPorts = append(svcPorts, v1.ServicePort{ - Name: fmt.Sprintf("port-%d", port), - Port: int32(port), - TargetPort: intstr.IntOrString{IntVal: int32(port)}, - }) + svcPorts = append(svcPorts, servicePort(port)) } return &v1.Service{ @@ -55,6 +52,17 @@ func serviceName(step *types.Step) (string, error) { return dnsName(step.Name) } +func servicePort(port types.Port) v1.ServicePort { + portNumber := int32(port.Number) + portProtocol := strings.ToUpper(port.Protocol) + return v1.ServicePort{ + Name: fmt.Sprintf("port-%d", portNumber), + Port: portNumber, + Protocol: v1.Protocol(portProtocol), + TargetPort: intstr.IntOrString{IntVal: portNumber}, + } +} + func startService(ctx context.Context, engine *kube, step *types.Step) (*v1.Service, error) { name, err := serviceName(step) if err != nil { diff --git a/pipeline/backend/kubernetes/service_test.go b/pipeline/backend/kubernetes/service_test.go index 5dc06509ff..b1a9b00f91 100644 --- a/pipeline/backend/kubernetes/service_test.go +++ b/pipeline/backend/kubernetes/service_test.go @@ -52,11 +52,13 @@ func TestService(t *testing.T) { }, { "name": "port-2", + "protocol": "TCP", "port": 2, "targetPort": 2 }, { "name": "port-3", + "protocol": "UDP", "port": 3, "targetPort": 3 } @@ -70,8 +72,12 @@ func TestService(t *testing.T) { "loadBalancer": {} } }` - - s, _ := mkService("foo", "bar", []uint16{1, 2, 3}, map[string]string{"step": "baz"}) + ports := []types.Port{ + {Number: 1}, + {Number: 2, Protocol: "tcp"}, + {Number: 3, Protocol: "udp"}, + } + s, _ := mkService("foo", "bar", ports, map[string]string{"step": "baz"}) j, err := json.Marshal(s) assert.NoError(t, err) assert.JSONEq(t, expected, string(j)) diff --git a/pipeline/backend/types/network.go b/pipeline/backend/types/network.go index 8aa027ae4b..fd73455586 100644 --- a/pipeline/backend/types/network.go +++ b/pipeline/backend/types/network.go @@ -18,3 +18,8 @@ package types type Network struct { Name string `json:"name,omitempty"` } + +type Port struct { + Number uint16 `json:"number,omitempty"` + Protocol string `json:"protocol,omitempty"` +} diff --git a/pipeline/backend/types/step.go b/pipeline/backend/types/step.go index 71bd5a66db..4e215bcbfa 100644 --- a/pipeline/backend/types/step.go +++ b/pipeline/backend/types/step.go @@ -48,7 +48,7 @@ type Step struct { NetworkMode string `json:"network_mode,omitempty"` IpcMode string `json:"ipc_mode,omitempty"` Sysctls map[string]string `json:"sysctls,omitempty"` - Ports []uint16 `json:"ports,omitempty"` + Ports []Port `json:"ports,omitempty"` BackendOptions BackendOptions `json:"backend_options,omitempty"` } diff --git a/pipeline/frontend/yaml/compiler/convert.go b/pipeline/frontend/yaml/compiler/convert.go index 07b1eec2b2..80bde88d98 100644 --- a/pipeline/frontend/yaml/compiler/convert.go +++ b/pipeline/frontend/yaml/compiler/convert.go @@ -18,6 +18,7 @@ import ( "fmt" "maps" "path" + "strconv" "strings" "github.com/oklog/ulid/v2" @@ -146,9 +147,13 @@ func (c *Compiler) createProcess(name string, container *yaml_types.Container, s cpuSet = c.reslimit.CPUSet } - var ports []uint16 - for _, port := range container.Ports { - ports = append(ports, uint16(port)) + var ports []backend_types.Port + for _, portDef := range container.Ports { + port, err := convertPort(portDef) + if err != nil { + return nil, err + } + ports = append(ports, port) } // at least one constraint contain status success, or all constraints have no status set @@ -205,6 +210,28 @@ func (c *Compiler) stepWorkdir(container *yaml_types.Container) string { return path.Join(c.base, c.path, container.Directory) } +func convertPort(portDef string) (backend_types.Port, error) { + var err error + var port backend_types.Port + + portArr := strings.Split(portDef, "/") + + portNumber, err := strconv.ParseUint(portArr[0], 10, 16) + if err != nil { + return port, err + } + + var proto string + if len(portArr) > 1 { + proto = portArr[1] + } + + port.Number = uint16(portNumber) + port.Protocol = proto + + return port, nil +} + func convertKubernetesBackendOptions(kubeOpt *yaml_types.KubernetesBackendOptions) backend_types.KubernetesBackendOptions { resources := backend_types.Resources{ Limits: kubeOpt.Resources.Limits, diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 2cb6388c53..80c371fd40 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -771,14 +771,7 @@ "description": "expose ports to which other steps can connect to", "type": "array", "items": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] + "type": "string" }, "minLength": 1 } diff --git a/pipeline/frontend/yaml/types/container.go b/pipeline/frontend/yaml/types/container.go index b50d3efcba..23a729095c 100644 --- a/pipeline/frontend/yaml/types/container.go +++ b/pipeline/frontend/yaml/types/container.go @@ -47,7 +47,7 @@ type ( Settings map[string]any `yaml:"settings"` Volumes Volumes `yaml:"volumes,omitempty"` When constraint.When `yaml:"when,omitempty"` - Ports []base.StringOrInt `yaml:"ports,omitempty"` + Ports []string `yaml:"ports,omitempty"` // Docker Specific Privileged bool `yaml:"privileged,omitempty"` diff --git a/pipeline/frontend/yaml/types/container_test.go b/pipeline/frontend/yaml/types/container_test.go index 429e5dbe64..b789aea4fe 100644 --- a/pipeline/frontend/yaml/types/container_test.go +++ b/pipeline/frontend/yaml/types/container_test.go @@ -70,6 +70,8 @@ settings: baz: false ports: - 8080 + - 4443/tcp + - 51820/udp `) func TestUnmarshalContainer(t *testing.T) { @@ -128,7 +130,7 @@ func TestUnmarshalContainer(t *testing.T) { "foo": "bar", "baz": false, }, - Ports: []base.StringOrInt{8080}, + Ports: []string{"8080", "4443/tcp", "51820/udp"}, } got := Container{} err := yaml.Unmarshal(containerYaml, &got) From 4253bf5d6937c0267f243366b05f2725c1021072 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 22 Dec 2023 20:20:30 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks [CI SKIP] for more information, see https://pre-commit.ci --- docs/docs/20-usage/60-services.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/20-usage/60-services.md b/docs/docs/20-usage/60-services.md index 64457fbfce..9c03470104 100644 --- a/docs/docs/20-usage/60-services.md +++ b/docs/docs/20-usage/60-services.md @@ -23,6 +23,7 @@ services: ``` You can define a port and a protocol explicitly: + ```yamlservices: database: image: mysql From 51fafcbd68e00822c0075f1217d024b97d44743c Mon Sep 17 00:00:00 2001 From: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:46:29 +0300 Subject: [PATCH 3/9] Fixed PR notes --- pipeline/backend/kubernetes/service_test.go | 4 ++-- pipeline/frontend/yaml/linter/schema/schema.json | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pipeline/backend/kubernetes/service_test.go b/pipeline/backend/kubernetes/service_test.go index b1a9b00f91..c4076b277c 100644 --- a/pipeline/backend/kubernetes/service_test.go +++ b/pipeline/backend/kubernetes/service_test.go @@ -52,13 +52,13 @@ func TestService(t *testing.T) { }, { "name": "port-2", - "protocol": "TCP", + "protocol": "TCP", "port": 2, "targetPort": 2 }, { "name": "port-3", - "protocol": "UDP", + "protocol": "UDP", "port": 3, "targetPort": 3 } diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 80c371fd40..2cb6388c53 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -771,7 +771,14 @@ "description": "expose ports to which other steps can connect to", "type": "array", "items": { - "type": "string" + "oneOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ] }, "minLength": 1 } From 92727416e73eb12e4d127f094b50471d796fc3ce Mon Sep 17 00:00:00 2001 From: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Date: Sun, 24 Dec 2023 19:59:43 +0300 Subject: [PATCH 4/9] Using strings.Cut() --- pipeline/frontend/yaml/compiler/convert.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pipeline/frontend/yaml/compiler/convert.go b/pipeline/frontend/yaml/compiler/convert.go index 392c20066a..9463110fc3 100644 --- a/pipeline/frontend/yaml/compiler/convert.go +++ b/pipeline/frontend/yaml/compiler/convert.go @@ -224,20 +224,14 @@ func convertPort(portDef string) (backend_types.Port, error) { var err error var port backend_types.Port - portArr := strings.Split(portDef, "/") + number, protocol, _ := strings.Cut(portDef, "/") + port.Protocol = protocol - portNumber, err := strconv.ParseUint(portArr[0], 10, 16) + portNumber, err := strconv.ParseUint(number, 10, 16) if err != nil { return port, err } - - var proto string - if len(portArr) > 1 { - proto = portArr[1] - } - port.Number = uint16(portNumber) - port.Protocol = proto return port, nil } From 3841fdd6c8e57463db5e0fa765b841a8e94d2b64 Mon Sep 17 00:00:00 2001 From: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Date: Sun, 24 Dec 2023 20:00:30 +0300 Subject: [PATCH 5/9] Setting ports in Pod --- pipeline/backend/kubernetes/pod.go | 26 +++++++++++++++++++++---- pipeline/backend/kubernetes/pod_test.go | 23 ++++++++++++++++++++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/pipeline/backend/kubernetes/pod.go b/pipeline/backend/kubernetes/pod.go index d0adb5cc36..c8b0ff8f6b 100644 --- a/pipeline/backend/kubernetes/pod.go +++ b/pipeline/backend/kubernetes/pod.go @@ -38,7 +38,7 @@ func mkPod(namespace, name, image, workDir, goos, serviceAccountName string, pool, privileged bool, commands, vols []string, labels, annotations, env, nodeSelector map[string]string, - extraHosts []types.HostAlias, tolerations []types.Toleration, resources types.Resources, + ports []types.Port, extraHosts []types.HostAlias, tolerations []types.Toleration, resources types.Resources, securityContext *types.SecurityContext, securityContextConfig SecurityContextConfig, ) (*v1.Pod, error) { var err error @@ -51,7 +51,7 @@ func mkPod(namespace, name, image, workDir, goos, serviceAccountName string, } container, err := podContainer(name, image, workDir, goos, pool, privileged, commands, vols, env, - resources, securityContext) + ports, resources, securityContext) if err != nil { return nil, err } @@ -108,7 +108,8 @@ func podSpec(serviceAccountName string, vols []string, env, backendNodeSelector return spec, nil } -func podContainer(name, image, workDir, goos string, pull, privileged bool, commands, volumes []string, env map[string]string, resources types.Resources, +func podContainer(name, image, workDir, goos string, pull, privileged bool, commands, volumes []string, env map[string]string, + ports []types.Port, resources types.Resources, securityContext *types.SecurityContext, ) (v1.Container, error) { var err error @@ -130,6 +131,7 @@ func podContainer(name, image, workDir, goos string, pull, privileged bool, comm } container.Env = mapToEnvVars(env) + container.Ports = containerPorts(ports) container.SecurityContext = containerSecurityContext(securityContext, privileged) container.Resources, err = resourceRequirements(resources) @@ -194,6 +196,21 @@ func volumeMount(name, path string) v1.VolumeMount { } } +func containerPorts(ports []types.Port) []v1.ContainerPort { + containerPorts := make([]v1.ContainerPort, len(ports)) + for i, port := range ports { + containerPorts[i] = containerPort(port) + } + return containerPorts +} + +func containerPort(port types.Port) v1.ContainerPort { + return v1.ContainerPort{ + ContainerPort: int32(port.Number), + Protocol: v1.Protocol(strings.ToUpper(port.Protocol)), + } +} + // Here is the service IPs (placed in /etc/hosts in the Pod) func hostAliases(extraHosts []types.HostAlias) []v1.HostAlias { hostAliases := []v1.HostAlias{} @@ -359,7 +376,8 @@ func startPod(ctx context.Context, engine *kube, step *types.Step) (*v1.Pod, err step.Pull, step.Privileged, step.Commands, step.Volumes, engine.config.PodLabels, engine.config.PodAnnotations, step.Environment, step.BackendOptions.Kubernetes.NodeSelector, - step.ExtraHosts, step.BackendOptions.Kubernetes.Tolerations, step.BackendOptions.Kubernetes.Resources, step.BackendOptions.Kubernetes.SecurityContext, engine.config.SecurityContext) + step.Ports, step.ExtraHosts, step.BackendOptions.Kubernetes.Tolerations, step.BackendOptions.Kubernetes.Resources, + step.BackendOptions.Kubernetes.SecurityContext, engine.config.SecurityContext) if err != nil { return nil, err } diff --git a/pipeline/backend/kubernetes/pod_test.go b/pipeline/backend/kubernetes/pod_test.go index b05b2451e4..16a7e01fe5 100644 --- a/pipeline/backend/kubernetes/pod_test.go +++ b/pipeline/backend/kubernetes/pod_test.go @@ -110,7 +110,7 @@ func TestTinyPod(t *testing.T) { false, false, []string{"gradle build"}, []string{"workspace:/woodpecker/src"}, nil, nil, map[string]string{"CI": "woodpecker"}, nil, - nil, nil, + nil, nil, nil, types.Resources{Requests: nil, Limits: nil}, nil, SecurityContextConfig{}, ) assert.NoError(t, err) @@ -158,6 +158,19 @@ func TestFullPod(t *testing.T) { "echo $CI_SCRIPT | base64 -d | /bin/sh -e" ], "workingDir": "/woodpecker/src", + "ports": [ + { + "containerPort": 1234 + }, + { + "containerPort": 2345, + "protocol": "TCP" + }, + { + "containerPort": 3456, + "protocol": "UDP" + } + ], "env": [ "<>", { @@ -244,11 +257,16 @@ func TestFullPod(t *testing.T) { {Name: "cloudflare", IP: "1.1.1.1"}, {Name: "cf.v6", IP: "2606:4700:4700::64"}, } + ports := []types.Port{ + {Number: 1234}, + {Number: 2345, Protocol: "tcp"}, + {Number: 3456, Protocol: "udp"}, + } pod, err := mkPod("woodpecker", "wp-01he8bebctabr3kgk0qj36d2me-0", "meltwater/drone-cache", "/woodpecker/src", "linux/amd64", "wp-svc-acc", true, true, []string{"go get", "go test"}, []string{"woodpecker-cache:/woodpecker/src/cache"}, map[string]string{"app": "test"}, map[string]string{"apparmor.security": "runtime/default"}, map[string]string{"CGO": "0"}, map[string]string{"storage": "ssd"}, - hostAliases, []types.Toleration{{Key: "net-port", Value: "100Mbit", Effect: types.TaintEffectNoSchedule}}, + ports, hostAliases, []types.Toleration{{Key: "net-port", Value: "100Mbit", Effect: types.TaintEffectNoSchedule}}, types.Resources{Requests: map[string]string{"memory": "128Mi", "cpu": "1000m"}, Limits: map[string]string{"memory": "256Mi", "cpu": "2"}}, &types.SecurityContext{Privileged: newBool(true), RunAsNonRoot: newBool(true), RunAsUser: newInt64(101), RunAsGroup: newInt64(101), FSGroup: newInt64(101)}, SecurityContextConfig{RunAsNonRoot: false}, @@ -257,6 +275,7 @@ func TestFullPod(t *testing.T) { json, err := json.Marshal(pod) assert.NoError(t, err) + t.Log(string(json)) ja := jsonassert.New(t) ja.Assertf(string(json), expected) From 7c47f2a3bc879ab6a895afe08364e45e2d9c9b53 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 9 Jan 2024 19:59:13 +0100 Subject: [PATCH 6/9] Update pipeline/backend/kubernetes/pod_test.go --- pipeline/backend/kubernetes/pod_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pipeline/backend/kubernetes/pod_test.go b/pipeline/backend/kubernetes/pod_test.go index 4f0ea7b80f..bec5fe478a 100644 --- a/pipeline/backend/kubernetes/pod_test.go +++ b/pipeline/backend/kubernetes/pod_test.go @@ -273,7 +273,6 @@ func TestFullPod(t *testing.T) { json, err := json.Marshal(pod) assert.NoError(t, err) - t.Log(string(json)) ja := jsonassert.New(t) ja.Assertf(string(json), expected) From 6dfa52f08c436f737ea9bfaba8c0b5645495a393 Mon Sep 17 00:00:00 2001 From: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Date: Fri, 12 Jan 2024 16:37:59 +0300 Subject: [PATCH 7/9] Added tests --- pipeline/backend/docker/convert_test.go | 2 +- .../frontend/yaml/compiler/convert_test.go | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 pipeline/frontend/yaml/compiler/convert_test.go diff --git a/pipeline/backend/docker/convert_test.go b/pipeline/backend/docker/convert_test.go index a6e77fdd04..6c97bcf2e6 100644 --- a/pipeline/backend/docker/convert_test.go +++ b/pipeline/backend/docker/convert_test.go @@ -155,7 +155,7 @@ func TestToConfigFull(t *testing.T) { Failure: "fail", AuthConfig: backend.Auth{Username: "user", Password: "123456", Email: "user@example.com"}, NetworkMode: "bridge", - Ports: []uint16{21, 22}, + Ports: []backend.Port{{Number: 21}, {Number: 22}}, }) assert.NotNil(t, conf) diff --git a/pipeline/frontend/yaml/compiler/convert_test.go b/pipeline/frontend/yaml/compiler/convert_test.go new file mode 100644 index 0000000000..89c40cbef9 --- /dev/null +++ b/pipeline/frontend/yaml/compiler/convert_test.go @@ -0,0 +1,59 @@ +// Copyright 2024 Woodpecker Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compiler + +import ( + "github.com/stretchr/testify/assert" + backend_types "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" + "testing" +) + +func TestConvertPortNumber(t *testing.T) { + portDef := "1234" + actualPort, err := convertPort(portDef) + assert.NoError(t, err) + assert.Equal(t, backend_types.Port{ + Number: 1234, + Protocol: "", + }, actualPort) +} + +func TestConvertPortUdp(t *testing.T) { + portDef := "1234/udp" + actualPort, err := convertPort(portDef) + assert.NoError(t, err) + assert.Equal(t, backend_types.Port{ + Number: 1234, + Protocol: "udp", + }, actualPort) +} + +func TestConvertPortWrongOrder(t *testing.T) { + portDef := "tcp/1234" + _, err := convertPort(portDef) + assert.Error(t, err) +} + +func TestConvertPortWrongDelimiter(t *testing.T) { + portDef := "1234|udp" + _, err := convertPort(portDef) + assert.Error(t, err) +} + +func TestConvertPortWrong(t *testing.T) { + portDef := "http" + _, err := convertPort(portDef) + assert.Error(t, err) +} From 51341f367dc124687f5e975f503a555d6719efe7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 12 Jan 2024 16:02:30 +0100 Subject: [PATCH 8/9] Apply suggestions from code review --- pipeline/backend/kubernetes/pod_test.go | 1 - pipeline/backend/kubernetes/service_test.go | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/backend/kubernetes/pod_test.go b/pipeline/backend/kubernetes/pod_test.go index f0b101feaa..f1d30802ea 100644 --- a/pipeline/backend/kubernetes/pod_test.go +++ b/pipeline/backend/kubernetes/pod_test.go @@ -322,7 +322,6 @@ func TestFullPod(t *testing.T) { json, err := json.Marshal(pod) assert.NoError(t, err) - t.Log(string(json)) ja := jsonassert.New(t) ja.Assertf(string(json), expected) diff --git a/pipeline/backend/kubernetes/service_test.go b/pipeline/backend/kubernetes/service_test.go index f6bc09f8fb..fb7431b7e2 100644 --- a/pipeline/backend/kubernetes/service_test.go +++ b/pipeline/backend/kubernetes/service_test.go @@ -82,6 +82,7 @@ func TestService(t *testing.T) { Name: "bar", Ports: ports, }, "foo") + assert.NoError(t, err) j, err := json.Marshal(s) assert.NoError(t, err) assert.JSONEq(t, expected, string(j)) From e95d4aaaa25b92d8999deb140b5edfb6590f1b89 Mon Sep 17 00:00:00 2001 From: Thomas Anderson <127358482+zc-devs@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:24:38 +0300 Subject: [PATCH 9/9] gofumpt -extra -w --- pipeline/frontend/yaml/compiler/convert_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipeline/frontend/yaml/compiler/convert_test.go b/pipeline/frontend/yaml/compiler/convert_test.go index 89c40cbef9..3103f35885 100644 --- a/pipeline/frontend/yaml/compiler/convert_test.go +++ b/pipeline/frontend/yaml/compiler/convert_test.go @@ -15,9 +15,10 @@ package compiler import ( + "testing" + "github.com/stretchr/testify/assert" backend_types "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" - "testing" ) func TestConvertPortNumber(t *testing.T) {