Skip to content
Open
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
8 changes: 1 addition & 7 deletions go-sdk/pkg/execution/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"

"github.com/apache/airflow/go-sdk/pkg/api"
"github.com/apache/airflow/go-sdk/pkg/execution/genmodels"
Expand Down Expand Up @@ -72,11 +70,7 @@ func NewCoordinatorClient(comm *CoordinatorComm) *CoordinatorClient {

// GetVariable requests a variable value from the supervisor.
func (c *CoordinatorClient) GetVariable(ctx context.Context, key string) (string, error) {
// TODO: this duplicates variableFromEnv in sdk/client.go. The env-first
// precedence is part of the SDK contract, so both clients should share a
// single helper (e.g. an exported sdk.VariableFromEnv) instead of two
// independent copies that can drift.
if env, ok := os.LookupEnv(sdk.VariableEnvPrefix + strings.ToUpper(key)); ok {
if env, ok := sdk.VariableFromEnv(key); ok {
return env, nil
}

Expand Down
5 changes: 3 additions & 2 deletions go-sdk/sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ func NewClient() Client {
return &client{}
}

func variableFromEnv(key string) (string, bool) {
// VariableFromEnv returns the AIRFLOW_VAR_<UPPER(key)> value and whether it is set.
func VariableFromEnv(key string) (string, bool) {
return os.LookupEnv(VariableEnvPrefix + strings.ToUpper(key))
}

func (*client) GetVariable(ctx context.Context, key string) (string, error) {
// TODO: Let the lookup priority be configurable like it is in Python SDK
if env, ok := variableFromEnv(key); ok {
if env, ok := VariableFromEnv(key); ok {
return env, nil
}

Expand Down
Loading