Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/go.opentelemetry.io/ot…
Browse files Browse the repository at this point in the history
…el/exporters/otlp/otlptrace/otlptracegrpc-1.27.0
  • Loading branch information
markphelps authored May 27, 2024
2 parents 3d9021b + bfd36c1 commit 0f41b72
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: mage dagger:run "test:unit"

- name: Upload Coverage
uses: codecov/[email protected].0
uses: codecov/[email protected].1

test-darwin:
name: "Tests (Go - Darwin)"
Expand Down
8 changes: 7 additions & 1 deletion cmd/flipt/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("\nNo cloud authentication token found. Please run 'flipt cloud login' to authenticate.")
return nil
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions cmd/flipt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 0f41b72

Please sign in to comment.