Skip to content

Commit a171213

Browse files
author
Ma Shimiao
committed
redefine error code as int64
Currently, error code is string type and duplicate with comment. I think that's not good, we should change it. Signed-off-by: Ma Shimiao <[email protected]>
1 parent df01456 commit a171213

File tree

7 files changed

+124
-124
lines changed

7 files changed

+124
-124
lines changed

specerror/bundle.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99
// define error codes
1010
const (
1111
// ConfigInRootBundleDir represents "This REQUIRED file MUST reside in the root of the bundle directory"
12-
ConfigInRootBundleDir = "This REQUIRED file MUST reside in the root of the bundle directory."
12+
ConfigInRootBundleDir Code = 0xa001 + iota
1313
// ConfigConstName represents "This REQUIRED file MUST be named `config.json`."
14-
ConfigConstName = "This REQUIRED file MUST be named `config.json`."
14+
ConfigConstName
1515
// ArtifactsInSingleDir represents "When supplied, while these artifacts MUST all be present in a single directory on the local filesystem, that directory itself is not part of the bundle."
16-
ArtifactsInSingleDir = "When supplied, while these artifacts MUST all be present in a single directory on the local filesystem, that directory itself is not part of the bundle."
16+
ArtifactsInSingleDir
1717
)
1818

1919
var (

specerror/config-linux.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,59 @@ import (
99
// define error codes
1010
const (
1111
// DefaultFilesystems represents "The following filesystems SHOULD be made available in each container's filesystem:"
12-
DefaultFilesystems = "The following filesystems SHOULD be made available in each container's filesystem:"
12+
DefaultFilesystems Code = 0xc001 + iota
1313
// NSPathAbs represents "This value MUST be an absolute path in the runtime mount namespace."
14-
NSPathAbs = "This value MUST be an absolute path in the runtime mount namespace."
14+
NSPathAbs
1515
// NSProcInPath represents "The runtime MUST place the container process in the namespace associated with that `path`."
16-
NSProcInPath = "The runtime MUST place the container process in the namespace associated with that `path`."
16+
NSProcInPath
1717
// NSPathMatchTypeError represents "The runtime MUST generate an error if `path` is not associated with a namespace of type `type`."
18-
NSPathMatchTypeError = "The runtime MUST generate an error if `path` is not associated with a namespace of type `type`."
18+
NSPathMatchTypeError
1919
// NSNewNSWithoutPath represents "If `path` is not specified, the runtime MUST create a new container namespace of type `type`."
20-
NSNewNSWithoutPath = "If `path` is not specified, the runtime MUST create a new container namespace of type `type`."
20+
NSNewNSWithoutPath
2121
// NSInheritWithoutType represents "If a namespace type is not specified in the `namespaces` array, the container MUST inherit the runtime namespace of that type."
22-
NSInheritWithoutType = "If a namespace type is not specified in the `namespaces` array, the container MUST inherit the runtime namespace of that type."
22+
NSInheritWithoutType
2323
// NSErrorOnDup represents "If a `namespaces` field contains duplicated namespaces with same `type`, the runtime MUST generate an error."
24-
NSErrorOnDup = "If a `namespaces` field contains duplicated namespaces with same `type`, the runtime MUST generate an error."
24+
NSErrorOnDup
2525
// UserNSMapOwnershipRO represents "The runtime SHOULD NOT modify the ownership of referenced filesystems to realize the mapping."
26-
UserNSMapOwnershipRO = "The runtime SHOULD NOT modify the ownership of referenced filesystems to realize the mapping."
26+
UserNSMapOwnershipRO
2727
// DevicesAvailable represents "devices (array of objects, OPTIONAL) lists devices that MUST be available in the container."
28-
DevicesAvailable = "devices (array of objects, OPTIONAL) lists devices that MUST be available in the container."
28+
DevicesAvailable
2929
// DevicesFileNotMatch represents "If a file already exists at `path` that does not match the requested device, the runtime MUST generate an error."
30-
DevicesFileNotMatch = "If a file already exists at `path` that does not match the requested device, the runtime MUST generate an error."
30+
DevicesFileNotMatch
3131
// DevicesMajMinRequired represents "`major, minor` (int64, REQUIRED unless `type` is `p`) - major, minor numbers for the device."
32-
DevicesMajMinRequired = "`major, minor` (int64, REQUIRED unless `type` is `p`) - major, minor numbers for the device."
32+
DevicesMajMinRequired
3333
// DevicesErrorOnDup represents "The same `type`, `major` and `minor` SHOULD NOT be used for multiple devices."
34-
DevicesErrorOnDup = "The same `type`, `major` and `minor` SHOULD NOT be used for multiple devices."
34+
DevicesErrorOnDup
3535
// DefaultDevices represents "In addition to any devices configured with this setting, the runtime MUST also supply default devices."
36-
DefaultDevices = "In addition to any devices configured with this setting, the runtime MUST also supply default devices."
36+
DefaultDevices
3737
// CgroupsPathAbsOrRel represents "The value of `cgroupsPath` MUST be either an absolute path or a relative path."
38-
CgroupsPathAbsOrRel = "The value of `cgroupsPath` MUST be either an absolute path or a relative path."
38+
CgroupsPathAbsOrRel
3939
// CgroupsAbsPathRelToMount represents "In the case of an absolute path (starting with `/`), the runtime MUST take the path to be relative to the cgroups mount point."
40-
CgroupsAbsPathRelToMount = "In the case of an absolute path (starting with `/`), the runtime MUST take the path to be relative to the cgroups mount point."
40+
CgroupsAbsPathRelToMount
4141
// CgroupsPathAttach represents "If the value is specified, the runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`."
42-
CgroupsPathAttach = "If the value is specified, the runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`."
42+
CgroupsPathAttach
4343
// CgroupsPathError represents "Runtimes MAY consider certain `cgroupsPath` values to be invalid, and MUST generate an error if this is the case."
44-
CgroupsPathError = "Runtimes MAY consider certain `cgroupsPath` values to be invalid, and MUST generate an error if this is the case."
44+
CgroupsPathError
4545
// DevicesApplyInOrder represents "The runtime MUST apply entries in the listed order."
46-
DevicesApplyInOrder = "The runtime MUST apply entries in the listed order."
46+
DevicesApplyInOrder
4747
// BlkIOWeightOrLeafWeightExist represents "You MUST specify at least one of `weight` or `leafWeight` in a given entry, and MAY specify both."
48-
BlkIOWeightOrLeafWeightExist = "You MUST specify at least one of `weight` or `leafWeight` in a given entry, and MAY specify both."
48+
BlkIOWeightOrLeafWeightExist
4949
// IntelRdtPIDWrite represents "If `intelRdt` is set, the runtime MUST write the container process ID to the `<container-id>/tasks` file in a mounted `resctrl` pseudo-filesystem, using the container ID from `start` and creating the `container-id` directory if necessary."
50-
IntelRdtPIDWrite = "If `intelRdt` is set, the runtime MUST write the container process ID to the `<container-id>/tasks` file in a mounted `resctrl` pseudo-filesystem, using the container ID from `start` and creating the `<container-id>` directory if necessary."
50+
IntelRdtPIDWrite
5151
// IntelRdtNoMountedResctrlError represents "If no mounted `resctrl` pseudo-filesystem is available in the runtime mount namespace, the runtime MUST generate an error."
52-
IntelRdtNoMountedResctrlError = "If no mounted `resctrl` pseudo-filesystem is available in the runtime mount namespace, the runtime MUST generate an error."
52+
IntelRdtNoMountedResctrlError
5353
// NotManipResctrlWithoutIntelRdt represents "If `intelRdt` is not set, the runtime MUST NOT manipulate any `resctrl` pseudo-filesystems."
54-
NotManipResctrlWithoutIntelRdt = "If `intelRdt` is not set, the runtime MUST NOT manipulate any `resctrl` pseudo-filesystems."
54+
NotManipResctrlWithoutIntelRdt
5555
// IntelRdtL3CacheSchemaWrite represents "If `l3CacheSchema` is set, runtimes MUST write the value to the `schemata` file in the `<container-id>` directory discussed in `intelRdt`."
56-
IntelRdtL3CacheSchemaWrite = "If `l3CacheSchema` is set, runtimes MUST write the value to the `schemata` file in the `<container-id>` directory discussed in `intelRdt`."
56+
IntelRdtL3CacheSchemaWrite
5757
// IntelRdtL3CacheSchemaNotWrite represents "If `l3CacheSchema` is not set, runtimes MUST NOT write to `schemata` files in any `resctrl` pseudo-filesystems."
58-
IntelRdtL3CacheSchemaNotWrite = "If `l3CacheSchema` is not set, runtimes MUST NOT write to `schemata` files in any `resctrl` pseudo-filesystems."
58+
IntelRdtL3CacheSchemaNotWrite
5959
// SeccSyscallsNamesRequired represents "`names` MUST contain at least one entry."
60-
SeccSyscallsNamesRequired = "`names` MUST contain at least one entry."
60+
SeccSyscallsNamesRequired
6161
// MaskedPathsAbs represents "maskedPaths (array of strings, OPTIONAL) will mask over the provided paths inside the container so that they cannot be read. The values MUST be absolute paths in the container namespace."
62-
MaskedPathsAbs = "maskedPaths (array of strings, OPTIONAL) will mask over the provided paths inside the container so that they cannot be read. The values MUST be absolute paths in the container namespace."
62+
MaskedPathsAbs
6363
// ReadonlyPathsAbs represents "readonlyPaths (array of strings, OPTIONAL) will set the provided paths as readonly inside the container. The values MUST be absolute paths in the container namespace."
64-
ReadonlyPathsAbs = "readonlyPaths (array of strings, OPTIONAL) will set the provided paths as readonly inside the container. The values MUST be absolute paths in the container namespace."
64+
ReadonlyPathsAbs
6565
)
6666

6767
var (

specerror/config-windows.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99
// define error codes
1010
const (
1111
// WindowsLayerFoldersRequired represents "`layerFolders` MUST contain at least one entry."
12-
WindowsLayerFoldersRequired = "`layerFolders` MUST contain at least one entry."
12+
WindowsLayerFoldersRequired Code = 0xd001 + iota
1313
// WindowsHyperVPresent represents "If present, the container MUST be run with Hyper-V isolation."
14-
WindowsHyperVPresent = "If present, the container MUST be run with Hyper-V isolation."
14+
WindowsHyperVPresent
1515
// WindowsHyperVOmit represents "If omitted, the container MUST be run as a Windows Server container."
16-
WindowsHyperVOmit = "If omitted, the container MUST be run as a Windows Server container."
16+
WindowsHyperVOmit
1717
)
1818

1919
var (

0 commit comments

Comments
 (0)