/config/shared/errors/errors.go

https://github.com/coreos/ignition · Go · 109 lines · 75 code · 11 blank · 23 comment · 0 complexity · dd054cc1a212165ca23529fc06e97624 MD5 · raw file

  1. // Copyright 2018 CoreOS, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Package errors includes errors that are used in multiple config versions
  15. package errors
  16. import (
  17. "errors"
  18. "fmt"
  19. )
  20. var (
  21. // Parsing / general errors
  22. ErrInvalid = errors.New("config is not valid")
  23. ErrEmpty = errors.New("not a config (empty)")
  24. ErrDuplicate = errors.New("duplicate entry defined")
  25. // Ignition section errors
  26. ErrInvalidVersion = errors.New("invalid config version (couldn't parse)")
  27. ErrUnknownVersion = errors.New("unsupported config version")
  28. ErrDeprecated = errors.New("config format deprecated")
  29. ErrCompressionInvalid = errors.New("invalid compression method")
  30. // Storage section errors
  31. ErrFileUsedSymlink = errors.New("file path includes link in config")
  32. ErrDirectoryUsedSymlink = errors.New("directory path includes link in config")
  33. ErrLinkUsedSymlink = errors.New("link path includes link in config")
  34. ErrHardLinkToDirectory = errors.New("hard link target is a directory")
  35. ErrDiskDeviceRequired = errors.New("disk device is required")
  36. ErrPartitionNumbersCollide = errors.New("partition numbers collide")
  37. ErrPartitionsOverlap = errors.New("partitions overlap")
  38. ErrPartitionsMisaligned = errors.New("partitions misaligned")
  39. ErrOverwriteAndNilSource = errors.New("overwrite must be false if source is unspecified")
  40. ErrVerificationAndNilSource = errors.New("source must be specified if verification is specified")
  41. ErrFilesystemInvalidFormat = errors.New("invalid filesystem format")
  42. ErrLabelNeedsFormat = errors.New("filesystem must specify format if label is specified")
  43. ErrFormatNilWithOthers = errors.New("format cannot be empty when path, label, uuid, or options are specified")
  44. ErrExt4LabelTooLong = errors.New("filesystem labels cannot be longer than 16 characters when using ext4")
  45. ErrBtrfsLabelTooLong = errors.New("filesystem labels cannot be longer than 256 characters when using btrfs")
  46. ErrXfsLabelTooLong = errors.New("filesystem labels cannot be longer than 12 characters when using xfs")
  47. ErrSwapLabelTooLong = errors.New("filesystem labels cannot be longer than 15 characters when using swap")
  48. ErrVfatLabelTooLong = errors.New("filesystem labels cannot be longer than 11 characters when using vfat")
  49. ErrLuksLabelTooLong = errors.New("luks device labels cannot be longer than 47 characters")
  50. ErrLuksNameContainsSlash = errors.New("device names cannot contain slashes")
  51. ErrInvalidLuksKeyFile = errors.New("invalid key-file source")
  52. ErrUnknownClevisPin = errors.New("unsupported clevis pin")
  53. ErrClevisConfigRequired = errors.New("missing required custom clevis config")
  54. ErrClevisCustomWithOthers = errors.New("cannot use custom clevis config with tpm2, tang, or threshold")
  55. ErrTangThumbprintRequired = errors.New("thumbprint is required")
  56. ErrFileIllegalMode = errors.New("illegal file mode")
  57. ErrBothIDAndNameSet = errors.New("cannot set both id and name")
  58. ErrLabelTooLong = errors.New("partition labels may not exceed 36 characters")
  59. ErrDoesntMatchGUIDRegex = errors.New("doesn't match the form \"01234567-89AB-CDEF-EDCB-A98765432101\"")
  60. ErrLabelContainsColon = errors.New("partition label will be truncated to text before the colon")
  61. ErrNoPath = errors.New("path not specified")
  62. ErrPathRelative = errors.New("path not absolute")
  63. ErrDirtyPath = errors.New("path is not fully simplified")
  64. ErrSparesUnsupportedForLevel = errors.New("spares unsupported for arrays with a level greater than 0")
  65. ErrUnrecognizedRaidLevel = errors.New("unrecognized raid level")
  66. ErrShouldNotExistWithOthers = errors.New("shouldExist specified false with other options also specified")
  67. ErrZeroesWithShouldNotExist = errors.New("shouldExist is false for a partition and other partition(s) has start or size 0")
  68. ErrNeedLabelOrNumber = errors.New("a partition number >= 1 or a label must be specified")
  69. ErrDuplicateLabels = errors.New("cannot use the same partition label twice")
  70. ErrInvalidProxy = errors.New("proxies must be http(s)")
  71. ErrInsecureProxy = errors.New("insecure plaintext HTTP proxy specified for HTTPS resources")
  72. // Systemd section errors
  73. ErrInvalidSystemdExt = errors.New("invalid systemd unit extension")
  74. ErrInvalidSystemdDropinExt = errors.New("invalid systemd drop-in extension")
  75. ErrNoSystemdExt = errors.New("no systemd unit extension")
  76. ErrInvalidInstantiatedUnit = errors.New("invalid systemd instantiated unit")
  77. // Misc errors
  78. ErrSourceRequired = errors.New("source is required")
  79. ErrInvalidScheme = errors.New("invalid url scheme")
  80. ErrInvalidUrl = errors.New("unable to parse url")
  81. ErrInvalidHTTPHeader = errors.New("unable to parse HTTP header")
  82. ErrEmptyHTTPHeaderName = errors.New("HTTP header name can't be empty")
  83. ErrUnsupportedSchemeForHTTPHeaders = errors.New("cannot use HTTP headers with this source scheme")
  84. ErrHashMalformed = errors.New("malformed hash specifier")
  85. ErrHashWrongSize = errors.New("incorrect size for hash sum")
  86. ErrHashUnrecognized = errors.New("unrecognized hash function")
  87. ErrEngineConfiguration = errors.New("engine incorrectly configured")
  88. // AWS S3 specific errors
  89. ErrInvalidS3ObjectVersionId = errors.New("invalid S3 object VersionId")
  90. // Obsolete errors, left here for ABI compatibility
  91. ErrFilePermissionsUnset = errors.New("permissions unset, defaulting to 0644")
  92. ErrDirectoryPermissionsUnset = errors.New("permissions unset, defaulting to 0755")
  93. )
  94. // NewNoInstallSectionError produces an error indicating the given unit, named
  95. // name, is missing an Install section.
  96. func NewNoInstallSectionError(name string) error {
  97. return fmt.Errorf("unit %q is enabled, but has no install section so enable does nothing", name)
  98. }