Skip to content

Commit

Permalink
Fix where the new go module needed by echo-basic resides, but keep th…
Browse files Browse the repository at this point in the history
  • Loading branch information
candita committed Aug 19, 2024
1 parent 6d9ab9e commit b774245
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 43 deletions.
65 changes: 32 additions & 33 deletions conformance/base/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,9 @@ spec:
selector:
app: backendtlspolicy-test
ports:
- protocol: TCP
port: 443
targetPort: 8443
- protocol: TCP
port: 443
targetPort: 8443
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -762,34 +762,33 @@ spec:
app: backendtlspolicy-test
spec:
containers:
- name: backendtlspolicy-test
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
volumeMounts:
- name: secret-volume
mountPath: /etc/secret-volume
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CA_CERT
value: /etc/secret-volume/crt
- name: CA_CERT_KEY
value: /etc/secret-volume/key
resources:
requests:
cpu: 10m
volumes:
- name: backendtlspolicy-test
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
volumeMounts:
- name: secret-volume
secret:
secretName: backend-tls-checks-certificate
items:
- key: tls.crt
path: crt
- key: tls.key
path: key
---
mountPath: /etc/secret-volume
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CA_CERT
value: /etc/secret-volume/crt
- name: CA_CERT_KEY
value: /etc/secret-volume/key
resources:
requests:
cpu: 10m
volumes:
- name: secret-volume
secret:
secretName: backend-tls-checks-certificate
items:
- key: tls.crt
path: crt
- key: tls.key
path: key
1 change: 1 addition & 0 deletions conformance/echo-basic/.go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module sigs.k8s.io/gateway-api/conformance/echo-basic
go 1.21

require (
github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732
golang.org/x/net v0.21.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.1
Expand Down
2 changes: 2 additions & 0 deletions conformance/echo-basic/.go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732 h1:nkseUkzjazCNyGhkRwnJ1OiHSwMXazsJQx+Ci+oVLEM=
github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732/go.mod h1:J3XXNGJINXLa4yIivdUT0Ad/srv2q0pSOWbbm6El2EY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
Expand Down
9 changes: 6 additions & 3 deletions conformance/echo-basic/echo-basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ func echoHandler(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.RequestURI, "backendTLS") {
sni, err = sniffForSNI(r.RemoteAddr)
if err != nil {
// Todo: research if for some test cases there won't be one
// TODO: research if for some test cases there won't be SNI available.
processError(w, err, http.StatusBadRequest)
return
}
}

Expand Down Expand Up @@ -340,14 +342,15 @@ func sniffForSNI(addr string) (string, error) {
return "", fmt.Errorf("could not read socket: %v", err)
}
// Take an incoming TLS Client Hello and return the SNI name.
sni, err = parser.GetHostname(data[:])
sni, err = parser.GetHostname(data)
if err != nil {
return "", fmt.Errorf("error getting SNI: %v", err)
}
if sni == "" {
return "", fmt.Errorf("no server name indication found")
} else { //nolint:revive
return sni, nil
}
return sni, nil
}
}

Expand Down
8 changes: 4 additions & 4 deletions conformance/tests/backendtlspolicy-normative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ metadata:
namespace: gateway-conformance-infra
spec:
targetRefs:
- group: ""
kind: Service
name: "backendtlspolicy-test"
- group: ""
kind: Service
name: "backendtlspolicy-test"
validation:
caCertificateRefs:
group: ""
kind: Secret
name: "backend-tls-checks-certificate"
hostname: "abc.example.com"
hostname: "abc.example.com"
7 changes: 4 additions & 3 deletions docker/Dockerfile.echo-basic
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ COPY ./conformance/echo-basic ./

# If left as go.mod and go.sum in the external repo, these files would
# interfere with the ability to use reuse the protobuf/gRPC generated code
# for the test client in the conformance tests.
RUN mv .go.mod go.mod
RUN mv .go.sum go.sum
# for the test client in the conformance tests. Add -f in case previous run
# is aborted and not cleaned up.
RUN mv -f .go.mod go.mod
RUN mv -f .go.sum go.sum

RUN go build -trimpath -ldflags="-buildid= -s -w" -o echo-basic .

Expand Down

0 comments on commit b774245

Please sign in to comment.