You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to configure depguard to prevent introduction of additional packages from a dependencies in our project (https://github.com/containerd/containerd), but so far I haven't found a good way to construct this in golangci-lint's configuration. It's very possible that I just didin't find the right combination, so let me try to describe our case;
We currently depend on the libcontainer/user package from runc (github.com/opencontainers/runc/libcontainer/user), want to prevent additional packages being used from that depository (libcontainer should only be used for existing code, and not for new things).
The containerd maintainers have put effort into moving away from libcontainer dependencies, with the exception of the libcontainer/user package (which is pending to be moved to a separate module).
We want to use depguard to prevent accidentally re-introducing further (indirect) dependencies from runc, and want to "deny" all of github.com/opencontainers/runc, with the exeception of the existing libcontainer/user package.
My initial attempt was to create a rule that denies all of github.com/opencontainers/runc, and allowsgithub.com/opencontainers/runc/libcontainer/user;
linters-settings:
depguard:
rules:
libcontainer:
allow:
- "github.com/opencontainers/runc/libcontainer/user$"deny:
- pkg: github.com/opencontainers/runcdesc: We don't want to introduce more dependencies on runc (libcontainer), unless there is no other option.
Unfortunately, this doesn't work, because (IIUC);
rules with a deny list default "allow all"
unless an allow is configured, in which case only packages in the allow list are accepted (and are not part of the deny list
While there is a convenience variable for stdlib ($gostd), there is no equivalent for "all" dependencies (the default), and because our project has many dependencies; constructing a list of all allowed (existing) packages would result in a very long (and hard to maintain) configuration.
Likewise, a deny list for the github.com/opencontainers/runc dependency (and anything inside it) is also hard to maintain, as it would require us to maintain a full list of all packages in the repository (to prevent missing any new package added to that repository). To illustrate; this is what that would look like just for the libcontainer package in runc;
I am trying to configure depguard to prevent introduction of additional packages from a dependencies in our project (https://github.com/containerd/containerd), but so far I haven't found a good way to construct this in golangci-lint's configuration. It's very possible that I just didin't find the right combination, so let me try to describe our case;
We currently depend on the
libcontainer/user
package from runc (github.com/opencontainers/runc/libcontainer/user
), want to prevent additional packages being used from that depository (libcontainer
should only be used for existing code, and not for new things).The containerd maintainers have put effort into moving away from
libcontainer
dependencies, with the exception of thelibcontainer/user
package (which is pending to be moved to a separate module).We want to use
depguard
to prevent accidentally re-introducing further (indirect) dependencies fromrunc
, and want to "deny" all ofgithub.com/opencontainers/runc
, with the exeception of the existinglibcontainer/user
package.My initial attempt was to create a rule that denies all of
github.com/opencontainers/runc
, and allowsgithub.com/opencontainers/runc/libcontainer/user
;Unfortunately, this doesn't work, because (IIUC);
deny
list default "allow all"allow
is configured, in which case only packages in theallow
list are accepted (and are not part of thedeny
listWhile there is a convenience variable for stdlib (
$gostd
), there is no equivalent for "all" dependencies (the default), and because our project has many dependencies; constructing a list of all allowed (existing) packages would result in a very long (and hard to maintain) configuration.Likewise, a
deny
list for thegithub.com/opencontainers/runc
dependency (and anything inside it) is also hard to maintain, as it would require us to maintain a full list of all packages in the repository (to prevent missing any new package added to that repository). To illustrate; this is what that would look like just for thelibcontainer
package in runc;Perhaps I overlooked existing ones! So if there are options I overlooked, I'm "all ears" 😄
The text was updated successfully, but these errors were encountered: