Skip to content

Commit 75c503b

Browse files
committed
Use Go crossplane
1 parent 13a79ea commit 75c503b

File tree

7 files changed

+102
-13
lines changed

7 files changed

+102
-13
lines changed

tests/Dockerfile.crossplane

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ build-test-runner-image: ## Build conformance test runner image
4141

4242
.PHONY: build-crossplane-image
4343
build-crossplane-image: ## Build the crossplane image
44-
docker build --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR) -t nginx-crossplane:latest -f Dockerfile.crossplane ..
44+
docker build --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR) -t nginx-crossplane:latest -f framework/crossplane/Dockerfile ..
4545

4646
.PHONY: run-conformance-tests
4747
run-conformance-tests: ## Run conformance tests

tests/framework/crossplane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func createCrossplaneExecutor(
178178
ngfPodName,
179179
namespace string,
180180
) (remotecommand.Executor, error) {
181-
cmd := []string{"crossplane", "parse", "/etc/nginx/nginx.conf"}
181+
cmd := []string{"./crossplane", "/etc/nginx/nginx.conf"}
182182
opts := &core.PodExecOptions{
183183
Command: cmd,
184184
Container: "crossplane",

tests/framework/crossplane/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.10
2+
FROM golang:1.23-alpine AS builder
3+
4+
WORKDIR /
5+
ARG DIR=tests/framework/crossplane
6+
7+
COPY ${DIR}/go.mod ${DIR}/go.sum .
8+
RUN go mod download
9+
10+
COPY ${DIR}/cmd/crossplane .
11+
RUN go build -o crossplane
12+
13+
FROM alpine
14+
15+
WORKDIR /crossplane
16+
ARG NGINX_CONF_DIR
17+
18+
COPY ${NGINX_CONF_DIR}/nginx.conf /etc/nginx/nginx.conf
19+
COPY --from=builder /crossplane .
20+
21+
USER 101:1001
22+
23+
ENTRYPOINT ["sh"]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"errors"
6+
"fmt"
7+
"os"
8+
9+
crossplane "github.com/nginxinc/nginx-go-crossplane"
10+
)
11+
12+
// This binary accepts a single argument, the path of the base nginx config, and prints out the JSON representation
13+
// of the full nginx config, in crossplane format.
14+
// See https://github.com/nginxinc/nginx-go-crossplane for more info.
15+
func main() {
16+
if len(os.Args) != 2 {
17+
panic(errors.New("must have exactly one argument, the path of the base nginx config"))
18+
}
19+
20+
path := os.Args[1]
21+
22+
payload, err := crossplane.Parse(path, &crossplane.ParseOptions{})
23+
if err != nil {
24+
panic(err)
25+
}
26+
27+
b, err := json.Marshal(payload)
28+
if err != nil {
29+
panic(err)
30+
}
31+
32+
fmt.Println(string(b))
33+
}

tests/framework/crossplane/go.mod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module github.com/nginxinc/nginx-gateway-fabric/tests/framework/crossplane
2+
3+
go 1.23.1
4+
5+
require github.com/nginxinc/nginx-go-crossplane v0.4.63
6+
7+
require (
8+
github.com/jstemmer/go-junit-report v1.0.0 // indirect
9+
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 // indirect
10+
golang.org/x/mod v0.19.0 // indirect
11+
golang.org/x/sync v0.7.0 // indirect
12+
golang.org/x/text v0.16.0 // indirect
13+
golang.org/x/tools v0.23.0 // indirect
14+
)

tests/framework/crossplane/go.sum

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
4+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5+
github.com/jstemmer/go-junit-report v1.0.0 h1:8X1gzZpR+nVQLAht+L/foqOeX2l9DTZoaIPbEQHxsds=
6+
github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
7+
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 h1:NicmruxkeqHjDv03SfSxqmaLuisddudfP3h5wdXFbhM=
8+
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1/go.mod h1:eyp4DdUJAKkr9tvxR3jWhw2mDK7CWABMG5r9uyaKC7I=
9+
github.com/nginxinc/nginx-go-crossplane v0.4.63 h1:nx5e+EXzPepWVM3YsTEhcs8kp8XDTK1BCzPTTmdgK1E=
10+
github.com/nginxinc/nginx-go-crossplane v0.4.63/go.mod h1:b7L/JSru3rvbbxVJxBgkePkNvC+LXo/IWE4iJJJvUUw=
11+
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
12+
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
13+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
14+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
15+
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
16+
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
17+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
18+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
19+
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
20+
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
21+
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
22+
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
23+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
24+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
25+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
26+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
27+
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
28+
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
29+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
30+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)