mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: flatten proxy skip_commands schema and move docs to proxy-mode.md (#241)
- Replace nested policies map with flat skip_commands map in ProxyConfig - Make skip_commands dependent on install_only being enabled - Move proxy configuration docs from proxy.md to proxy-mode.md - Update config template and tests for new schema
This commit is contained in:
@@ -52,18 +52,20 @@ func (f *proxyFlow) Run(ctx context.Context, args []string, parsedCmd *packagema
|
||||
|
||||
cfg := config.Get()
|
||||
|
||||
// Skip proxy for commands that don't download packages when install_only is enabled
|
||||
if cfg.Config.Proxy.InstallOnly && !parsedCmd.MayDownloadPackages() {
|
||||
log.Debugf("Skipping proxy for non-download command (install_only=true)")
|
||||
return runner.Execute(ctx, parsedCmd, f.pm.Name(), cfg.DryRun)
|
||||
}
|
||||
|
||||
// Skip proxy for user-defined skip commands
|
||||
if policy, ok := cfg.Config.Proxy.Policies[f.pm.Name()]; ok && len(policy.SkipCommands) > 0 {
|
||||
if packagemanager.IsFirstNonFlagArgInList(parsedCmd.Command.Args, policy.SkipCommands) {
|
||||
log.Debugf("Skipping proxy for user-defined skip command")
|
||||
// When install_only is enabled, skip proxy for known non-download commands
|
||||
// and user-defined skip commands
|
||||
if cfg.Config.Proxy.InstallOnly {
|
||||
if !parsedCmd.MayDownloadPackages() {
|
||||
log.Debugf("Skipping proxy for non-download command (install_only=true)")
|
||||
return runner.Execute(ctx, parsedCmd, f.pm.Name(), cfg.DryRun)
|
||||
}
|
||||
|
||||
if cmds, ok := cfg.Config.Proxy.SkipCommands[f.pm.Name()]; ok && len(cmds) > 0 {
|
||||
if packagemanager.IsFirstNonFlagArgInList(parsedCmd.Command.Args, cmds) {
|
||||
log.Debugf("Skipping proxy for user-defined skip command (install_only=true)")
|
||||
return runner.Execute(ctx, parsedCmd, f.pm.Name(), cfg.DryRun)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize report data at the start
|
||||
|
||||
Reference in New Issue
Block a user