Fix TestDockerPluginSuite/TestPluginInstallArgs nil panic#41180
Fix TestDockerPluginSuite/TestPluginInstallArgs nil panic#41180yedamao wants to merge 1 commit intomoby:masterfrom
Conversation
fix the embedding *types.PluginConfig is nil Signed-off-by: HuanHuan Ye <logindaveye@gmail.com>
| } | ||
|
|
||
| var cfg Config | ||
| cfg.PluginConfig = &types.PluginConfig{} |
There was a problem hiding this comment.
Thinking what would be better; set PluginConfig here, or update TestPluginInstallArgs to take this case into account;
moby/integration-cli/docker_cli_plugins_test.go
Lines 199 to 201 in 07e6b84
And change the above to:
plugin.CreateInRegistry(ctx, pName, nil, func(cfg *plugin.Config) {
if cfg.PluginConfig == nil {
cfg.PluginConfig = &types.PluginConfig{}
}
cfg.Env = []types.PluginEnv{{Name: "DEBUG", Settable: []string{"value"}}}
})There was a problem hiding this comment.
how about this:
cfg := Config{PluginConfig: &types.PluginConfig{}}There was a problem hiding this comment.
You mean in the plugin.CreateInRegistry(... code or in the CreateInRegistry() fixture?
In the plugin.CreateInRegistry(..., that wouldn't be correct, because it would overwrite other options in the config.
If you meant in the CreateInRegistry() fixture; yes, that would work, but would be roughly the same as the change is now.
My train of thought for my first comment was that (I think) TestPluginInstallArgs should be able to work with a "default" / "empty" config; from that perspective it would be "cleaner" if we didn't modify the fixture, but adjusted the test to handle that case.
There was a problem hiding this comment.
I think the embedding pointer to PluginConfig should be initialized when cfg Config be declared.
if check and initial cfg.PluginConfig in CreateOpt function, other CreateOpt function (if have) should do so.
fix #40932 the embedding *types.PluginConfig is nil
Signed-off-by: HuanHuan Ye logindaveye@gmail.com
- What I did
Fix TestDockerPluginSuite/TestPluginInstallArgs panic
- How I did it
fix the embedding *types.PluginConfig is nil
- How to verify it
go test -v --run=TestDockerPluginSuite
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)