2020-08-13 11:20:22 -04:00
package common
import (
"fmt"
"github.com/hashicorp/boundary/internal/cmd/base"
2020-09-08 13:27:51 -07:00
"github.com/posener/complete"
2020-08-13 11:20:22 -04:00
)
2021-06-02 13:05:10 -05:00
func PopulateCommonFlags ( c * base . Command , f * base . FlagSet , resourceType string , flagNames map [ string ][] string , command string ) {
for _ , name := range flagNames [ command ] {
2020-08-13 11:20:22 -04:00
switch name {
2020-09-08 13:27:51 -07:00
case "scope-id" :
f . StringVar ( & base . StringVar {
Name : "scope-id" ,
Target : & c . FlagScopeId ,
2020-10-02 19:20:30 -04:00
EnvVar : "BOUNDARY_SCOPE_ID" ,
2020-09-08 13:27:51 -07:00
Default : "global" ,
Completion : complete . PredictAnything ,
2020-10-22 08:40:00 -04:00
Usage : `Scope in which to make the request.` ,
})
case "scope-name" :
f . StringVar ( & base . StringVar {
Name : "scope-name" ,
Target : & c . FlagScopeName ,
EnvVar : "BOUNDARY_SCOPE_NAME" ,
Completion : complete . PredictAnything ,
Usage : `Scope in which to make the request, identified by name.` ,
2020-09-08 13:27:51 -07:00
})
2020-08-13 11:20:22 -04:00
case "id" :
f . StringVar ( & base . StringVar {
Name : "id" ,
Target : & c . FlagId ,
2020-10-22 08:40:00 -04:00
Usage : fmt . Sprintf ( "ID of the %s on which to operate." , resourceType ),
2020-08-13 11:20:22 -04:00
})
case "name" :
f . StringVar ( & base . StringVar {
Name : "name" ,
Target : & c . FlagName ,
2020-10-22 08:40:00 -04:00
Usage : fmt . Sprintf ( "Name to set on the %s." , resourceType ),
2020-08-13 11:20:22 -04:00
})
case "description" :
f . StringVar ( & base . StringVar {
Name : "description" ,
Target : & c . FlagDescription ,
2020-10-22 08:40:00 -04:00
Usage : fmt . Sprintf ( "Description to set on the %s." , resourceType ),
2020-08-13 11:20:22 -04:00
})
case "version" :
f . IntVar ( & base . IntVar {
Name : "version" ,
Target : & c . FlagVersion ,
2020-08-18 17:46:34 -04:00
Usage : fmt . Sprintf ( "The version of the %s against which to perform an update operation. If not specified, the command will perform a check-and-set automatically." , resourceType ),
2020-08-13 11:20:22 -04:00
})
2020-10-02 19:20:30 -04:00
case "auth-method-id" :
f . StringVar ( & base . StringVar {
Name : "auth-method-id" ,
EnvVar : "BOUNDARY_AUTH_METHOD_ID" ,
Target : & c . FlagAuthMethodId ,
2020-10-22 08:40:00 -04:00
Usage : "The auth-method resource to use for the operation." ,
2020-10-02 19:20:30 -04:00
})
case "host-catalog-id" :
f . StringVar ( & base . StringVar {
Name : "host-catalog-id" ,
EnvVar : "BOUNDARY_HOST_CATALOG_ID" ,
Target : & c . FlagHostCatalogId ,
2020-10-22 08:40:00 -04:00
Usage : "The host-catalog resource to use for the operation." ,
2020-10-02 19:20:30 -04:00
})
2021-06-22 22:26:26 -04:00
case "credential-store-id" :
f . StringVar ( & base . StringVar {
Name : "credential-store-id" ,
EnvVar : "BOUNDARY_CREDENTIAL_STORE_ID" ,
Target : & c . FlagCredentialStoreId ,
Usage : "The credential-store resource to use for the operation." ,
})
2021-01-23 13:39:04 -05:00
case "recursive" :
f . BoolVar ( & base . BoolVar {
Name : "recursive" ,
Target : & c . FlagRecursive ,
Usage : "If set, the list operation will be applied recursively into child scopes, if supported by the type." ,
})
2021-06-02 13:05:10 -05:00
}
}
if command == "list" {
for _ , name := range flagNames [ command ] {
switch name {
case "filter" :
f . StringVar ( & base . StringVar {
Name : "filter" ,
Target : & c . FlagFilter ,
Usage : "If set, the list operation will be filtered before being returned. The filter operates against each item in the list. Using single quotes is recommended as filters contain double quotes. See https://www.boundaryproject.io/docs/concepts/filtering/resource-listing for details." ,
})
}
2020-08-13 11:20:22 -04:00
}
}
}