Skip to content

Commit

Permalink
Add a local environment that implements config.Env interface (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinFairise2 committed May 21, 2024
1 parent 3b71e7f commit ef99991
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/kubernetes/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func NewLocalKindCluster(env config.Env, resourceName, kindClusterName string, k
return err
}

nodeImage := fmt.Sprintf("%s/%s:%s", env.InfraOSDescriptor(), kindNodeImageName, kindVersionConfig.nodeImageVersion)
nodeImage := fmt.Sprintf("%s/%s:%s", env.InternalDockerhubMirror(), kindNodeImageName, kindVersionConfig.nodeImageVersion)
createCluster, err := runner.Command(
commonEnvironment.CommonNamer().ResourceName("kind-create-cluster", resourceName),
&command.Args{
Expand Down
38 changes: 38 additions & 0 deletions resources/local/environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package local

import (
"github.com/DataDog/test-infra-definitions/common/config"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

type Environment struct {
// CommonEnvironment is the common environment for all the components
// in the test-infra-definitions.
*config.CommonEnvironment
}

var _ config.Env = (*Environment)(nil)

// NewEnvironment creates a new local environment.
func NewEnvironment(ctx *pulumi.Context) (Environment, error) {
env := Environment{}

commonEnv, err := config.NewCommonEnvironment(ctx)
if err != nil {
return Environment{}, err
}

env.CommonEnvironment = &commonEnv

return env, nil
}

// InternalRegistry returns the internal registry.
func (e *Environment) InternalRegistry() string {
return "none"
}

// InternalDockerhubMirror returns the internal Dockerhub mirror.
func (e *Environment) InternalDockerhubMirror() string {
return "registry-1.docker.io"
}

0 comments on commit ef99991

Please sign in to comment.