Skip to content

Commit 5b694ec

Browse files
committed
Switch from using teams backend to nais api
NAIS-api uses a grpc client for internal communication. This also upgrades the project to Go 1.22 because nais-api requires Go 1.22.
1 parent c74879f commit 5b694ec

18 files changed

+269
-354
lines changed

Dockerfile.canary-deployer

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine as builder
1+
FROM golang:1.22-alpine as builder
22

33
RUN apk add --no-cache git make curl
44
ENV GOOS=linux

Dockerfile.deploy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine as builder
1+
FROM golang:1.22-alpine as builder
22

33
RUN apk add --no-cache git make curl
44
ENV GOOS=linux

Dockerfile.deploy-action

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine as builder
1+
FROM golang:1.22-alpine as builder
22

33
RUN apk add --no-cache git make curl
44
ENV GOOS=linux

Dockerfile.deployd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine as builder
1+
FROM golang:1.22-alpine as builder
22

33
RUN apk add --no-cache git make curl
44
ENV GOOS=linux

Dockerfile.hookd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine as builder
1+
FROM golang:1.22-alpine as builder
22

33
RUN apk add --no-cache git make curl
44
ENV GOOS=linux

charts/hookd/Feature.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- allOf:
3-
- teams-backend
3+
- nais-api
44
environmentKinds:
55
- management
66
values:
@@ -61,13 +61,12 @@ values:
6161
displayName: Ingress URL
6262
computed:
6363
template: '"{{ subdomain . "deploy" }}"'
64-
teamsAPIKey:
65-
displayName: "teams api key"
66-
computed:
67-
template: "{{.Management.hookd_teams_api_key | quote}}"
68-
description: "API key used for teams integration"
6964
frontendPreSharedKey:
7065
displayName: "console-backend pre-shared key"
7166
computed:
7267
template: "{{.Management.hookd_frontend_pre_shared_key | quote}}"
7368
description: "The pre-shared key used to authenticate the console-backend"
69+
naisAPI.insecure:
70+
displayName: Insecure connection to NAIS API
71+
config:
72+
type: bool

charts/hookd/templates/netpol.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ spec:
2525
kubernetes.io/metadata.name: nais-system
2626
podSelector:
2727
matchLabels:
28-
app.kubernetes.io/instance: teams-backend
29-
app.kubernetes.io/name: teams-backend
28+
app: nais-api
3029
podSelector:
3130
matchLabels:
3231
{{- include "hookd.selectorLabels" . | nindent 6 }}

charts/hookd/templates/secret.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ stringData:
2525
HOOKD_LOG_LINK_FORMATTER: "{{ .Values.logLinkFormatter }}"
2626
HOOKD_OAUTH_ENABLED: "true"
2727
HOOKD_PROVISION_KEY: "{{ .Values.provisionKey }}"
28-
HOOKD_TEAMS_API_KEY: "{{ .Values.teamsAPIKey }}"
29-
HOOKD_TEAMS_URL: "{{ .Values.teamsURL }}"
28+
HOOKD_NAIS_API_TARGET: "{{ .Values.naisAPI.target }}"
29+
HOOKD_NAIS_API_INSECURE: "{{ .Values.naisAPI.insecure }}"

charts/hookd/values.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ frontendPreSharedKey: # mapped by fasit
4444

4545
imagePullSecrets: []
4646

47-
teamsAPIKey: # mapped by fasit
48-
teamsURL: "http://teams-backend/query"
47+
naisAPI:
48+
target: "nais-api:3001"
49+
insecure: "false"

cmd/hookd/main.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import (
3131
"github.com/nais/deploy/pkg/hookd/logproxy"
3232
"github.com/nais/deploy/pkg/hookd/middleware"
3333
"github.com/nais/deploy/pkg/logging"
34+
"github.com/nais/deploy/pkg/naisapi"
3435
"github.com/nais/deploy/pkg/pb"
35-
"github.com/nais/deploy/pkg/teams"
3636
"github.com/nais/deploy/pkg/version"
3737
)
3838

@@ -179,8 +179,11 @@ func startGrpcServer(cfg config.Config, db database.DeploymentStore, apikeys dat
179179
return nil, nil, fmt.Errorf("unable to set up github validator: %w", err)
180180
}
181181

182-
teamsClient := teams.New(cfg.TeamsURL, cfg.TeamsAPIKey)
183-
authInterceptor := auth_interceptor.NewServerInterceptor(apikeys, ghValidator, teamsClient)
182+
apiClient, err := naisapi.New(cfg.NaisAPITarget, cfg.NaisAPIInsecure)
183+
if err != nil {
184+
return nil, nil, fmt.Errorf("unable to set up nais-api client: %w", err)
185+
}
186+
authInterceptor := auth_interceptor.NewServerInterceptor(apikeys, ghValidator, apiClient)
184187

