mirror of
https://github.com/peridotbuild/peridot.git
synced 2024-06-04 09:10:17 +00:00
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package kubernetes
|
|
|
|
import (
|
|
"go.resf.org/peridot/devtools/garrison/internal/pkg/starlark"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
)
|
|
|
|
type EnvironmentVariables struct {
|
|
// Stage is the environment the current deployment will run in
|
|
Stage starlark.Stage
|
|
|
|
// Kubernetes-specific
|
|
|
|
// Namespace is the Kubernetes namespace to deploy to
|
|
Namespace string
|
|
|
|
// ServiceAccountName is the Kubernetes service account to use
|
|
ServiceAccountName string
|
|
|
|
// Cloud-specific
|
|
|
|
// AwsRegion is the AWS region to use as default
|
|
AwsRegion string
|
|
|
|
// Dev-specific
|
|
|
|
// LocalstackEndpoint is the endpoint to use for localstack
|
|
LocalstackEndpoint string
|
|
}
|
|
|
|
func GetEnvironmentVariables(state *starlark.State, md *metav1.ObjectMeta) *EnvironmentVariables {
|
|
defaultAwsRegion := "us-east-2"
|
|
if state.Default.AwsRegion != nil {
|
|
defaultAwsRegion = *state.Default.AwsRegion
|
|
}
|
|
|
|
localstackEndpoint := "http://localstack.default.svc.cluster.local:4566"
|
|
if state.Stage != starlark.StageDevelopment {
|
|
localstackEndpoint = ""
|
|
}
|
|
|
|
return &EnvironmentVariables{
|
|
Stage: state.Stage,
|
|
Namespace: md.Namespace,
|
|
ServiceAccountName: md.Name,
|
|
AwsRegion: defaultAwsRegion,
|
|
LocalstackEndpoint: localstackEndpoint,
|
|
}
|
|
}
|