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

Create interface for parameter cross cloud providers #632

Merged
merged 8 commits into from
Feb 20, 2024
Merged
28 changes: 17 additions & 11 deletions common/config/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ const (
type CommonEnvironment struct {
providerRegistry

Ctx *pulumi.Context
CommonNamer namer.Namer
Ctx *pulumi.Context
CommonNamer namer.Namer
CloudProviderEnvironment CloudProviderEnvironment

InfraConfig *sdkconfig.Config
AgentConfig *sdkconfig.Config
Expand All @@ -71,16 +72,21 @@ type CommonEnvironment struct {
username string
}

func NewCommonEnvironment(ctx *pulumi.Context) (CommonEnvironment, error) {
type CloudProviderEnvironment interface {
GetInternalRegistry() string
}

func NewCommonEnvironment(ctx *pulumi.Context, cloudProviderEnvironment CloudProviderEnvironment) (CommonEnvironment, error) {
env := CommonEnvironment{
Ctx: ctx,
InfraConfig: sdkconfig.New(ctx, DDInfraConfigNamespace),
AgentConfig: sdkconfig.New(ctx, DDAgentConfigNamespace),
TestingWorkloadConfig: sdkconfig.New(ctx, DDTestingWorkloadNamespace),
DogstatsdConfig: sdkconfig.New(ctx, DDDogstatsdNamespace),
UpdaterConfig: sdkconfig.New(ctx, DDUpdaterConfigNamespace),
CommonNamer: namer.NewNamer(ctx, ""),
providerRegistry: newProviderRegistry(ctx),
Ctx: ctx,
InfraConfig: sdkconfig.New(ctx, DDInfraConfigNamespace),
AgentConfig: sdkconfig.New(ctx, DDAgentConfigNamespace),
TestingWorkloadConfig: sdkconfig.New(ctx, DDTestingWorkloadNamespace),
DogstatsdConfig: sdkconfig.New(ctx, DDDogstatsdNamespace),
UpdaterConfig: sdkconfig.New(ctx, DDUpdaterConfigNamespace),
CommonNamer: namer.NewNamer(ctx, ""),
CloudProviderEnvironment: cloudProviderEnvironment,
providerRegistry: newProviderRegistry(ctx),
}
// store username
user, err := user.Current()
Expand Down
11 changes: 10 additions & 1 deletion resources/aws/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ type Environment struct {
randomSubnets pulumi.StringArrayOutput
}

type CloudProviderEnvironment struct{}

func (e *CloudProviderEnvironment) GetInternalRegistry() string {
return "669783387624.dkr.ecr.us-east-1.amazonaws.com"
}

KevinFairise2 marked this conversation as resolved.
Show resolved Hide resolved
func WithCommonEnvironment(e *config.CommonEnvironment) func(*Environment) {
return func(awsEnv *Environment) {
awsEnv.CommonEnvironment = e
awsEnv.CommonEnvironment.CloudProviderEnvironment = &CloudProviderEnvironment{}
}
}

Expand All @@ -77,8 +84,10 @@ func NewEnvironment(ctx *pulumi.Context, options ...func(*Environment)) (Environ
for _, opt := range options {
opt(&env)
}

awsParameter := &CloudProviderEnvironment{}
if env.CommonEnvironment == nil {
commonEnv, err := config.NewCommonEnvironment(ctx)
commonEnv, err := config.NewCommonEnvironment(ctx, awsParameter)
if err != nil {
return Environment{}, err
}
Expand Down
10 changes: 9 additions & 1 deletion resources/azure/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ type Environment struct {
envDefault environmentDefault
}

type CloudProviderEnvironment struct{}

func (p *CloudProviderEnvironment) GetInternalRegistry() string {
return ""
}

func NewEnvironment(ctx *pulumi.Context) (Environment, error) {
commonEnv, err := config.NewCommonEnvironment(ctx)

azureParameter := &CloudProviderEnvironment{}
commonEnv, err := config.NewCommonEnvironment(ctx, azureParameter)
if err != nil {
return Environment{}, err
}
Expand Down
9 changes: 8 additions & 1 deletion resources/hyperv/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ type Environment struct {
Namer namer.Namer
}

type CloudProviderEnvironment struct{}

func (p *CloudProviderEnvironment) GetInternalRegistry() string {
return ""
}

func NewEnvironment(ctx *pulumi.Context) (Environment, error) {
commonEnv, err := config.NewCommonEnvironment(ctx)
hyperVParameter := &CloudProviderEnvironment{}
commonEnv, err := config.NewCommonEnvironment(ctx, hyperVParameter)
if err != nil {
return Environment{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion scenarios/aws/microVMs/microvms/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func RunAndReturnInstances(e commonConfig.CommonEnvironment) (*ScenarioDone, err
}

func Run(ctx *pulumi.Context) error {
commonEnv, err := commonConfig.NewCommonEnvironment(ctx)
commonEnv, err := commonConfig.NewCommonEnvironment(ctx, nil)
if err != nil {
return err
}
Expand Down
Loading