185188
interceptor.Add(pb.Deploy_ServiceDesc.ServiceName, authInterceptor)
186189
log.Infof("Authentication enabled for deployment requests")

go.mod

+59-53
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
module github.com/nais/deploy
22

3-
go 1.21
3+
go 1.22
4+
5+
toolchain go1.22.0
46

57
require (
68
github.com/aymerick/raymond v2.0.2+incompatible
79
github.com/ghodss/yaml v1.0.0
810
github.com/go-chi/chi v4.1.2+incompatible
911
github.com/go-chi/render v1.0.3
1012
github.com/golang/protobuf v1.5.3
11-
github.com/google/uuid v1.3.1
13+
github.com/google/uuid v1.6.0
1214
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0
1315
github.com/jackc/pgx/v4 v4.18.1
1416
github.com/lib/pq v1.10.9
15-
github.com/nais/liberator v0.0.0-20230807082713-b3572ceadac6
16-
github.com/prometheus/client_golang v1.16.0
17+
github.com/nais/liberator v0.0.0-20240208114703-a4ddc1dd2ffa
18+
github.com/prometheus/client_golang v1.18.0
1719
github.com/sirupsen/logrus v1.9.3
1820
github.com/spf13/pflag v1.0.5
19-
github.com/spf13/viper v1.16.0
21+
github.com/spf13/viper v1.17.0
2022
github.com/stretchr/testify v1.8.4
21-
golang.org/x/oauth2 v0.14.0 // indirect
22-
google.golang.org/grpc v1.59.0
23-
google.golang.org/protobuf v1.31.0
23+
golang.org/x/oauth2 v0.16.0 // indirect
24+
google.golang.org/grpc v1.61.0
25+
google.golang.org/protobuf v1.32.0
2426
gopkg.in/sakura-internet/go-rison.v3 v3.2.0
2527
gopkg.in/yaml.v2 v2.4.0
26-
k8s.io/api v0.27.4
27-
k8s.io/apimachinery v0.27.4
28-
k8s.io/client-go v0.27.4
29-
sigs.k8s.io/controller-runtime v0.15.0
28+
k8s.io/api v0.29.1
29+
k8s.io/apimachinery v0.29.1
30+
k8s.io/client-go v0.29.1
31+
sigs.k8s.io/controller-runtime v0.17.0
3032
)
3133

