github.com/Venafi/vcert/v5@v5.10.2/pkg/playbook/app/domain/error.go (about)

     1  /*
     2   * Copyright 2023 Venafi, Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *  http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package domain
    18  
    19  import "fmt"
    20  
    21  var (
    22  	// ErrNoConfig is thrown when the Playbook has no config section
    23  	ErrNoConfig = fmt.Errorf("no config found on playbook")
    24  	// ErrNoTasks is thrown when the Playbook has no certificateTasks section
    25  	ErrNoTasks = fmt.Errorf("no certificate tasks found on playbook")
    26  	// ErrNoInstallations is thrown when any task (item in Certificates section) has no installations defined
    27  	ErrNoInstallations = fmt.Errorf("no installations found on certificate task")
    28  
    29  	// ErrNoRequestZone is thrown when a certificate request is specified without a zone
    30  	ErrNoRequestZone = fmt.Errorf("request.zone is required and was not found")
    31  	// ErrNoRequestCN si thrown when a certificate request does not contain subject.CommonName
    32  	ErrNoRequestCN = fmt.Errorf("request.subject.commonName is required and was not found")
    33  
    34  	// ErrNoCredentials is thrown when the Playbook has no config section
    35  	ErrNoCredentials = fmt.Errorf("no credentials defined on playbook")
    36  	// ErrMultipleCredentials is thrown when the config.credentials section has both apikey and accessToken declared
    37  	ErrMultipleCredentials = fmt.Errorf("credentials for multiple platforms set. Only one of ApiKey or AccessToken/RefreshToken pair should be declared")
    38  	// ErrNoTPPURL is thrown when accessToken and/or refreshToken are declared in config.credentials but no url is specified
    39  	ErrNoTPPURL = fmt.Errorf("no url defined. TPP platform requires an url to the TPP instance")
    40  	// ErrTrustBundleNotExist is thrown when config.trustBundle is set but the path does not exist or cannot be read
    41  	ErrTrustBundleNotExist = fmt.Errorf("trustBundle path does not exist")
    42  
    43  	// ErrNoJKSAlias is thrown when certificates.installations[].type is JKS but no jksAlias is set
    44  	ErrNoJKSAlias = fmt.Errorf("jksAlias should not be empty when installing a certificate in JKS format")
    45  	// ErrNoJKSPassword is thrown when certificates.installations[].type is JKS but no jksPassword is set
    46  	ErrNoJKSPassword = fmt.Errorf("jksPassword should not be empty when installing a certificate in JKS format")
    47  	// ErrJKSPasswordLength is thrown when certificates.installations[].type is JKS but the jksPassword length is shorter than the minimum required
    48  	ErrJKSPasswordLength = fmt.Errorf("jksPassword must be at least 6 characters long")
    49  	// ErrKeyPasswordLength is thrown when certificates.installations[].type is JKS but the keyPassword length is shorter than the minimum required
    50  	ErrKeyPasswordLength = fmt.Errorf("keyPassword must be at least 6 characters long")
    51  
    52  	// ErrNoP12Password is thrown when certificates.installations[].type is JKS but no jksPassword is set
    53  	ErrNoP12Password = fmt.Errorf("p12Password should not be empty when installing a certificate in PKCS12 format")
    54  
    55  	// ErrNoChainFile is thrown when certificates.installations[].type is PEM but no pemChainFilename is set
    56  	ErrNoChainFile = fmt.Errorf("chainFile should not be empty when installing a certificate in PEM format")
    57  	// ErrNoKeyFile is thrown when certificates.installations[].type is PEM but no pemKeyFilename is set
    58  	ErrNoKeyFile = fmt.Errorf("keyFile should not be empty when installing a certificate in PEM format")
    59  
    60  	// ErrUndefinedInstallationFormat is thrown when certificates.installations[].type is unknown
    61  	ErrUndefinedInstallationFormat = fmt.Errorf("unknown installation format specified")
    62  	// ErrNoInstallationFile is thrown when certificates.installations[].File is not set
    63  	ErrNoInstallationFile = fmt.Errorf("installation file not specified")
    64  
    65  	// ErrCAPIOnNonWindows is thrown when certificates.installations[].type is CAPI but running on a non-windows build
    66  	ErrCAPIOnNonWindows = fmt.Errorf("unable to specify CAPI installation type on non-windows system")
    67  	// ErrNoCAPILocation is thrown when certificates.installations[].format is CAPI but certificates.installations[].location is not set
    68  	ErrNoCAPILocation = fmt.Errorf("CAPI installation location not specified")
    69  	// ErrMalformedCAPILocation is thrown when certificates.installations[].type is CAPI but the location is malformed
    70  	ErrMalformedCAPILocation = fmt.Errorf("invalid CAPI location. Should be in form of 'StoreLocation\\StoreName' (i.e. 'LocalMachine\\My')")
    71  	// ErrInvalidCAPILocation is thrown when certificates.installations[].type is CAPI but the location is malformed
    72  	ErrInvalidCAPILocation = fmt.Errorf("invalid CAPI location. Should be either 'LocalMachine' or 'CurrentUser' (i.e. 'LocalMachine\\My')")
    73  	// ErrInvalidCAPIStoreName is thrown when certificates.installations[].type is CAPI but the location is malformed
    74  	ErrInvalidCAPIStoreName = fmt.Errorf("invalid CAPI store name. Should contain a valid storeName after the '\\' (i.e. 'LocalMachine\\My')")
    75  	// WarningLocationFieldDeprecated is thrown when certificates.installations[].type is CAPI but the deprecated location field is set
    76  	WarningLocationFieldDeprecated = "location field is deprecated and will be removed in a future release. Use capiLocation instead"
    77  	// WarningNoCAPIFriendlyName is thrown when certificates.installations[].type is CAPI but no friendlyName is set
    78  	WarningNoCAPIFriendlyName = "no capiFriendlyName defined. It is strongly recommended to define a " +
    79  		"capiFriendlyName for CAPI installation type. This will become required in a future release"
    80  
    81  	// ErrNoFireflyURL is thrown when platform is Firefly but no url is specified inf config.credentials
    82  	ErrNoFireflyURL = fmt.Errorf("no url defined. Firefly platform requires an url to the Firefly instance")
    83  	// ErrNoClientId is thrown when platform is Firefly and no config.credentials.clientId is defined
    84  	ErrNoClientId = fmt.Errorf("no cliendId defined. Firefly platform requires a clientId to request OAuth2 token")
    85  	// ErrNoIdentityProviderURL is thrown when platform is Firefly and no config.credentials.tokenURL is defined to request an OAuth2 Token
    86  	ErrNoIdentityProviderURL = fmt.Errorf("no tokenURL defined in credentials. tokenURL is required to request OAuth2 token")
    87  	// ErrNoExternalJWT is thrown when platform is TLSPC/VAAS/VCP, a tokenURL has been passed but no config.credentials.ExternalJWT is set
    88  	ErrNoExternalJWT = fmt.Errorf("no externalJWT defined in credentials. externalJWT and tokenURL are both required to request an access token from VCP")
    89  	// ErrNoVaaSTokenURL is thrown when platform is TLSPC/VAAS/VCP, an externaJWT has been provided, but no config.credentials.TokenURL has been passed
    90  	ErrNoVCPTokenURL = fmt.Errorf("no tokenURL defined in credentials. tokenURL and externalJWT are both required to request an access token from VCP when using an externalJWT")
    91  	// ErrAmbiguousVCPCreds is thrown when platform is TLSPC/VAAS/VCP, and more than one type (apiKey, accessToken, or externalJWT) was provided
    92  	ErrAmbiguousVCPCreds = fmt.Errorf("unable to disambiguate multiple VCP credentials. Only ONE of apiKey, accessToken, or tokenURL WITH externalJWT should be defined")
    93  )