Skip to content

Commit

Permalink
Merge branch 'main' into feat/default-lookup-services-consumerGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineJac authored Sep 9, 2024
2 parents e72a9f9 + ea0983e commit 2160b42
Show file tree
Hide file tree
Showing 19 changed files with 167 additions and 268 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/integration-enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ jobs:
strategy:
matrix:
kong_image:
- 'kong/kong-gateway:1.5.0.11'
- 'kong/kong-gateway:2.1.4.6'
- 'kong/kong-gateway:2.2.1.3'
- 'kong/kong-gateway:2.3.3.4'
- 'kong/kong-gateway:2.4.1.3'
- 'kong/kong-gateway:2.5.1.2'
- 'kong/kong-gateway:2.6.0.2'
- 'kong/kong-gateway:2.7'
- 'kong/kong-gateway:2.8'
- 'kong/kong-gateway:3.0'
- 'kong/kong-gateway:3.1'
- 'kong/kong-gateway:3.2'
- 'kong/kong-gateway:3.3'
- 'kong/kong-gateway:3.4'
- 'kong/kong-gateway:3.5'
- 'kong/kong-gateway:3.6'
- 'kong/kong-gateway:3.7'
- 'kong/kong-gateway-dev:latest'
env:
KONG_ANONYMOUS_REPORTS: "off"
Expand All @@ -55,7 +44,6 @@ jobs:
- uses: Kong/kong-license@master
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
op-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
- name: Setup Kong
env:
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,11 @@ jobs:
strategy:
matrix:
kong_image:
- 'kong:1.4.3'
- 'kong:1.5.1'
- 'kong:2.0.5'
- 'kong:2.1.4'
- 'kong:2.2.2'
- 'kong:2.3.3'
- 'kong:2.4.1'
- 'kong:2.5.1'
- 'kong:2.6.0'
- 'kong:2.7'
- 'kong:2.8'
- 'kong:3.0'
- 'kong:3.1'
- 'kong:3.2'
- 'kong:3.3'
- 'kong:3.4'
- 'kong:3.5'
- 'kong:3.6'
- 'kong:3.7'
- 'kong/kong:master'
env:
KONG_ANONYMOUS_REPORTS: "off"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ jobs:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT) }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Setup golangci-lint
uses: golangci/[email protected]
- name: Run tests with Coverage
run: make coverage
- name: Upload Code Coverage
Expand All @@ -33,5 +29,24 @@ jobs:
name: codecov-deck
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

lint:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: golangci/[email protected]

build:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: make build
1 change: 0 additions & 1 deletion .github/workflows/validate-kong-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
- uses: Kong/kong-license@master
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
op-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
- name: Setup Kong
env:
Expand Down
6 changes: 4 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ linters:
- dogsled
- durationcheck
- exhaustive
- exportloopref
- copyloopvar
- gci
- goconst
- gofmt
Expand All @@ -19,7 +19,9 @@ linters:
- govet
- importas
- lll
- megacheck
- gosimple
- staticcheck
- unused
- misspell
- nakedret
- nilerr
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Table of Contents

