Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
eac2cf2
chore(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.17 to…
outofcoffee May 28, 2026
4e84f46
chore(deps): update various indirect Go module dependencies
outofcoffee May 28, 2026
0f163e9
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.101.…
outofcoffee May 29, 2026
d3870fa
chore(deps): bump github.com/aws/aws-sdk-go-v2 from 1.41.7 to 1.41.8
outofcoffee May 30, 2026
17880f3
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/iam from 1.53.…
outofcoffee May 30, 2026
e8146b0
chore(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.18 to…
outofcoffee May 30, 2026
514e597
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/lambda from 1.…
outofcoffee May 30, 2026
08c888e
chore(deps): bump github.com/aws/aws-sdk-go-v2 from 1.41.8 to 1.41.9
outofcoffee Jun 2, 2026
c7a86cd
chore(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.19 to…
outofcoffee Jun 2, 2026
9fda995
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/iam from 1.53.…
outofcoffee Jun 2, 2026
5b43620
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/lambda from 1.…
outofcoffee Jun 2, 2026
214ffca
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.102.…
outofcoffee Jun 2, 2026
c9c6959
chore(deps): bump github.com/shirou/gopsutil/v4 from 4.26.4 to 4.26.5
outofcoffee Jun 2, 2026
14b9c84
chore(deps): run go mod tidy to sync go.sum
outofcoffee Jun 2, 2026
8c35603
chore(deps): bump github.com/aws/aws-sdk-go-v2 from 1.41.9 to 1.41.11
outofcoffee Jun 4, 2026
42969d3
chore(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.20 to…
outofcoffee Jun 4, 2026
f3ccc09
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/lambda from 1.…
outofcoffee Jun 4, 2026
bb57158
chore(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.102.…
outofcoffee Jun 4, 2026
72ee2d9
feat: generate .imposter.yaml during scaffold and add gRPC/protobuf s…
claude Jun 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ var scaffoldCmd = &cobra.Command{
Aliases: []string{"init"},
Short: "Create Imposter configuration",
Long: `Creates Imposter configuration files. If one or more OpenAPI/Swagger
specification files or WSDL files are present, they are used as the basis for
the generated resources. If no specification files are present, a simple REST
mock is created.
specification files, WSDL files or protobuf files are present, they are used
as the basis for the generated configuration. If no specification files are
present, a simple REST mock is created.

If DIR is not specified, the current working directory is used.`,
Args: cobra.RangeArgs(0, 1),
Expand Down
68 changes: 65 additions & 3 deletions cmd/scaffold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ limitations under the License.
package cmd

import (
"github.com/imposter-project/imposter-cli/internal/fileutil"
impostermodel2 "github.com/imposter-project/imposter-cli/internal/impostermodel"
"github.com/sirupsen/logrus"
"os"
"path/filepath"
"strings"
"testing"

"github.com/imposter-project/imposter-cli/internal/fileutil"
impostermodel2 "github.com/imposter-project/imposter-cli/internal/impostermodel"
"github.com/sirupsen/logrus"
)

func init() {
Expand All @@ -42,6 +44,7 @@ func Test_createMockConfig(t *testing.T) {
scriptEngine impostermodel2.ScriptEngine
copySpecs bool
copyWsdl bool
copyProto bool
anchorFileName string
checkResponseFile bool
}
Expand Down Expand Up @@ -148,6 +151,28 @@ func Test_createMockConfig(t *testing.T) {
checkResponseFile: false,
},
},
{
name: "generate grpc mock no script",
args: args{
generateResources: true,
forceOverwrite: true,
scriptEngine: impostermodel2.ScriptEngineNone,
anchorFileName: "pet_store",
copyProto: true,
checkResponseFile: false,
},
},
{
name: "generate grpc mock with script",
args: args{
generateResources: true,
forceOverwrite: true,
scriptEngine: impostermodel2.ScriptEngineJavaScript,
anchorFileName: "pet_store",
copyProto: true,
checkResponseFile: false,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -164,6 +189,12 @@ func Test_createMockConfig(t *testing.T) {
t.Fatal(err)
}
}
if tt.args.copyProto {
err = fileutil.CopyFile(filepath.Join(workingDir, "testdata_grpc", "pet_store.proto"), filepath.Join(configDir, "pet_store.proto"))
if err != nil {
t.Fatal(err)
}
}
impostermodel2.Create(configDir, tt.args.generateResources, tt.args.forceOverwrite, tt.args.scriptEngine, false)

if !doesFileExist(filepath.Join(configDir, tt.args.anchorFileName+"-config.yaml")) {
Expand All @@ -183,6 +214,37 @@ func Test_createMockConfig(t *testing.T) {
t.Fatalf("script file should not exist")
}
}

dotImposterPath := filepath.Join(configDir, ".imposter.yaml")
if !doesFileExist(dotImposterPath) {
t.Fatalf(".imposter.yaml should exist")
}
dotImposterContent, err := os.ReadFile(dotImposterPath)
if err != nil {
t.Fatal(err)
}
content := string(dotImposterContent)
if tt.args.copyProto {
if !strings.Contains(content, "version: 5-beta") {
t.Fatalf(".imposter.yaml should contain version: 5-beta for grpc, got:\n%s", content)
}
if !strings.Contains(content, "- grpc") {
t.Fatalf(".imposter.yaml should contain grpc plugin for grpc, got:\n%s", content)
}
} else {
if !strings.Contains(content, "version: latest") {
t.Fatalf(".imposter.yaml should contain version: latest, got:\n%s", content)
}
}
if !strings.Contains(content, "IMPOSTER_LOG_LEVEL: DEBUG") {
t.Fatalf(".imposter.yaml should contain IMPOSTER_LOG_LEVEL: DEBUG, got:\n%s", content)
}
if !strings.Contains(content, "# or pin to a particular version") {
t.Fatalf(".imposter.yaml should contain version comment, got:\n%s", content)
}
if !strings.Contains(content, "# See https://docs.imposter.sh/environment_variables/") {
t.Fatalf(".imposter.yaml should contain env docs comment, got:\n%s", content)
}
})
}
}
Expand Down
22 changes: 22 additions & 0 deletions cmd/testdata_grpc/pet_store.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";

package store;

service PetStore {
rpc GetPet (GetPetRequest) returns (GetPetResponse);
rpc ListPets (ListPetsRequest) returns (ListPetsResponse);
}

message GetPetRequest {
string pet_id = 1;
}

message GetPetResponse {
string name = 1;
}

message ListPetsRequest {}

message ListPetsResponse {
repeated GetPetResponse pets = 1;
}
112 changes: 58 additions & 54 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ go 1.25.0

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/aws/aws-sdk-go-v2 v1.41.7
github.com/aws/aws-sdk-go-v2/config v1.32.17
github.com/aws/aws-sdk-go-v2/credentials v1.19.16
github.com/aws/aws-sdk-go-v2/service/iam v1.53.10
github.com/aws/aws-sdk-go-v2/service/lambda v1.90.1
github.com/aws/aws-sdk-go-v2/service/s3 v1.101.0
github.com/aws/aws-sdk-go-v2 v1.41.11
github.com/aws/aws-sdk-go-v2/config v1.32.22
github.com/aws/aws-sdk-go-v2/credentials v1.19.21
github.com/aws/aws-sdk-go-v2/service/iam v1.54.0
github.com/aws/aws-sdk-go-v2/service/lambda v1.92.1
github.com/aws/aws-sdk-go-v2/service/s3 v1.103.1
github.com/coreos/go-semver v0.3.1
github.com/docker/docker v28.5.2+incompatible
github.com/docker/go-connections v0.7.0
github.com/google/uuid v1.6.0
github.com/olekukonko/tablewriter v1.1.4
github.com/radovskyb/watcher v1.0.7
github.com/shirou/gopsutil/v4 v4.26.4
github.com/shirou/gopsutil/v4 v4.26.5
github.com/sirupsen/logrus v1.9.4
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
Expand All @@ -30,39 +30,44 @@ require (
github.com/antchfx/xmlquery v1.5.1 // indirect
github.com/antchfx/xpath v1.3.6 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/displaywidth v0.10.0 // indirect
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/moby/moby/api v1.54.1 // indirect
github.com/moby/moby/client v0.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
github.com/moby/moby/api v1.54.2 // indirect
github.com/moby/moby/client v0.4.1 // indirect
github.com/moby/sys/atomicwriter v0.1.0 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 // indirect
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260511170946-3700d4141b60 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260511170946-3700d4141b60 // indirect
google.golang.org/grpc v1.81.1 // indirect
pgregory.net/rapid v1.3.0 // indirect
)

require (
dario.cat/mergo v1.0.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.10 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.24 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.9 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.23 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.23 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.0.11 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.30.17 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.21 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.42.1 // indirect
github.com/aws/smithy-go v1.25.1 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.12 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.28 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.20 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.27 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.1.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.31.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.43.1 // indirect
github.com/aws/smithy-go v1.27.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
Expand All @@ -72,54 +77,53 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ebitengine/purego v0.10.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/ebitengine/purego v0.10.1 // indirect
github.com/fatih/color v1.19.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirect
github.com/magiconair/properties v1.8.10 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/go-archive v0.2.0 // indirect
github.com/moby/patternmatcher v0.6.1 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/user v0.4.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/olekukonko/errors v1.2.0 // indirect
github.com/olekukonko/ll v0.1.6 // indirect
github.com/morikuni/aec v1.1.0 // indirect
github.com/olekukonko/errors v1.3.0 // indirect
github.com/olekukonko/ll v0.1.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/outofcoffee/go-wsdl-parser v0.2.0
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/tklauser/go-sysconf v0.4.0 // indirect
github.com/tklauser/numcpus v0.12.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading