fix(deploy): skip kubectl flag validation for configs with no deploy section - #10111
Conversation
…section When using skaffold apply with a multi-config project where a dependency config has no deploy section (e.g. only resourceSelector), the default deployer would incorrectly treat the zero-value KubectlFlags as conflicting with the parent config's flags. Move the validateKubectlFlags call and namespace check inside the existing if d.KubectlDeploy != nil block so configs without a kubectl deploy section are skipped entirely. Fixes GoogleContainerTools#10071
There was a problem hiding this comment.
Code Review
This pull request resolves an issue where dependency configurations without a deploy section were incorrectly treated as having conflicting kubectl deploy flags. The fix refactors getDefaultDeployer to only process kubectl flags and namespaces when d.KubectlDeploy is not nil, and includes a regression test. Feedback on the changes suggests a performance optimization in deployer.go to reference &d.KubectlDeploy.Flags directly, which avoids copying the struct to a block-local variable and prevents unnecessary heap allocations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
What changed
When using
skaffold applywith a multi-config project where a dependency config has no deploy section (e.g. it only providesresourceSelector), the default deployer would incorrectly treat the zero-valueKubectlFlags{}as conflicting with the parent config's kubectl flags (e.g.--server-side).Root Cause
In
getDefaultDeployer,validateKubectlFlagswas called for every pipeline config regardless of whetherd.KubectlDeploywasnil. AnilKubectlDeployproduced a zero-valueKubectlFlags{}that did not contain the parent's flags, causing a false conflict error.Fix
Moved the
validateKubectlFlagscall and theDefaultNamespaceconflict check inside the existingif d.KubectlDeploy != nilblock. Configs without a kubectl deploy section are now skipped entirely.Testing
TestGetDefaultDeployer/parent_config_with_kubectl_flags_and_dependency_config_with_no_deploy_section_should_not_conflictinpkg/skaffold/runner/deployer_test.goTestGetDefaultDeployersubtests passFixes #10071