Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use hardcoded Konnect version instead of retrieving it #1095

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism,
var kongVersion string
var parsedKongVersion semver.Version
if mode == modeKonnect {
kongVersion, err = fetchKonnectKongVersion(ctx, kongClient)
if err != nil {
return fmt.Errorf("reading Konnect Kong version: %w", err)
}
kongVersion = fetchKonnectKongVersion()
} else {
kongVersion, err = fetchKongVersion(ctx, wsConfig)
if err != nil {
Expand Down
26 changes: 7 additions & 19 deletions cmd/common_konnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"context"
"fmt"
"net/http"
"os"
"strings"

Expand Down Expand Up @@ -118,10 +117,6 @@ func dumpKonnectV2(ctx context.Context) error {
if err != nil {
return err
}
kongVersion, err := fetchKonnectKongVersion(ctx, client)
if err != nil {
return fmt.Errorf("reading Konnect Kong version: %w", err)
}
rawState, err := dump.Get(ctx, client, dumpConfig)
if err != nil {
return fmt.Errorf("reading configuration from Kong: %w", err)
Expand All @@ -136,7 +131,7 @@ func dumpKonnectV2(ctx context.Context) error {
FileFormat: file.Format(strings.ToUpper(dumpCmdStateFormat)),
WithID: dumpWithID,
ControlPlaneName: konnectControlPlane,
KongVersion: kongVersion,
KongVersion: fetchKonnectKongVersion(),
})
}

Expand Down Expand Up @@ -346,17 +341,10 @@ func getKonnectState(ctx context.Context,
return ks, nil
}

func fetchKonnectKongVersion(ctx context.Context, client *kong.Client) (string, error) {
req, err := http.NewRequest("GET",
utils.CleanAddress(client.BaseRootURL())+"/v1", nil)
if err != nil {
return "", err
}

var resp map[string]interface{}
_, err = client.Do(ctx, req, &resp)
if err != nil {
return "", err
}
return resp["version"].(string), nil
func fetchKonnectKongVersion() string {
// Returning an hardcoded version for now. decK only needs the version
// to determine the format_version expected in the state file. Since
// Konnect is always on the latest version, we can safely return the
// latest version here and avoid making an extra and unnecessary request.
return "3.5.0.0"
}