Skip to content

Commit

Permalink
Add env var support (#324)
Browse files Browse the repository at this point in the history
Co-authored-by: Filipe Regadas <[email protected]>
  • Loading branch information
andresgomezfrr and regadas authored Dec 21, 2023
1 parent 10fb176 commit f61f437
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/flink/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ import (
)

type FlinkTaskContext struct {
ClusterName ClusterName
Namespace string
Annotations map[string]string
Labels map[string]string
Job flinkIdl.FlinkJob
ClusterName ClusterName
Namespace string
Annotations map[string]string
Labels map[string]string
EnvironmentVariables map[string]string
Job flinkIdl.FlinkJob
}

type FlinkTaskExecContext interface {
Expand Down Expand Up @@ -92,11 +93,12 @@ func NewFlinkTaskContext(ctx context.Context, taskCtx FlinkTaskExecContext) (*Fl
}

return &FlinkTaskContext{
ClusterName: cn,
Namespace: taskMetadata.GetNamespace(),
Annotations: GetDefaultAnnotations(taskMetadata),
Labels: GetDefaultLabels(taskMetadata),
Job: job,
ClusterName: cn,
Namespace: taskMetadata.GetNamespace(),
Annotations: GetDefaultAnnotations(taskMetadata),
Labels: GetDefaultLabels(taskMetadata),
EnvironmentVariables: GetDefaultEnvironmentVariables(taskMetadata),
Job: job,
}, nil
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/flink/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ func GetDefaultLabels(taskCtx pluginsCore.TaskExecutionMetadata) Labels {
)
}

type EnvVars map[string]string

func GetDefaultEnvironmentVariables(taskCtx pluginsCore.TaskExecutionMetadata) EnvVars {
return utils.UnionMaps(
config.GetK8sPluginConfig().DefaultEnvVars,
utils.CopyMap(taskCtx.GetEnvironmentVariables()),
)
}

type ClusterName string

func (cn ClusterName) Validate() error {
Expand Down

0 comments on commit f61f437

Please sign in to comment.