3234
require (
3335
github.com/google/go-github/v41 v41.0.0
3436
github.com/lestrrat-go/jwx/v2 v2.0.19
35-
github.com/vektra/mockery/v2 v2.38.0
37+
github.com/nais/api v0.0.0-20240221092250-0f2590f0befc
38+
github.com/vektra/mockery/v2 v2.40.1
3639
golang.org/x/vuln v1.0.1
3740
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
3841
honnef.co/go/tools v0.4.6
@@ -44,21 +47,21 @@ require (
4447
github.com/ajg/form v1.5.1 // indirect
4548
github.com/beorn7/perks v1.0.1 // indirect
4649
github.com/cespare/xxhash/v2 v2.2.0 // indirect
47-
github.com/chigopher/pathlib v0.15.0 // indirect
48-
github.com/davecgh/go-spew v1.1.1 // indirect
50+
github.com/chigopher/pathlib v0.19.1 // indirect
51+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4952
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
50-
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
51-
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
52-
github.com/fsnotify/fsnotify v1.6.0 // indirect
53-
github.com/go-logr/logr v1.2.4 // indirect
54-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
55-
github.com/go-openapi/jsonreference v0.20.2 // indirect
56-
github.com/go-openapi/swag v0.22.3 // indirect
53+
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
54+
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
55+
github.com/fsnotify/fsnotify v1.7.0 // indirect
56+
github.com/go-logr/logr v1.4.1 // indirect
57+
github.com/go-openapi/jsonpointer v0.20.2 // indirect
58+
github.com/go-openapi/jsonreference v0.20.4 // indirect
59+
github.com/go-openapi/swag v0.22.9 // indirect
5760
github.com/goccy/go-json v0.10.2 // indirect
5861
github.com/gogo/protobuf v1.3.2 // indirect
5962
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
60-
github.com/google/gnostic v0.6.9 // indirect
61-
github.com/google/go-cmp v0.5.9 // indirect
63+
github.com/google/gnostic-models v0.6.8 // indirect
64+
github.com/google/go-cmp v0.6.0 // indirect
6265
github.com/google/go-querystring v1.1.0 // indirect
6366
github.com/google/gofuzz v1.2.0 // indirect
6467
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0 // indirect
@@ -72,7 +75,7 @@ require (
7275
github.com/jackc/pgio v1.0.0 // indirect
7376
github.com/jackc/pgpassfile v1.0.0 // indirect
7477
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
75-
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
78+
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
7679
github.com/jackc/pgtype v1.14.0 // indirect
7780
github.com/jackc/puddle v1.3.0 // indirect
7881
github.com/jinzhu/copier v0.4.0 // indirect
@@ -86,8 +89,7 @@ require (
8689
github.com/magiconair/properties v1.8.7 // indirect
8790
github.com/mailru/easyjson v0.7.7 // indirect
8891
github.com/mattn/go-colorable v0.1.13 // indirect
89-
github.com/mattn/go-isatty v0.0.19 // indirect
90-
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
92+
github.com/mattn/go-isatty v0.0.20 // indirect
9193
github.com/mitchellh/go-homedir v1.1.0 // indirect
9294
github.com/mitchellh/hashstructure v1.1.0 // indirect
9395
github.com/mitchellh/mapstructure v1.5.0 // indirect
@@ -96,40 +98,44 @@ require (
9698
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
9799
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
98100
github.com/pkg/errors v0.9.1 // indirect
99-
github.com/pmezard/go-difflib v1.0.0 // indirect
100-
github.com/prometheus/client_model v0.4.0 // indirect
101-
github.com/prometheus/common v0.44.0 // indirect
102-
github.com/prometheus/procfs v0.11.1 // indirect
101+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
102+
github.com/prometheus/client_model v0.5.0 // indirect
103+
github.com/prometheus/common v0.46.0 // indirect
104+
github.com/prometheus/procfs v0.12.0 // indirect
103105
github.com/rs/zerolog v1.30.0 // indirect
106+
github.com/sagikazarmark/locafero v0.3.0 // indirect
107+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
104108
github.com/segmentio/asm v1.2.0 // indirect
105-
github.com/spf13/afero v1.9.5 // indirect
109+
github.com/sourcegraph/conc v0.3.0 // indirect
110+
github.com/spf13/afero v1.10.0 // indirect
106111
github.com/spf13/cast v1.5.1 // indirect
107-
github.com/spf13/cobra v1.7.0 // indirect
108-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
109-
github.com/stretchr/objx v0.5.0 // indirect
112+
github.com/spf13/cobra v1.8.0 // indirect
113+
github.com/stretchr/objx v0.5.1 // indirect
110114
github.com/subosito/gotenv v1.6.0 // indirect
111-
golang.org/x/crypto v0.17.0 // indirect
115+
go.uber.org/multierr v1.11.0 // indirect
116+
golang.org/x/crypto v0.19.0 // indirect
117+
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
112118
golang.org/x/exp/typeparams v0.0.0-20230213192124-5e25df0256eb // indirect
113-
golang.org/x/mod v0.12.0 // indirect
114-
golang.org/x/net v0.18.0 // indirect
115-
golang.org/x/sync v0.3.0 // indirect
116-
golang.org/x/sys v0.15.0 // indirect
117-
golang.org/x/term v0.15.0 // indirect
119+
golang.org/x/mod v0.15.0 // indirect
120+
golang.org/x/net v0.21.0 // indirect
121+
golang.org/x/sync v0.6.0 // indirect
122+
golang.org/x/sys v0.17.0 // indirect
123+
golang.org/x/term v0.17.0 // indirect
118124
golang.org/x/text v0.14.0 // indirect
119-
golang.org/x/time v0.3.0 // indirect
120-
golang.org/x/tools v0.13.0 // indirect
121-
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
122-
google.golang.org/appengine v1.6.7 // indirect
123-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
125+
golang.org/x/time v0.5.0 // indirect
126+
golang.org/x/tools v0.17.0 // indirect
127+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
128+
google.golang.org/appengine v1.6.8 // indirect
129+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
124130
gopkg.in/inf.v0 v0.9.1 // indirect
125131
gopkg.in/ini.v1 v1.67.0 // indirect
126132
gopkg.in/yaml.v3 v3.0.1 // indirect
127-
k8s.io/apiextensions-apiserver v0.27.4 // indirect
128-
k8s.io/component-base v0.27.4 // indirect
129-
k8s.io/klog/v2 v2.100.1 // indirect
130-
k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect
131-
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
133+
k8s.io/apiextensions-apiserver v0.29.1 // indirect
134+
k8s.io/component-base v0.29.1 // indirect
135+
k8s.io/klog/v2 v2.120.1 // indirect
136+
k8s.io/kube-openapi v0.0.0-20240126223410-2919ad4fcfec // indirect
137+
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
132138
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
133-
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
134-
sigs.k8s.io/yaml v1.3.0 // indirect
139+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
140+
sigs.k8s.io/yaml v1.4.0 // indirect
135141
)

0 commit comments

Comments
 (0)