mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:12:02 +00:00
msp: provision and load EXTERNAL_DNS_NAME envvar (#58275)
This commit is contained in:
parent
9c7d092513
commit
e1f590b27d
@ -129,11 +129,16 @@ func NewStack(stacks *stack.Set, vars Variables) (crossStackOutput *CrossStackOu
|
||||
// convention across MSP services.
|
||||
cloudRunBuilder.AddEnv("DIAGNOSTICS_SECRET", diagnosticsSecret.HexValue)
|
||||
|
||||
// Add the domain as an environment variable.
|
||||
dnsName := pointers.DerefZero(vars.Environment.EnvironmentServiceSpec).Domain.GetDNSName()
|
||||
if dnsName != "" {
|
||||
cloudRunBuilder.AddEnv("EXTERNAL_DNS_NAME", dnsName)
|
||||
}
|
||||
|
||||
// Add user-configured env vars
|
||||
if err := addContainerEnvVars(cloudRunBuilder, vars.Environment.Env, vars.Environment.SecretEnv, envVariablesData{
|
||||
ProjectID: vars.ProjectID,
|
||||
ServiceDnsName: pointers.DerefZero(vars.Environment.EnvironmentServiceSpec).
|
||||
Domain.GetDNSName(),
|
||||
ProjectID: vars.ProjectID,
|
||||
ServiceDnsName: dnsName,
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "add user env vars")
|
||||
}
|
||||
|
||||
@ -9,14 +9,18 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
)
|
||||
|
||||
// Contract loads standardized MSP-provisioned configuration.
|
||||
type Contract struct {
|
||||
// Port is the port the service must listen on.
|
||||
Port int
|
||||
// ExternalDNSName is the DNS name the service uses, if one is configured.
|
||||
ExternalDNSName *string
|
||||
}
|
||||
|
||||
func newContract(env *Env) Contract {
|
||||
return Contract{
|
||||
Port: env.GetInt("PORT", "", "service port"),
|
||||
Port: env.GetInt("PORT", "", "service port"),
|
||||
ExternalDNSName: env.GetOptional("EXTERNAL_DNS_NAME", "external DNS name provisioned for the service"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,8 +90,12 @@ func (e *Env) Get(name, defaultValue, description string) string {
|
||||
}
|
||||
|
||||
// GetOptional returns the value with the given name.
|
||||
func (e *Env) GetOptional(name, description string) string {
|
||||
return e.get(name, "", description)
|
||||
func (e *Env) GetOptional(name, description string) *string {
|
||||
v, ok := e.env[name]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &v
|
||||
}
|
||||
|
||||
// GetInt returns the value with the given name interpreted as an integer. If no
|
||||
|
||||
Loading…
Reference in New Issue
Block a user