containerd/contrib
Sebastiaan van Stijn eaedadbed0
replace strings.Split(N) for strings.Cut() or alternatives
Go 1.18 and up now provides a strings.Cut() which is better suited for
splitting key/value pairs (and similar constructs), and performs better:

```go
func BenchmarkSplit(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _ = strings.SplitN(s, "=", 2)[0]
                }
        }
}

func BenchmarkCut(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _, _, _ = strings.Cut(s, "=")
                }
        }
}
```

    BenchmarkSplit
    BenchmarkSplit-10            8244206               128.0 ns/op           128 B/op          4 allocs/op
    BenchmarkCut
    BenchmarkCut-10             54411998                21.80 ns/op            0 B/op          0 allocs/op

While looking at occurrences of `strings.Split()`, I also updated some for alternatives,
or added some constraints; for cases where an specific number of items is expected, I used `strings.SplitN()`
with a suitable limit. This prevents (theoretical) unlimited splits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-07 10:02:25 +01:00
..
ansible migrate from k8s.gcr.io to registry.k8s.io 2022-08-24 13:46:46 +08:00
apparmor replace strings.Split(N) for strings.Cut() or alternatives 2022-11-07 10:02:25 +01:00
autocomplete Fix zsh autocomplete script 2020-02-11 19:56:27 +08:00
aws Move snapshotters benchmark to a separate package 2019-04-02 14:42:21 -07:00
Dockerfile.test.d/cri-in-userns Dockerfile.test: add "cri-in-userns" (aka rootless) test stage 2021-07-09 14:50:04 +09:00
fuzz Bump go version to 1.19.3 2022-11-02 19:54:42 +00:00
gce adds support for using env file for systemd boot 2022-07-20 12:52:10 -05:00
nvidia replace uses of os/exec with golang.org/x/sys/execabs 2021-08-25 18:11:09 +02:00
seccomp Update the default seccomp to block socket calls to AF_VSOCK 2022-10-11 15:30:39 -07:00
snapshotservice Rename Size_ to Size 2022-04-22 15:31:53 +00:00
Dockerfile.test Bump go version to 1.19.3 2022-11-02 19:54:42 +00:00
README.md Add readme to contib 2017-09-18 11:47:27 -04:00

contrib

The contrib directory contains packages that do not belong in the core containerd packages but still contribute to overall containerd usability.

Package such as Apparmor or Selinux are placed in contrib because they are platform dependent and often require higher level tools and profiles to work.

Packaging and other built tools can be added to contrib to aid in packaging containerd for various distributions.

Testing

Code in the contrib directory may or may not have been tested in the normal test pipeline for core components.