Files
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

87 lines
2.4 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package managedgroupscmd
import (
"fmt"
"repo.anhonesthost.net/CyberCoveLLC/threshold/api/managedgroups"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/cmd/base"
)
const (
groupNamesFlagName = "group-names"
)
type extraLdapCmdVars struct {
flagGroupNames []string
}
func init() {
extraLdapFlagsFunc = extraLdapFlagsFuncImpl
extraLdapActionsFlagsMapFunc = extraLdapActionsFlagsMapFuncImpl
extraLdapFlagsHandlingFunc = extraLdapFlagsHandlingFuncImpl
}
func extraLdapActionsFlagsMapFuncImpl() map[string][]string {
return map[string][]string{
"create": {groupNamesFlagName},
"update": {groupNamesFlagName},
}
}
func (c *LdapCommand) extraLdapHelpFunc(helpMap map[string]func() string) string {
var helpStr string
switch c.Func {
case "create":
helpStr = base.WrapForHelpText([]string{
"Usage: threshold managed-groups create ldap [options] [args]",
"",
" Create a ldap-type managed group. Example:",
"",
` $ threshold managed-groups create ldap -group-names admin -description "Ldap managed group for ProdOps"`,
"",
"",
})
case "update":
helpStr = base.WrapForHelpText([]string{
"Usage: threshold managed-groups update ldap [options] [args]",
"",
" Update an ldap-type managed group given its ID. Example:",
"",
` $ threshold managed-groups update ldap -id acctldap_1234567890 -name "devops" -description "Ldap managed group for DevOps"`,
"",
"",
})
}
return helpStr + c.Flags().Help()
}
func extraLdapFlagsFuncImpl(c *LdapCommand, _ *base.FlagSets, f *base.FlagSet) {
for _, name := range flagsLdapMap[c.Func] {
switch name {
case groupNamesFlagName:
f.StringSliceVar(&base.StringSliceVar{
Name: groupNamesFlagName,
Target: &c.flagGroupNames,
Usage: "The LDAP group names against which an LDAP account's associated groups (discovered during login) will be evaluated to determine membership (required). May be specified multiple times",
})
}
}
}
func extraLdapFlagsHandlingFuncImpl(c *LdapCommand, _ *base.FlagSets, opts *[]managedgroups.Option) bool {
switch {
case len(c.flagGroupNames) == 0:
case len(c.flagGroupNames) == 1 && c.flagGroupNames[0] == "null":
c.UI.Error(fmt.Sprintf("There must be at least one %q", groupNamesFlagName))
return false
default:
*opts = append(*opts, managedgroups.WithLdapManagedGroupGroupNames(c.flagGroupNames))
}
return true
}