You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lint common error wrapping issues, update README (#1969)
* Lint common error wrapping issues, update README
Enable `errorlint` to catch common issues with wrapping and testing for errors.
Wherever possible, switched to using `errors.Is` and `errors.As`.
Exceptions:
- function is defined in the same package and explicitly returns a
know error variable
- returns from functions in `io`, `binary`, `context`, `syscall`,
`golang.org/x/sys/windows`, or `golang.org/x/sys/unix` that are
(relatively) stable in error return value and type
- conversion would interact with with `github.com/pkg/errors`
- conversion would be non-trivial and require additional
testing/validation
- specifically, legacy code in `runhcs` and the root of the repo
Rename `context` to `ctx` in `pkg\go-runhcs\*.go` to avoid
overshadowing `context` package.
Update `README.md`:
- run markdown formatter (spaces around code blocks and headers, raw link URLS)
- add section on linter and go generate (similar to go-winio's)
Signed-off-by: Hamza El-Saawy <[email protected]>
* PR: hcserrors(+tests), README
Signed-off-by: Hamza El-Saawy <[email protected]>
---------
Signed-off-by: Hamza El-Saawy <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+76-8Lines changed: 76 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,18 @@ It is primarily used in the [Moby](https://github.com/moby/moby) and [Containerd
9
9
## Building
10
10
11
11
While this repository can be used as a library of sorts to call the HCS apis, there are a couple binaries built out of the repository as well. The main ones being the Linux guest agent, and an implementation of the [runtime v2 containerd shim api](https://github.com/containerd/containerd/blob/master/runtime/v2/README.md).
12
+
12
13
### Linux Hyper-V Container Guest Agent
13
14
14
15
To build the Linux guest agent itself all that's needed is to set your GOOS to "Linux" and build out of ./cmd/gcs.
16
+
15
17
```powershell
16
18
C:\> $env:GOOS="linux"
17
19
C:\> go build .\cmd\gcs\
18
20
```
19
21
20
22
or on a Linux machine
23
+
21
24
```sh
22
25
> go build ./cmd/gcs
23
26
```
@@ -33,13 +36,15 @@ make all
33
36
```
34
37
35
38
If the build is successful, in the `./out` folder you should see:
39
+
36
40
```sh
37
41
> ls ./out/
38
42
delta.tar.gz initrd.img rootfs.tar.gz
39
43
```
40
44
41
45
### Containerd Shim
42
-
For info on the Runtime V2 API: https://github.com/containerd/containerd/blob/master/runtime/v2/README.md.
46
+
47
+
For info on the [Runtime V2 API](https://github.com/containerd/containerd/blob/master/runtime/v2/README.md).
43
48
44
49
Contrary to the typical Linux architecture of shim -> runc, the runhcs shim is used both to launch and manage the lifetime of containers.
45
50
@@ -48,14 +53,17 @@ C:\> $env:GOOS="windows"
48
53
C:\> go build .\cmd\containerd-shim-runhcs-v1
49
54
```
50
55
51
-
Then place the binary in the same directory that Containerd is located at in your environment. A default Containerd configuration file can be generated by running:
56
+
Then place the binary in the same directory that Containerd is located at in your environment.
57
+
A default Containerd configuration file can be generated by running:
This project welcomes contributions and suggestions. Most contributions require you to agree to a
66
74
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
67
-
the rights to use your contribution. For details, visit https://cla.microsoft.com.
75
+
the rights to use your contribution. For details, visit [Microsoft CLA](https://cla.microsoft.com).
68
76
69
77
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
70
78
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
71
79
provided by the bot. You will only need to do this once across all repos using our CLA.
72
80
73
-
We also require that contributors [sign their commits](https://git-scm.com/docs/git-commit) using `git commit -s` or `git commit --signoff` to
74
-
certify they either authored the work themselves or otherwise have permission to use it in this project. Please see https://developercertificate.org/ for
75
-
more info, as well as to make sure that you can attest to the rules listed. Our CI uses the [DCO Github app](https://github.com/apps/dco) to ensure
76
-
that all commits in a given PR are signed-off.
81
+
We require that contributors sign their commits
82
+
to certify they either authored the work themselves or otherwise have permission to use it in this project.
83
+
84
+
We also require that contributors sign their commits using using [`git commit --signoff`][git-commit-s]
85
+
to certify they either authored the work themselves or otherwise have permission to use it in this project.
86
+
A range of commits can be signed off using [`git rebase --signoff`][git-rebase-s].
87
+
88
+
Please see [the developer certificate](https://developercertificate.org) for more info,
89
+
as well as to make sure that you can attest to the rules listed.
90
+
Our CI uses the [DCO Github app](https://github.com/apps/dco) to ensure that all commits in a given PR are signed-off.
91
+
92
+
### Linting
93
+
94
+
Code must pass a linting stage, which uses [`golangci-lint`][lint].
95
+
Since `./test` is a separate Go module, the linter is run from both the root and the
96
+
`test` directories. Additionally, the linter is run with `GOOS` set to both `windows` and
97
+
`linux`.
98
+
99
+
The linting settings are stored in [`.golangci.yaml`](./.golangci.yaml), and can be run
100
+
automatically with VSCode by adding the following to your workspace or folder settings:
101
+
102
+
```json
103
+
"go.lintTool": "golangci-lint",
104
+
"go.lintOnSave": "package",
105
+
```
106
+
107
+
Additional editor [integrations options are also available][lint-ide].
108
+
109
+
Alternatively, `golangci-lint` can be [installed][lint-install] and run locally:
110
+
111
+
```shell
112
+
# use . or specify a path to only lint a package
113
+
# to show all lint errors, use flags "--max-issues-per-linter=0 --max-same-issues=0"
114
+
> golangci-lint run
115
+
```
116
+
117
+
To run across the entire repo for both `GOOS=windows` and `linux`:
118
+
119
+
```powershell
120
+
> foreach ( $goos in ('windows', 'linux') ) {
121
+
foreach ( $repo in ('.', 'test') ) {
122
+
pwsh -Command "cd $repo && go env -w GOOS=$goos && golangci-lint.exe run --verbose"
123
+
}
124
+
}
125
+
```
126
+
127
+
### Go Generate
128
+
129
+
The pipeline checks that auto-generated code, via `go generate`, are up to date.
130
+
Similar to the [linting stage](#linting), `go generate` is run in both the root and test Go modules.
This project requires Golang 1.17 or newer to build.
147
+
This project requires Golang 1.18 or newer to build.
87
148
88
149
For system requirements to run this project, see the Microsoft docs on [Windows Container requirements](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/system-requirements).
89
150
@@ -100,3 +161,10 @@ For additional details, see [Report a Computer Security Vulnerability](https://t
100
161
101
162
---------------
102
163
Copyright (c) 2018 Microsoft Corp. All rights reserved.
0 commit comments