Skip to content

Commit

Permalink
Add additional elector environment variables
Browse files Browse the repository at this point in the history
Keep ELECTOR_PATH for backwards compatibility, with plain host and port.
Add ELECTOR_GET_URL for old aka simple API: URL with scheme, host, port and path.
Add ELECTOR_SSE_URL for new SSE API: URL with scheme, host, port and path.
  • Loading branch information
mortenlj committed Aug 22, 2024
1 parent 6427dd7 commit a2fd882
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pkg/resourcecreator/leaderelection/leaderelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Create(source Source, ast *resource.Ast, cfg Config) error {

ast.AppendOperation(resource.OperationCreateOrRecreate, roleBinding(appObjectMeta, roleBindingObjectMeta))
ast.Containers = append(ast.Containers, container(source.GetName(), source.GetNamespace(), image))
ast.Env = append(ast.Env, electorPathEnv())
ast.Env = append(ast.Env, electorEnv()...)
return nil
}

Expand All @@ -68,10 +68,20 @@ func roleBinding(appObjectMeta, roleObjectMeta metav1.ObjectMeta) *rbacv1.RoleBi
}
}

func electorPathEnv() corev1.EnvVar {
return corev1.EnvVar{
Name: "ELECTOR_PATH",
Value: "localhost:4040",
func electorEnv() []corev1.EnvVar {
return []corev1.EnvVar{
{
Name: "ELECTOR_PATH",
Value: "localhost:4040",
},
{
Name: "ELECTOR_GET_URL",
Value: "http://localhost:4040/",
},
{
Name: "ELECTOR_SSE_URL",
Value: "http://localhost:4040/sse",
},
}
}

Expand Down

0 comments on commit a2fd882

Please sign in to comment.