Files
threshold/internal/cmd/gencli/input.go
T
hashicorp-copywrite[bot]andJohan Brandhorst-Satzkorn 29da0bcb92 [COMPLIANCE] License changes (#3567)
* Adding explicit MPL license for sub-package.

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* Update copyright file headers to BUS-1.1

* Rerun make gen

This will pick up the last of the license changes

* Revert "Rerun make gen"

This reverts commit dbe0968bffd92745d8663c6940debae098395a6b.

* Remove copywrite from generation script

The current version of copywrite is not sophisticated enough
to only apply the copywrite changes to certain subdirectories,
so to avoid accidentally relicensing our api and sdk modules,
we will stop running the copywrite script until such time
that it can do the right thing.

* License protobuf API as MPL

The protobuf API files are used to generate the SDK,
since we want the SDK to be MPL, the protobuf files
must also be MPL. This extends to all protobuf files
whose sources end up in the SDK directory, including:

- internal/proto/controller/api
- internal/proto/controller/custom_options
- internal/proto/plugin

It also includes the generated service directory in
internal/gen/controller/api/services, since they are
generated from the protobuf sources used for the SDK.

* Change website license file name

This makes the naming scheme consistent with the rest
of the repository.

* Add note on licensing to README

* Set copywrite license to BUSL

* Revert "Add note on licensing to README"

This reverts commit 4d865a91a7a4f11605f0dc4609355d7e3c3cfffe.

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-08-11 10:31:53 -07:00

702 lines
22 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package main
import (
"github.com/hashicorp/boundary/internal/types/resource"
)
type cmdInfo struct {
// The type of the resource, e.g. "target"
ResourceType string
// The API package under the api path
Pkg string
// Standard actions (with standard parameters) used by this resource
StdActions []string
// HasExtraCommandVars controls whether to generate an embedded struct with
// extra command variables
HasExtraCommandVars bool
// SkipNormalHelp indicates skipping the normal help case for when it needs
// to be only custom (mainly for subactions)
SkipNormalHelp bool
// HasExtraHelpFunc controls whether to include a default statement chaining
// to an extra help function
HasExtraHelpFunc bool
// HasExampleCliOutput controls whether to generate code to look for a CLI
// output env var and print
HasExampleCliOutput bool
// HasId controls whether to add ID emptiness checking. Note that some
// commands that allow name/scope id or name/scope name handling may skip
// this in favor of custom logic.
HasId bool
// Container controls what to generate for a required container (scope ID,
// auth method ID, etc.)
Container string
// HasName controls whether to add name options
HasName bool
// HasDescription controls whether to add description options
HasDescription bool
// HasScopeName controls whether to add scope name options
HasScopeName bool
// VersionedActions controls which actions to add a case for version checking
VersionedActions []string
// SubActionPrefix specifies the prefix to use when generating sub-action
// commands (e.g. "targets update tcp")
SubActionPrefix string
// NeedsSubtypeInCreate controls whether the sub-type must be passed in as
// an argument to a create call. Targets need this, accounts do not, etc.
NeedsSubtypeInCreate bool
// PrefixAttributeFieldErrorsWithSubactionPrefix will prepend the value in
// SubActionPrefix when reporting errors which are reported in flag format.
// This allows the flags to be defined differently from the the attribute
// names in the API.
PrefixAttributeFieldErrorsWithSubactionPrefix bool
// HasGenericAttributes controls whether to generate flags for -attributes,
// -attr, -string-attr, etc.
HasGenericAttributes bool
// HasGenericSecrets controls whether to generate flags for -secrets,
// -secret, -string-secret, etc.
HasGenericSecrets bool
// HasJsonObject controls whether to generate flags for -object,
// -kv, -string-kv, -bool-kv, -num-kv.
HasJsonObject bool
// IsPluginType controls whether standard plugin flags are generated
IsPluginType bool
// SkipClientCallActions allows skipping creation of an actual client
// call for an action in favor of custom logic in extra actions
SkipClientCallActions []string
SkipFiltering bool
}
var inputStructs = map[string][]*cmdInfo{
"accounts": {
{
ResourceType: resource.Account.String(),
Pkg: "accounts",
StdActions: []string{"read", "delete", "list"},
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
Container: "AuthMethod",
HasId: true,
HasName: true,
HasDescription: true,
VersionedActions: []string{"change-password", "set-password"},
},
{
ResourceType: resource.Account.String(),
Pkg: "accounts",
StdActions: []string{"create", "update"},
SubActionPrefix: "password",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "AuthMethod",
HasDescription: true,
VersionedActions: []string{"update"},
},
{
ResourceType: resource.Account.String(),
Pkg: "accounts",
StdActions: []string{"create", "update"},
SubActionPrefix: "oidc",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "AuthMethod",
HasDescription: true,
VersionedActions: []string{"update"},
},
{
ResourceType: resource.Account.String(),
Pkg: "accounts",
StdActions: []string{"create", "update"},
SubActionPrefix: "ldap",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "AuthMethod",
HasDescription: true,
VersionedActions: []string{"update"},
},
},
"authmethods": {
{
ResourceType: resource.AuthMethod.String(),
Pkg: "authmethods",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "Scope",
HasId: true,
},
{
ResourceType: resource.AuthMethod.String(),
Pkg: "authmethods",
StdActions: []string{"create", "update"},
SubActionPrefix: "password",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
},
{
ResourceType: resource.AuthMethod.String(),
Pkg: "authmethods",
StdActions: []string{"create", "update"},
SubActionPrefix: "oidc",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"update", "change-state"},
NeedsSubtypeInCreate: true,
},
{
ResourceType: resource.AuthMethod.String(),
Pkg: "authmethods",
StdActions: []string{"create", "update"},
SubActionPrefix: "ldap",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
},
},
"authtokens": {
{
ResourceType: resource.AuthToken.String(),
Pkg: "authtokens",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "Scope",
},
},
"credentialstores": {
{
ResourceType: resource.CredentialStore.String(),
Pkg: "credentialstores",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "Scope",
HasId: true,
},
{
ResourceType: resource.CredentialStore.String(),
Pkg: "credentialstores",
StdActions: []string{"create", "update"},
SubActionPrefix: "vault",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
{
ResourceType: resource.CredentialStore.String(),
Pkg: "credentialstores",
StdActions: []string{"create", "update"},
SubActionPrefix: "static",
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
},
"credentiallibraries": {
{
ResourceType: resource.CredentialLibrary.String(),
Pkg: "credentiallibraries",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "CredentialStore",
HasId: true,
},
{
ResourceType: resource.CredentialLibrary.String(),
Pkg: "credentiallibraries",
StdActions: []string{"create", "update"},
SubActionPrefix: "vault",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
NeedsSubtypeInCreate: true,
Container: "CredentialStore",
VersionedActions: []string{"update"},
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
{
ResourceType: resource.CredentialLibrary.String(),
Pkg: "credentiallibraries",
StdActions: []string{"create", "update"},
SubActionPrefix: "vault-generic",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
NeedsSubtypeInCreate: true,
Container: "CredentialStore",
VersionedActions: []string{"update"},
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
{
ResourceType: resource.CredentialLibrary.String(),
Pkg: "credentiallibraries",
StdActions: []string{"create", "update"},
SubActionPrefix: "vault-ssh-certificate",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
NeedsSubtypeInCreate: true,
Container: "CredentialStore",
VersionedActions: []string{"update"},
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
},
"credentials": {
{
ResourceType: resource.Credential.String(),
Pkg: "credentials",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "CredentialStore",
HasId: true,
},
{
ResourceType: resource.Credential.String(),
Pkg: "credentials",
StdActions: []string{"create", "update"},
SubActionPrefix: "username_password",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "CredentialStore",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
{
ResourceType: resource.Credential.String(),
Pkg: "credentials",
StdActions: []string{"create", "update"},
SubActionPrefix: "ssh_private_key",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "CredentialStore",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
},
{
ResourceType: resource.Credential.String(),
Pkg: "credentials",
StdActions: []string{"create", "update"},
SubActionPrefix: "json",
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "CredentialStore",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
PrefixAttributeFieldErrorsWithSubactionPrefix: true,
HasJsonObject: true,
},
},
"groups": {
{
ResourceType: resource.Group.String(),
Pkg: "groups",
StdActions: []string{"create", "read", "update", "delete", "list"},
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
HasId: true,
Container: "Scope",
HasName: true,
HasDescription: true,
VersionedActions: []string{"update", "add-members", "remove-members", "set-members"},
},
},
"hostcatalogs": {
{
ResourceType: resource.HostCatalog.String(),
Pkg: "hostcatalogs",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "Scope",
HasId: true,
},
{
ResourceType: resource.HostCatalog.String(),
Pkg: "hostcatalogs",
StdActions: []string{"create", "update"},
SubActionPrefix: "static",
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
},
{
ResourceType: resource.HostCatalog.String(),
Pkg: "hostcatalogs",
StdActions: []string{"create", "update"},
SubActionPrefix: "plugin",
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
IsPluginType: true,
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
HasGenericAttributes: true,
HasGenericSecrets: true,
},
},
"hostsets": {
{
ResourceType: resource.HostSet.String(),
Pkg: "hostsets",
StdActions: []string{"read", "delete", "list"},
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
Container: "HostCatalog",
HasId: true,
HasName: true,
HasDescription: true,
VersionedActions: []string{"add-hosts", "set-hosts", "remove-hosts"},
},
{
ResourceType: resource.HostSet.String(),
Pkg: "hostsets",
StdActions: []string{"create", "update"},
SubActionPrefix: "static",
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "HostCatalog",
HasDescription: true,
VersionedActions: []string{"update"},
},
{
ResourceType: resource.HostSet.String(),
Pkg: "hostsets",
StdActions: []string{"create", "update"},
SubActionPrefix: "plugin",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "HostCatalog",
HasDescription: true,
HasGenericAttributes: true,
VersionedActions: []string{"update"},
},
},
"hosts": {
{
ResourceType: resource.Host.String(),
Pkg: "hosts",
StdActions: []string{"read", "delete", "list"},
HasExtraHelpFunc: true,
Container: "HostCatalog",
HasId: true,
HasName: true,
HasDescription: true,
},
{
ResourceType: resource.Host.String(),
Pkg: "hosts",
StdActions: []string{"create", "update"},
SubActionPrefix: "static",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "HostCatalog",
HasDescription: true,
VersionedActions: []string{"update"},
},
},
"managedgroups": {
{
ResourceType: resource.ManagedGroup.String(),
Pkg: "managedgroups",
StdActions: []string{"read", "delete", "list"},
Container: "AuthMethod",
HasId: true,
HasName: true,
HasDescription: true,
},
{
ResourceType: resource.ManagedGroup.String(),
Pkg: "managedgroups",
StdActions: []string{"create", "update"},
SubActionPrefix: "oidc",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "AuthMethod",
HasDescription: true,
VersionedActions: []string{"update"},
},
{
ResourceType: resource.ManagedGroup.String(),
Pkg: "managedgroups",
StdActions: []string{"create", "update"},
SubActionPrefix: "ldap",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "AuthMethod",
HasDescription: true,
VersionedActions: []string{"update"},
},
},
"roles": {
{
ResourceType: resource.Role.String(),
Pkg: "roles",
StdActions: []string{"create", "read", "update", "delete", "list"},
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
HasId: true,
Container: "Scope",
HasName: true,
HasDescription: true,
VersionedActions: []string{"update", "add-grants", "remove-grants", "set-grants", "add-principals", "remove-principals", "set-principals"},
},
},
"scopes": {
{
ResourceType: resource.Scope.String(),
Pkg: "scopes",
StdActions: []string{"create", "read", "update", "delete", "list"},
HasExtraCommandVars: true,
HasId: true,
Container: "Scope",
HasName: true,
HasDescription: true,
VersionedActions: []string{"update"},
},
},
"sessions": {
{
ResourceType: resource.Session.String(),
Pkg: "sessions",
StdActions: []string{"read", "list"},
Container: "Scope",
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
HasId: true,
VersionedActions: []string{"cancel"},
},
},
"sessionrecordings": {
{
ResourceType: resource.SessionRecording.String(),
Pkg: "sessionrecordings",
StdActions: []string{"read", "list"},
Container: "Scope",
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
HasId: true,
SkipFiltering: true,
},
},
"storagebuckets": {
{
ResourceType: resource.StorageBucket.String(),
Pkg: "storagebuckets",
StdActions: []string{"create", "update", "read", "delete", "list"},
HasExtraHelpFunc: true,
HasExtraCommandVars: true,
HasId: true,
HasName: true,
HasDescription: true,
Container: "Scope",
IsPluginType: true,
VersionedActions: []string{"update"},
HasGenericAttributes: true,
HasGenericSecrets: true,
},
},
"targets": {
{
ResourceType: resource.Target.String(),
Pkg: "targets",
StdActions: []string{"read", "delete", "list"},
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
HasExampleCliOutput: true,
HasName: true,
HasDescription: true,
Container: "Scope",
VersionedActions: []string{"add-host-sources", "remove-host-sources", "set-host-sources", "add-credential-sources", "remove-credential-sources", "set-credential-sources"},
},
{
ResourceType: resource.Target.String(),
Pkg: "targets",
StdActions: []string{"create", "update"},
SubActionPrefix: "tcp",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "Scope",
HasDescription: true,
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
},
{
ResourceType: resource.Target.String(),
Pkg: "targets",
StdActions: []string{"create", "update"},
SubActionPrefix: "ssh",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "Scope",
HasDescription: true,
VersionedActions: []string{"update"},
NeedsSubtypeInCreate: true,
},
},
"users": {
{
ResourceType: resource.User.String(),
Pkg: "users",
StdActions: []string{"create", "read", "update", "delete", "list"},
HasExtraCommandVars: true,
HasExtraHelpFunc: true,
HasId: true,
Container: "Scope",
HasName: true,
HasDescription: true,
VersionedActions: []string{"update", "add-accounts", "remove-accounts", "set-accounts"},
},
},
"workers": {
{
ResourceType: resource.Worker.String(),
Pkg: "workers",
StdActions: []string{"read", "update", "delete", "list"},
HasExtraHelpFunc: true,
HasId: true,
Container: "Scope",
HasName: true,
HasDescription: true,
VersionedActions: []string{"update", "add-worker-tags", "set-worker-tags", "remove-worker-tags"},
},
{
ResourceType: resource.Worker.String(),
Pkg: "workers",
StdActions: []string{"create"},
SubActionPrefix: "worker-led",
HasExtraCommandVars: true,
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "Scope",
HasDescription: true,
NeedsSubtypeInCreate: true,
SkipClientCallActions: []string{"create"},
},
{
ResourceType: resource.Worker.String(),
Pkg: "workers",
StdActions: []string{"create"},
SubActionPrefix: "controller-led",
SkipNormalHelp: true,
HasExtraHelpFunc: true,
HasId: true,
HasName: true,
Container: "Scope",
HasDescription: true,
NeedsSubtypeInCreate: true,
SkipClientCallActions: []string{"create"},
},
},
}