github.com/fastly/cli@v1.7.2-0.20240304164155-9d0f1d77c3bf/pkg/errors/errors.go (about)

     1  package errors
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  // ErrSignalInterrupt means a SIGINT was received.
     9  var ErrSignalInterrupt = fmt.Errorf("a SIGINT was received")
    10  
    11  // ErrSignalKilled means a SIGTERM was received.
    12  var ErrSignalKilled = fmt.Errorf("a SIGTERM was received")
    13  
    14  // ErrViceroyRestart means the viceroy binary needs to be restarted due to a
    15  // file modification noticed while running `compute serve --watch`.
    16  var ErrViceroyRestart = fmt.Errorf("a RESTART was initiated")
    17  
    18  // ErrDontContinue means the user said "NO" when prompted whether to continue.
    19  var ErrDontContinue = fmt.Errorf("will not continue")
    20  
    21  // ErrIncompatibleServeFlags means no --skip-build can't be used with --watch
    22  // because it defeats the purpose of --watch which is designed to restart
    23  // Viceroy whenever changes are detected (those changes would not be seen if we
    24  // allowed --skip-build with --watch).
    25  var ErrIncompatibleServeFlags = RemediationError{
    26  	Inner:       fmt.Errorf("--skip-build shouldn't be used with --watch"),
    27  	Remediation: ComputeServeRemediation,
    28  }
    29  
    30  // ErrNoToken means no --token has been provided.
    31  var ErrNoToken = RemediationError{
    32  	Inner:       fmt.Errorf("no token provided"),
    33  	Remediation: AuthRemediation,
    34  }
    35  
    36  // ErrNoServiceID means no --service-id or service_id fastly.toml value has
    37  // been provided.
    38  var ErrNoServiceID = RemediationError{
    39  	Inner:       fmt.Errorf("error reading service: no service ID found"),
    40  	Remediation: ServiceIDRemediation,
    41  }
    42  
    43  // ErrNoCustomerID means no --customer-id or FASTLY_CUSTOMER_ID environment
    44  // variable found.
    45  var ErrNoCustomerID = RemediationError{
    46  	Inner:       fmt.Errorf("error reading customer ID: no customer ID found"),
    47  	Remediation: CustomerIDRemediation,
    48  }
    49  
    50  // ErrMissingManifestVersion means an invalid manifest (fastly.toml) has been used.
    51  var ErrMissingManifestVersion = RemediationError{
    52  	Inner:       fmt.Errorf("no manifest_version found in the fastly.toml"),
    53  	Remediation: BugRemediation,
    54  }
    55  
    56  // ErrUnrecognisedManifestVersion means an invalid manifest (fastly.toml)
    57  // version has been specified.
    58  var ErrUnrecognisedManifestVersion = RemediationError{
    59  	Inner:       fmt.Errorf("unrecognised manifest_version found in the fastly.toml"),
    60  	Remediation: UnrecognisedManifestVersionRemediation,
    61  }
    62  
    63  // ErrIncompatibleManifestVersion means the manifest_version defined is no
    64  // longer compatible with the current CLI version.
    65  var ErrIncompatibleManifestVersion = RemediationError{
    66  	Inner:       fmt.Errorf("the fastly.toml contains an incompatible manifest_version number"),
    67  	Remediation: "Update the `manifest_version` in the fastly.toml and refer to https://developer.fastly.com/reference/compute/fastly-toml/ for changes to the manifest structure",
    68  }
    69  
    70  // ErrNoID means no --id value has been provided.
    71  var ErrNoID = RemediationError{
    72  	Inner:       fmt.Errorf("no ID found"),
    73  	Remediation: IDRemediation,
    74  }
    75  
    76  // ErrReadingManifest means there was a problem reading the fastly.toml.
    77  var ErrReadingManifest = RemediationError{
    78  	Inner:       fmt.Errorf("error reading fastly.toml"),
    79  	Remediation: "Ensure the Fastly CLI is being run within a directory containing a fastly.toml file. " + ComputeInitRemediation,
    80  }
    81  
    82  // ErrParsingManifest means there was a problem unmarshalling the fastly.toml.
    83  var ErrParsingManifest = RemediationError{
    84  	Inner:       fmt.Errorf("error parsing fastly.toml"),
    85  	Remediation: ComputeInitRemediation,
    86  }
    87  
    88  // ErrStopWalk is used to indicate to filepath.WalkDir that it should stop
    89  // walking the directory tree.
    90  var ErrStopWalk = errors.New("stop directory walking")
    91  
    92  // ErrInvalidArchive means the package archive didn't contain a recognised
    93  // directory structure.
    94  var ErrInvalidArchive = RemediationError{
    95  	Inner:       fmt.Errorf("invalid package archive structure"),
    96  	Remediation: "Ensure the archive contains all required package files (such as a 'fastly.toml' manifest, and a 'src' folder etc).",
    97  }
    98  
    99  // ErrPostInitStopped means the user stopped the init process because they were
   100  // unhappy with the custom post_init defined in the fastly.toml manifest file.
   101  var ErrPostInitStopped = RemediationError{
   102  	Inner:       fmt.Errorf("init process stopped by user"),
   103  	Remediation: "Check the [scripts.post_init] in the fastly.toml manifest is safe to execute or skip this prompt using either `--auto-yes` or `--non-interactive`.",
   104  }
   105  
   106  // ErrPostBuildStopped means the user stopped the build because they were unhappy
   107  // with the custom build defined in the fastly.toml manifest file.
   108  var ErrPostBuildStopped = RemediationError{
   109  	Inner:       fmt.Errorf("build process stopped by user"),
   110  	Remediation: "Check the [scripts.post_build] in the fastly.toml manifest is safe to execute or skip this prompt using either `--auto-yes` or `--non-interactive`.",
   111  }
   112  
   113  // ErrInvalidVerboseJSONCombo means the user provided both a --verbose and
   114  // --json flag which are mutually exclusive behaviours.
   115  var ErrInvalidVerboseJSONCombo = RemediationError{
   116  	Inner:       fmt.Errorf("invalid flag combination, --verbose and --json"),
   117  	Remediation: "Use either --verbose or --json, not both.",
   118  }
   119  
   120  // ErrInvalidDeleteAllJSONKeyCombo means the user provided both a --all and
   121  // --json flag which are mutually exclusive behaviours.
   122  var ErrInvalidDeleteAllJSONKeyCombo = RemediationError{
   123  	Inner:       fmt.Errorf("invalid flag combination, --all and --json"),
   124  	Remediation: "Use either --all or --json, not both.",
   125  }
   126  
   127  // ErrInvalidDeleteAllKeyCombo means the user provided both a --all and --key
   128  // flag which are mutually exclusive behaviours.
   129  var ErrInvalidDeleteAllKeyCombo = RemediationError{
   130  	Inner:       fmt.Errorf("invalid flag combination, --all and --key"),
   131  	Remediation: "Use either --all or --key, not both.",
   132  }
   133  
   134  // ErrMissingDeleteAllKeyCombo means the user omitted both the --all and --key
   135  // flags and we need at least one of them.
   136  var ErrMissingDeleteAllKeyCombo = RemediationError{
   137  	Inner:       fmt.Errorf("invalid command, neither --all or --key provided"),
   138  	Remediation: "Provide at least one of: --all or --key, not both.",
   139  }
   140  
   141  // ErrNoSTDINData indicates the --stdin flag was specified but no data was piped
   142  // into stdin.
   143  var ErrNoSTDINData = RemediationError{
   144  	Inner:       fmt.Errorf("unable to read from STDIN"),
   145  	Remediation: "Provide data to STDIN, or use --file to read from a file",
   146  }
   147  
   148  // ErrInvalidKVCombo means the user omitted either the key or value flag.
   149  var ErrInvalidKVCombo = RemediationError{
   150  	Inner:       fmt.Errorf("--key-name and --value are required"),
   151  	Remediation: "Please add both flags or alternatively use either --stdin or --file.",
   152  }
   153  
   154  // ErrInvalidStdinFileDirCombo means the user provided more than one of --stdin,
   155  // --file or --dir flags, which are mutally exclusive behaviours.
   156  var ErrInvalidStdinFileDirCombo = RemediationError{
   157  	Inner:       fmt.Errorf("invalid flag combination"),
   158  	Remediation: "Use only one of --stdin, --file or --dir.",
   159  }
   160  
   161  // ErrInvalidProfileSSOCombo means the user specified both --sso and
   162  // --automation-token and only one should be set.
   163  var ErrInvalidProfileSSOCombo = RemediationError{
   164  	Inner:       fmt.Errorf("invalid command, both --sso and --automation-token provided"),
   165  	Remediation: "Provide at only one of: --sso or --automation-token, not both.",
   166  }
   167  
   168  // ErrInvalidEnableDisableFlagCombo means the user provided both a --enable
   169  // and --disable flag which are mutually exclusive behaviours.
   170  var ErrInvalidEnableDisableFlagCombo = RemediationError{
   171  	Inner:       fmt.Errorf("invalid flag combination: --enable and --disable"),
   172  	Remediation: "Use either --enable or --disable, not both.",
   173  }