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

Add env var support #324

Merged
merged 5 commits into from
Dec 21, 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
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),
regadas marked this conversation as resolved.
Show resolved Hide resolved
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
Loading