-
Notifications
You must be signed in to change notification settings - Fork 226
fix: upgrade docker cli dependency #2589
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
Merged
SkArchon
merged 4 commits into
main
from
milinda/eng-9090-router-docker-cli-plugins-uncontrolled-search-path-element
Mar 5, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| package integration | ||
|
|
||
| import ( | ||
| "archive/tar" | ||
| "bytes" | ||
| "fmt" | ||
| "io" | ||
| "net/http/httptest" | ||
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/google/go-containerregistry/pkg/crane" | ||
| "github.com/google/go-containerregistry/pkg/name" | ||
| "github.com/google/go-containerregistry/pkg/registry" | ||
| v1 "github.com/google/go-containerregistry/pkg/v1" | ||
| "github.com/google/go-containerregistry/pkg/v1/empty" | ||
| "github.com/google/go-containerregistry/pkg/v1/mutate" | ||
| "github.com/google/go-containerregistry/pkg/v1/partial" | ||
| "github.com/google/go-containerregistry/pkg/v1/tarball" | ||
| "github.com/google/go-containerregistry/pkg/v1/types" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // startTestOCIRegistry starts an in-memory OCI registry on localhost and returns the host:port. | ||
| func startTestOCIRegistry(t *testing.T) string { | ||
| t.Helper() | ||
| reg := registry.New() | ||
| server := httptest.NewServer(reg) | ||
| t.Cleanup(server.Close) | ||
| return strings.TrimPrefix(server.URL, "http://") | ||
| } | ||
|
|
||
| // buildAndPushPluginImage reads a plugin binary (and any adjacent files in its directory), | ||
| // wraps them in an OCI image, and pushes it to the test registry. | ||
| // The binary is placed at /plugin in the image with the entrypoint set to ["/plugin"]. | ||
| // Any sibling files/directories next to the binary are included at the same relative paths. | ||
| func buildAndPushPluginImage(t *testing.T, registryHost, repo, tag, pluginBinaryPath string) { | ||
| t.Helper() | ||
|
|
||
| pluginDir := filepath.Dir(pluginBinaryPath) | ||
| binaryName := filepath.Base(pluginBinaryPath) | ||
|
|
||
| var buf bytes.Buffer | ||
| tw := tar.NewWriter(&buf) | ||
|
|
||
| err := filepath.Walk(pluginDir, func(path string, info os.FileInfo, err error) error { | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| relPath, err := filepath.Rel(pluginDir, path) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Skip the root directory itself | ||
| if relPath == "." { | ||
| return nil | ||
| } | ||
|
|
||
| // Rename the binary to "plugin" | ||
| tarPath := relPath | ||
| if relPath == binaryName { | ||
| tarPath = "plugin" | ||
| } | ||
|
|
||
| header, err := tar.FileInfoHeader(info, "") | ||
| if err != nil { | ||
| return err | ||
| } | ||
| header.Name = tarPath | ||
|
|
||
| if err := tw.WriteHeader(header); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if !info.IsDir() { | ||
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if _, err := tw.Write(data); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| }) | ||
| require.NoError(t, err) | ||
| require.NoError(t, tw.Close()) | ||
|
|
||
| layerBytes := buf.Bytes() | ||
| layer, err := tarball.LayerFromOpener(func() (io.ReadCloser, error) { | ||
| return io.NopCloser(bytes.NewReader(layerBytes)), nil | ||
| }) | ||
| require.NoError(t, err) | ||
|
|
||
| img, err := mutate.AppendLayers(empty.Image, layer) | ||
| require.NoError(t, err) | ||
|
|
||
| cfgFile, err := img.ConfigFile() | ||
| require.NoError(t, err) | ||
| cfgFile.Config.Entrypoint = []string{"/plugin"} | ||
| cfgFile.OS = runtime.GOOS | ||
| cfgFile.Architecture = runtime.GOARCH | ||
| img, err = mutate.ConfigFile(img, cfgFile) | ||
| require.NoError(t, err) | ||
|
|
||
| img = &ociImage{img} | ||
|
|
||
| ref := fmt.Sprintf("%s/%s:%s", registryHost, repo, tag) | ||
| nameRef, err := name.ParseReference(ref) | ||
| require.NoError(t, err) | ||
| err = crane.Push(img, nameRef.String(), crane.Insecure) | ||
| require.NoError(t, err, "pushing image to test registry") | ||
| } | ||
|
|
||
| // ociImage wraps a v1.Image to force OCI media types. | ||
| type ociImage struct { | ||
| v1.Image | ||
| } | ||
|
|
||
| func (i *ociImage) MediaType() (types.MediaType, error) { | ||
| return types.OCIManifestSchema1, nil | ||
| } | ||
|
|
||
| func (i *ociImage) Digest() (v1.Hash, error) { | ||
| return partial.Digest(i) | ||
| } | ||
|
|
||
| func (i *ociImage) Manifest() (*v1.Manifest, error) { | ||
| m, err := i.Image.Manifest() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| m.MediaType = types.OCIManifestSchema1 | ||
| return m, nil | ||
| } | ||
|
|
||
| func (i *ociImage) RawManifest() ([]byte, error) { | ||
| return partial.RawManifest(i) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package integration | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "runtime" | ||
| "slices" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "go.uber.org/zap/zapcore" | ||
| "go.uber.org/zap/zaptest/observer" | ||
|
|
||
| "github.com/wundergraph/cosmo/router-tests/testenv" | ||
| ) | ||
|
|
||
| func TestOCIPlugin_PullAndRun(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| registryHost := startTestOCIRegistry(t) | ||
|
|
||
| projectsBinary := fmt.Sprintf("../router/plugins/projects/bin/%s_%s", runtime.GOOS, runtime.GOARCH) | ||
| coursesBinary := fmt.Sprintf("../router/plugins/courses/bin/%s_%s", runtime.GOOS, runtime.GOARCH) | ||
|
|
||
| buildAndPushPluginImage(t, registryHost, "test-org/projects", "v1", projectsBinary) | ||
| buildAndPushPluginImage(t, registryHost, "test-org/courses", "v1", coursesBinary) | ||
|
|
||
| testenv.Run(t, &testenv.Config{ | ||
| RouterConfigJSONTemplate: testenv.ConfigWithOCIPluginsJSONTemplate, | ||
| Plugins: testenv.PluginConfig{ | ||
| Enabled: true, | ||
| RegistryURL: registryHost, | ||
| }, | ||
| }, func(t *testing.T, xEnv *testenv.Environment) { | ||
| response := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ | ||
| Query: `query { projects { id name } }`, | ||
| }) | ||
| require.Equal(t, `{"data":{"projects":[{"id":"1","name":"Cloud Migration Overhaul"},{"id":"2","name":"Microservices Revolution"},{"id":"3","name":"AI-Powered Analytics"},{"id":"4","name":"DevOps Transformation"},{"id":"5","name":"Security Overhaul"},{"id":"6","name":"Mobile App Development"},{"id":"7","name":"Data Lake Implementation"}]}}`, response.Body) | ||
|
|
||
| response = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ | ||
| Query: `query { courses { id title description } }`, | ||
| }) | ||
| require.Equal(t, `{"data":{"courses":[{"id":"1","title":"Introduction to TypeScript","description":"Learn the basics of TypeScript"},{"id":"2","title":"Advanced GraphQL","description":"Master GraphQL federation"},{"id":"3","title":"Go Programming","description":"Build services with Go"}]}}`, response.Body) | ||
| }) | ||
| } | ||
|
|
||
| func TestOCIPlugin_ImageNotFound(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| registryHost := startTestOCIRegistry(t) | ||
| // Don't push any images — registry is empty | ||
|
|
||
| testenv.FailsOnStartup(t, &testenv.Config{ | ||
| RouterConfigJSONTemplate: testenv.ConfigWithOCIPluginsJSONTemplate, | ||
| Plugins: testenv.PluginConfig{ | ||
| Enabled: true, | ||
| RegistryURL: registryHost, | ||
| }, | ||
| }, func(t *testing.T, err error) { | ||
| require.ErrorContains(t, err, "pulling image") | ||
| }) | ||
| } | ||
|
|
||
| func TestOCIPlugin_Restart(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| registryHost := startTestOCIRegistry(t) | ||
|
|
||
| projectsBinary := fmt.Sprintf("../router/plugins/projects/bin/%s_%s", runtime.GOOS, runtime.GOARCH) | ||
| coursesBinary := fmt.Sprintf("../router/plugins/courses/bin/%s_%s", runtime.GOOS, runtime.GOARCH) | ||
|
|
||
| buildAndPushPluginImage(t, registryHost, "test-org/projects", "v1", projectsBinary) | ||
| buildAndPushPluginImage(t, registryHost, "test-org/courses", "v1", coursesBinary) | ||
|
|
||
| testenv.Run(t, &testenv.Config{ | ||
| RouterConfigJSONTemplate: testenv.ConfigWithOCIPluginsJSONTemplate, | ||
| LogObservation: testenv.LogObservationConfig{ | ||
| Enabled: true, | ||
| LogLevel: zapcore.ErrorLevel, | ||
| }, | ||
| Plugins: testenv.PluginConfig{ | ||
| Enabled: true, | ||
| RegistryURL: registryHost, | ||
| }, | ||
| }, func(t *testing.T, xEnv *testenv.Environment) { | ||
| xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ | ||
| Query: `query { killService }`, | ||
| }) | ||
|
|
||
| require.EventuallyWithT(t, func(c *assert.CollectT) { | ||
| logMessages := xEnv.Observer().All() | ||
| require.True(c, slices.ContainsFunc(logMessages, func(msg observer.LoggedEntry) bool { | ||
| return strings.Contains(msg.Message, "plugin process exited") | ||
| }), "expected to find 'plugin process exited' message in logs") | ||
| }, 5*time.Second, 1*time.Second) | ||
|
|
||
| require.EventuallyWithT(t, func(c *assert.CollectT) { | ||
| response, err := xEnv.MakeGraphQLRequest(testenv.GraphQLRequest{ | ||
| Query: `query { projects { id name } }`, | ||
| }) | ||
| require.NoError(c, err) | ||
| require.Equal(c, 200, response.Response.StatusCode) | ||
| require.Equal(c, `{"data":{"projects":[{"id":"1","name":"Cloud Migration Overhaul"},{"id":"2","name":"Microservices Revolution"},{"id":"3","name":"AI-Powered Analytics"},{"id":"4","name":"DevOps Transformation"},{"id":"5","name":"Security Overhaul"},{"id":"6","name":"Mobile App Development"},{"id":"7","name":"Data Lake Implementation"}]}}`, response.Body) | ||
| }, 20*time.Second, 2*time.Second) | ||
| }) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.