From c83413d2c26667b3c374ef6e5c0fd963317cb945 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 03:05:42 +0000 Subject: [PATCH 1/2] chore(deps): bump codecov/codecov-action from 4.4.0 to 4.4.1 (#3121) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.0 to 4.4.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.4.0...v4.4.1) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16ce094110..a19f915f04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: run: mage dagger:run "test:unit" - name: Upload Coverage - uses: codecov/codecov-action@v4.4.0 + uses: codecov/codecov-action@v4.4.1 test-darwin: name: "Tests (Go - Darwin)" From bfd36c1299d0067100daa89e1b94780babbbb7ba Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Mon, 27 May 2024 07:44:12 -0500 Subject: [PATCH 2/2] fix: use cloud auth token from JWT instead of API key if present for flipt cloud serve (#3114) --- cmd/flipt/cloud.go | 8 +++++++- cmd/flipt/main.go | 13 +++++++++++-- internal/cmd/grpc.go | 1 - 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/flipt/cloud.go b/cmd/flipt/cloud.go index 99dba9758e..0b772f4b1d 100644 --- a/cmd/flipt/cloud.go +++ b/cmd/flipt/cloud.go @@ -196,7 +196,7 @@ func (c *cloudCommand) serve(cmd *cobra.Command, args []string) error { f, err := os.ReadFile(cloudAuthFile) if err != nil { if errors.Is(err, os.ErrNotExist) { - fmt.Println("No cloud authentication token found. Please run 'flipt cloud login' to authenticate with Flipt Cloud.") + fmt.Println("\nāœ— No cloud authentication token found. Please run 'flipt cloud login' to authenticate.") return nil } @@ -221,6 +221,11 @@ func (c *cloudCommand) serve(cmd *cobra.Command, args []string) error { parsed, err := jwt.Parse(auth.Token, k.Keyfunc, jwt.WithExpirationRequired()) if err != nil { + if errors.Is(err, jwt.ErrTokenExpired) { + fmt.Println("āœ— Existing cloud authentication token expired. Please run 'flipt cloud login' to re-authenticate.") + return nil + } + return fmt.Errorf("parsing JWT: %w", err) } @@ -364,6 +369,7 @@ func (c *cloudCommand) serve(cmd *cobra.Command, args []string) error { cfg.Cloud.Host = u.Hostname() cfg.Cloud.Instance = instance.Instance cfg.Cloud.Organization = instance.Organization + cfg.Cloud.Authentication.ApiKey = "" // clear API key if present to use JWT cfg.Server.Cloud.Enabled = true cfg.Authentication.Session.Domain = u.Host diff --git a/cmd/flipt/main.go b/cmd/flipt/main.go index 42db0e50a8..43b1e3ba17 100644 --- a/cmd/flipt/main.go +++ b/cmd/flipt/main.go @@ -257,6 +257,15 @@ func buildConfig(ctx context.Context) (*zap.Logger, *config.Config, error) { return logger, cfg, nil } +const ( + dntVar = "DO_NOT_TRACK" + ciVar = "CI" +) + +func isSet(env string) bool { + return os.Getenv(env) == "true" || os.Getenv(env) == "1" +} + func run(ctx context.Context, logger *zap.Logger, cfg *config.Config) error { isConsole := cfg.Log.Encoding == config.LogEncodingConsole @@ -298,12 +307,12 @@ func run(ctx context.Context, logger *zap.Logger, cfg *config.Config) error { } // see: https://consoledonottrack.com/ - if (os.Getenv("DO_NOT_TRACK") == "true" || os.Getenv("DO_NOT_TRACK") == "1") && cfg.Meta.TelemetryEnabled { + if isSet(dntVar) && cfg.Meta.TelemetryEnabled { logger.Debug("DO_NOT_TRACK environment variable set, disabling telemetry") cfg.Meta.TelemetryEnabled = false } - if (os.Getenv("CI") == "true" || os.Getenv("CI") == "1") && cfg.Meta.TelemetryEnabled { + if isSet(ciVar) && cfg.Meta.TelemetryEnabled { logger.Debug("CI detected, disabling telemetry") cfg.Meta.TelemetryEnabled = false } diff --git a/internal/cmd/grpc.go b/internal/cmd/grpc.go index 8ec17a83d2..0d7cb9308a 100644 --- a/internal/cmd/grpc.go +++ b/internal/cmd/grpc.go @@ -475,7 +475,6 @@ func NewGRPCServer( // This methods blocks until Shutdown is called. func (s *GRPCServer) Run() error { s.logger.Debug("starting grpc server") - return s.Serve(s.ln) }