Files
archie/internal/domain/storepkg/tool_permissions.go
T

22 lines
527 B
Go

package storepkg
import "slices"
// AllowedTools intersects a profile's tools with accepted package authority.
// Nil means unrestricted; a non-nil empty slice means no tools.
func AllowedTools(profile []string, packaged bool, accepted []string) []string {
if !packaged {
if len(profile) == 0 {
return nil
}
return slices.Clone(profile)
}
allowed := []string{}
for _, name := range accepted {
if len(profile) == 0 || slices.Contains(profile, name) {
allowed = append(allowed, name)
}
}
return allowed
}