Skip to content

Commit

Permalink
feat: adds support for docker-distroless image.
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Jul 2, 2024
1 parent 5f539f5 commit 48fbc99
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
6 changes: 5 additions & 1 deletion cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ func getBundleDest(engineType engine.EngineType) string {
if bundleFlags.output != "" {
dest = bundleFlags.output
} else {
if engineType == engine.EngineTypeDockerCore || engineType == engine.EngineTypeDockerAll {
if engineType == engine.EngineTypeDockerCore ||
engineType == engine.EngineTypeDockerAll ||
engineType == engine.EngineTypeDockerDistroless {

imageTag := time.Now().Format("20060102150405")
dest = "imposter-bundle:" + imageTag

} else {
temp, err := os.CreateTemp(os.TempDir(), "imposter-bundle-*.zip")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
var localTypes = []engine.EngineType{
engine.EngineTypeDockerCore,
engine.EngineTypeDockerAll,
engine.EngineTypeDockerDistroless,
engine.EngineTypeJvmSingleJar,
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/engine_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func Test_pull(t *testing.T) {
engineType: engine.EngineTypeDockerAll,
pullPolicy: engine.PullIfNotPresent,
}},
{name: "pull docker all distro if not present", args: args{
version: "3.44.1",
engineType: engine.EngineTypeDockerDistroless,
pullPolicy: engine.PullIfNotPresent,
}},
{name: "pull latest jvm always", args: args{
version: "latest",
engineType: engine.EngineTypeJvmSingleJar,
Expand Down
15 changes: 8 additions & 7 deletions engine/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import (
type EngineType string

const (
EngineTypeNone EngineType = ""
EngineTypeAwsLambda EngineType = "awslambda"
EngineTypeDockerCore EngineType = "docker"
EngineTypeDockerAll EngineType = "docker-all"
EngineTypeJvmSingleJar EngineType = "jvm"
EngineTypeJvmUnpacked EngineType = "unpacked"
EngineTypeNone EngineType = ""
EngineTypeAwsLambda EngineType = "awslambda"
EngineTypeDockerCore EngineType = "docker"
EngineTypeDockerAll EngineType = "docker-all"
EngineTypeDockerDistroless EngineType = "docker-distroless"
EngineTypeJvmSingleJar EngineType = "jvm"
EngineTypeJvmUnpacked EngineType = "unpacked"
)
const defaultEngineType = EngineTypeDockerCore

Expand Down Expand Up @@ -100,7 +101,7 @@ func build(engineType EngineType, configDir string, startOptions StartOptions) M

func validateEngineType(engineType EngineType) error {
switch engineType {
case EngineTypeAwsLambda, EngineTypeDockerCore, EngineTypeDockerAll, EngineTypeJvmSingleJar, EngineTypeJvmUnpacked:
case EngineTypeAwsLambda, EngineTypeDockerCore, EngineTypeDockerAll, EngineTypeDockerDistroless, EngineTypeJvmSingleJar, EngineTypeJvmUnpacked:
return nil
}
return fmt.Errorf("unsupported engine type: %v", engineType)
Expand Down
3 changes: 3 additions & 0 deletions engine/docker/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func getImageRepo(engineType engine.EngineType) string {
case engine.EngineTypeDockerAll:
imageRepo = "outofcoffee/imposter-all"
break
case engine.EngineTypeDockerDistroless:
imageRepo = "outofcoffee/imposter-distroless"
break
default:
panic("Unsupported engine type: " + engineType)
}
Expand Down
2 changes: 2 additions & 0 deletions engine/docker/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (l DockerEngineLibrary) ShouldEnsurePlugins() bool {
return true
case engine.EngineTypeDockerAll:
return false
case engine.EngineTypeDockerDistroless:
return true
default:
panic(fmt.Errorf("unsupported engine type: %s for Docker library", l.engineType))
}
Expand Down
1 change: 1 addition & 0 deletions engine/docker/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func EnableEngine() {
initialised = true
register(engine.EngineTypeDockerCore)
register(engine.EngineTypeDockerAll)
register(engine.EngineTypeDockerDistroless)
}
}

Expand Down

0 comments on commit 48fbc99

Please sign in to comment.