- [v1.39.6](#v1396)
- [v1.39.5](#v1395)
- [v1.39.4](#v1394)
- [v1.39.3](#v1393)
- [v1.39.2](#v1392)
Expand Down Expand Up @@ -90,6 +92,21 @@
- [v0.2.0](#v020)
- [v0.1.0](#v010)

## [v1.39.6]
> Release date: 2024/08/22
### Fixes

- Fixed the issue where plugins scoped to consumer-groups were shown as global by deck. [#1380](https://github.com/Kong/deck/pull/1380)
[go-database-reconciler #134](https://github.com/Kong/go-database-reconciler/pull/134)

## [v1.39.5]
> Release date: 2024/08/22
### Fixes

- Fixed `deck file openapi2kong` command where parameter schema wasn't getting generated properly. [#1355](https://github.com/Kong/deck/pull/1355) [go-apiops #186](https://github.com/Kong/go-apiops/pull/186)

## [v1.39.4]
> Release date: 2024/08/01
Expand Down Expand Up @@ -1757,6 +1774,8 @@ No breaking changes have been introduced in this release.

Debut release of decK

[v1.39.6]: https://github.com/Kong/deck/compare/v1.39.5...v1.39.6
[v1.39.5]: https://github.com/Kong/deck/compare/v1.39.4...v1.39.5
[v1.39.4]: https://github.com/Kong/deck/compare/v1.39.3...v1.39.4
[v1.39.3]: https://github.com/Kong/deck/compare/v1.39.2...v1.39.3
[v1.39.2]: https://github.com/kong/deck/compare/v1.39.1...v1.39.2
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.4 AS build
FROM golang:1.23.0 AS build
WORKDIR /deck
COPY go.mod ./
COPY go.sum ./
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ the GitHub [release page](https://github.com/kong/deck/releases)
or install by downloading the binary:

```shell
$ curl -sL https://github.com/kong/deck/releases/download/v1.39.4/deck_1.39.4_linux_amd64.tar.gz -o deck.tar.gz
$ curl -sL https://github.com/kong/deck/releases/download/v1.39.6/deck_1.39.6_linux_amd64.tar.gz -o deck.tar.gz
$ tar -xf deck.tar.gz -C /tmp
$ sudo cp /tmp/deck /usr/local/bin/
```
Expand All @@ -84,7 +84,7 @@ If you are on Windows, you can download the binary from the GitHub
[release page](https://github.com/kong/deck/releases) or via PowerShell:

```shell
$ curl -sL https://github.com/kong/deck/releases/download/v1.39.4/deck_1.39.4_windows_amd64.tar.gz -o deck.tar.gz
$ curl -sL https://github.com/kong/deck/releases/download/v1.39.6/deck_1.39.6_windows_amd64.tar.gz -o deck.tar.gz
$ tar -xzvf deck.tar.gz
```

Expand Down
8 changes: 4 additions & 4 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,11 @@ func checkForRBACResources(content reconcilerUtils.KongRawState,
common := "At a time, state file(s) must entirely consist of either proxy " +
"configuration or RBAC configuration."
if rbacResourcesOnly {
return fmt.Errorf("When --rbac-resources-only is used, state file(s) " +
"cannot contain any resources other than RBAC resources. " + common)
return fmt.Errorf("when --rbac-resources-only is used, state file(s) "+
"cannot contain any resources other than RBAC resources. %s", common)
}
return fmt.Errorf("State file(s) contains RBAC resources. " +
"Please use --rbac-resources-only flag to manage these resources. " + common)
return fmt.Errorf("state file(s) contains RBAC resources. "+
"Please use --rbac-resources-only flag to manage these resources. %s", common)
}
return nil
}
Expand Down
29 changes: 27 additions & 2 deletions cmd/common_konnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strings"
"time"

"github.com/kong/go-database-reconciler/pkg/diff"
"github.com/kong/go-database-reconciler/pkg/dump"
Expand All @@ -16,12 +17,36 @@ import (
"golang.org/x/sync/errgroup"
)

const defaultControlPlaneName = "default"
const (
defaultControlPlaneName = "default"
maxRetriesForAuth = 5
apiRateLimitExceededErrorString = "API rate limit exceeded"
)

func authenticate(
ctx context.Context, client *konnect.Client, konnectConfig utils.KonnectConfig,
) (konnect.AuthResponse, error) {
return client.Auth.LoginV2(ctx, konnectConfig.Email, konnectConfig.Password, konnectConfig.Token)
attempts := 0
backoff := 200 * time.Millisecond

for {
authResponse, err := client.Auth.LoginV2(ctx, konnectConfig.Email, konnectConfig.Password, konnectConfig.Token)
if err == nil {
return authResponse, nil
}

if !strings.Contains(err.Error(), apiRateLimitExceededErrorString) {
return authResponse, err
}

attempts++
if attempts > maxRetriesForAuth {
return authResponse, fmt.Errorf("maximum retries (%d) exceeded for authentication", maxRetriesForAuth)
}

time.Sleep(backoff)
backoff *= 2
}
}

// GetKongClientForKonnectMode abstracts the different cloud environments users
Expand Down
3 changes: 1 addition & 2 deletions convert/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,8 @@ func Test_Convert(t *testing.T) {

func wipeServiceID(content *file.Content) *file.Content {
result := content.DeepCopy()
result.ServicePackages = nil
result.ServicePackages = make([]file.FServicePackage, 0, len(content.ServicePackages))
for _, sp := range content.ServicePackages {
sp := sp
sp = zeroOutID(sp)
result.ServicePackages = append(result.ServicePackages, sp)
}
Expand Down
6 changes: 3 additions & 3 deletions kong2kic/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func populateKICIngressesWithAnnotations(content *file.Content, kicContent *KICC
Service: &k8snetv1.IngressServiceBackend{
Name: *service.Name,
Port: k8snetv1.ServiceBackendPort{
Number: int32(*service.Port),
Number: int32(*service.Port), //nolint:gosec
},
},
},
Expand Down Expand Up @@ -203,7 +203,7 @@ func populateKICIngressesWithAnnotations(content *file.Content, kicContent *KICC
Service: &k8snetv1.IngressServiceBackend{
Name: *service.Name,
Port: k8snetv1.ServiceBackendPort{
Number: int32(*service.Port),
Number: int32(*service.Port), //nolint:gosec
},
},
},
Expand Down Expand Up @@ -394,7 +394,7 @@ func populateKICIngressesWithGatewayAPI(content *file.Content, kicContent *KICCo
},
}
if service.Port != nil {
portNumber := k8sgwapiv1.PortNumber(*service.Port)
portNumber := k8sgwapiv1.PortNumber(*service.Port) //nolint:gosec
backendRef.Port = &portNumber
}

Expand Down
8 changes: 5 additions & 3 deletions kong2kic/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ func populateKICServicesWithAnnotations(content *file.Content, kicContent *KICCo

if service.Port != nil {
sPort := k8scorev1.ServicePort{
Protocol: protocol,
Port: int32(*service.Port),
TargetPort: intstr.IntOrString{IntVal: int32(*service.Port)},
Protocol: protocol,
Port: int32(*service.Port), //nolint:gosec
TargetPort: intstr.IntOrString{
IntVal: int32(*service.Port), //nolint:gosec
},
}
k8sService.Spec.Ports = append(k8sService.Spec.Ports, sPort)
}
Expand Down
2 changes: 1 addition & 1 deletion kong2kic/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func WriteContentToFile(content *file.Content, filename string, format file.Form
return err
}
default:
return fmt.Errorf("unknown file format: " + string(format))
return fmt.Errorf("unknown file format: %s", format)
}

if filename == "-" {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func Test_LintStructured(t *testing.T) {
cmpopts.EquateEmpty(),
}
if diff := cmp.Diff(outputErrors, expectedErrors, cmpOpts...); diff != "" {
t.Errorf(diff)
t.Errorf("got unexpected diff\n:%s", diff)
}
})
}
Expand Down
12 changes: 3 additions & 9 deletions tests/integration/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ u8S6yNlu2Q==
func Test_Reset_SkipCACert_2x(t *testing.T) {
// setup stage
client, err := getTestClient()
if err != nil {
t.Errorf(err.Error())
}
require.NoError(t, err)

tests := []struct {
name string
Expand Down Expand Up @@ -75,9 +73,7 @@ func Test_Reset_SkipCACert_2x(t *testing.T) {
func Test_Reset_SkipCACert_3x(t *testing.T) {
// setup stage
client, err := getTestClient()
if err != nil {
t.Errorf(err.Error())
}
require.NoError(t, err)

tests := []struct {
name string
Expand Down Expand Up @@ -113,9 +109,7 @@ func Test_Reset_ConsumerGroupConsumersWithCustomID(t *testing.T) {
setup(t)

client, err := getTestClient()
if err != nil {
t.Fatalf(err.Error())
}
require.NoError(t, err)

require.NoError(t, sync("testdata/sync/028-consumer-group-consumers-custom_id/kong.yaml"))
reset(t)
Expand Down
Loading

0 comments on commit 2160b42

Please sign in to comment.