Migrate to containerd v1.6.4

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd) 2022-05-25 11:22:51 +01:00
parent fee46de596
commit 18c7f90f64
93 changed files with 1145 additions and 630 deletions

View File

@ -1,7 +1,7 @@
Version := $(shell git describe --tags --dirty) Version := $(shell git describe --tags --dirty)
GitCommit := $(shell git rev-parse HEAD) GitCommit := $(shell git rev-parse HEAD)
LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)" LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)"
CONTAINERD_VER := 1.6.2 CONTAINERD_VER := 1.6.4
CNI_VERSION := v0.9.1 CNI_VERSION := v0.9.1
ARCH := amd64 ARCH := amd64
@ -33,7 +33,7 @@ hashgen:
.PHONY: prepare-test .PHONY: prepare-test
prepare-test: prepare-test:
curl -sLSf https://github.com/containerd/containerd/releases/download/v$(CONTAINERD_VER)/containerd-$(CONTAINERD_VER)-linux-amd64.tar.gz > /tmp/containerd.tar.gz && sudo tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1 curl -sLSf https://github.com/containerd/containerd/releases/download/v$(CONTAINERD_VER)/containerd-$(CONTAINERD_VER)-linux-amd64.tar.gz > /tmp/containerd.tar.gz && sudo tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1
curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.6.2/containerd.service | sudo tee /etc/systemd/system/containerd.service curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.6.4/containerd.service | sudo tee /etc/systemd/system/containerd.service
sudo systemctl daemon-reload && sudo systemctl start containerd sudo systemctl daemon-reload && sudo systemctl start containerd
sudo /sbin/sysctl -w net.ipv4.conf.all.forwarding=1 sudo /sbin/sysctl -w net.ipv4.conf.all.forwarding=1
sudo mkdir -p /opt/cni/bin sudo mkdir -p /opt/cni/bin

View File

@ -20,7 +20,7 @@ See these instructions instead: [Testing patches](/docs/PATCHES.md)
For Windows users, install [Git Bash](https://git-scm.com/downloads) along with multipass or vagrant. You can also use WSL1 or WSL2 which provides a Linux environment. For Windows users, install [Git Bash](https://git-scm.com/downloads) along with multipass or vagrant. You can also use WSL1 or WSL2 which provides a Linux environment.
You will also need [containerd v1.6.2](https://github.com/containerd/containerd) and the [CNI plugins v0.9.1](https://github.com/containernetworking/plugins) You will also need [containerd](https://github.com/containerd/containerd) and the [CNI plugins](https://github.com/containernetworking/plugins)
[faas-cli](https://github.com/openfaas/faas-cli) is optional, but recommended. [faas-cli](https://github.com/openfaas/faas-cli) is optional, but recommended.
@ -88,7 +88,7 @@ You have three options - binaries for PC, binaries for armhf, or build from sour
* Install containerd `x86_64` only * Install containerd `x86_64` only
```bash ```bash
export VER=1.6.2 export VER=1.6.4
curl -sSL https://github.com/containerd/containerd/releases/download/v$VER/containerd-$VER-linux-amd64.tar.gz > /tmp/containerd.tar.gz \ curl -sSL https://github.com/containerd/containerd/releases/download/v$VER/containerd-$VER-linux-amd64.tar.gz > /tmp/containerd.tar.gz \
&& sudo tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1 && sudo tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1
@ -100,7 +100,7 @@ containerd -version
Building `containerd` on armhf is extremely slow, so I've provided binaries for you. Building `containerd` on armhf is extremely slow, so I've provided binaries for you.
```bash ```bash
curl -sSL https://github.com/alexellis/containerd-armhf/releases/download/v1.6.2/containerd.tgz | sudo tar -xvz --strip-components=2 -C /usr/local/bin/ curl -sSL https://github.com/alexellis/containerd-armhf/releases/download/v1.6.4/containerd.tgz | sudo tar -xvz --strip-components=2 -C /usr/local/bin/
``` ```
* Or clone / build / install [containerd](https://github.com/containerd/containerd) from source: * Or clone / build / install [containerd](https://github.com/containerd/containerd) from source:
@ -112,7 +112,7 @@ containerd -version
git clone https://github.com/containerd/containerd git clone https://github.com/containerd/containerd
cd containerd cd containerd
git fetch origin --tags git fetch origin --tags
git checkout v1.6.2 git checkout v1.6.4
make make
sudo make install sudo make install
@ -123,7 +123,7 @@ containerd -version
#### Ensure containerd is running #### Ensure containerd is running
```bash ```bash
curl -sLS https://raw.githubusercontent.com/containerd/containerd/v1.6.2/containerd.service > /tmp/containerd.service curl -sLS https://raw.githubusercontent.com/containerd/containerd/v1.6.4/containerd.service > /tmp/containerd.service
# Extend the timeouts for low-performance VMs # Extend the timeouts for low-performance VMs
echo "[Manager]" | tee -a /tmp/containerd.service echo "[Manager]" | tee -a /tmp/containerd.service

View File

@ -6,8 +6,8 @@ packages:
- git - git
runcmd: runcmd:
- curl -sLSf https://github.com/containerd/containerd/releases/download/v1.6.2/containerd-1.6.2-linux-amd64.tar.gz > /tmp/containerd.tar.gz && tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1 - curl -sLSf https://github.com/containerd/containerd/releases/download/v1.6.4/containerd-1.6.4-linux-amd64.tar.gz > /tmp/containerd.tar.gz && tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1
- curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.6.2/containerd.service | tee /etc/systemd/system/containerd.service - curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.6.4/containerd.service | tee /etc/systemd/system/containerd.service
- systemctl daemon-reload && systemctl start containerd - systemctl daemon-reload && systemctl start containerd
- /sbin/sysctl -w net.ipv4.conf.all.forwarding=1 - /sbin/sysctl -w net.ipv4.conf.all.forwarding=1
- mkdir -p /opt/cni/bin - mkdir -p /opt/cni/bin

26
go.mod
View File

@ -6,27 +6,27 @@ require (
github.com/alexellis/go-execute v0.5.0 github.com/alexellis/go-execute v0.5.0
github.com/alexellis/k3sup v0.0.0-20220105194923-e2bb18116d36 github.com/alexellis/k3sup v0.0.0-20220105194923-e2bb18116d36
github.com/compose-spec/compose-go v0.0.0-20200528042322-36d8ce368e05 github.com/compose-spec/compose-go v0.0.0-20200528042322-36d8ce368e05
github.com/containerd/containerd v1.6.2 github.com/containerd/containerd v1.6.4
github.com/containerd/go-cni v1.1.3 github.com/containerd/go-cni v1.1.5
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/docker/cli v0.0.0-20191105005515-99c5edceb48d github.com/docker/cli v0.0.0-20191105005515-99c5edceb48d
github.com/docker/distribution v2.8.0+incompatible github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker v17.12.0-ce-rc1.0.20191113042239-ea84732a7725+incompatible // indirect github.com/docker/docker v17.12.0-ce-rc1.0.20191113042239-ea84732a7725+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.3 // indirect github.com/docker/docker-credential-helpers v0.6.3 // indirect
github.com/docker/go-units v0.4.0 github.com/docker/go-units v0.4.0
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/morikuni/aec v1.0.0 github.com/morikuni/aec v1.0.0
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/openfaas/faas-provider v0.18.9 github.com/openfaas/faas-provider v0.18.10
github.com/openfaas/faas/gateway v0.0.0-20220124164130-cdb6badddaed github.com/openfaas/faas/gateway v0.0.0-20220509091830-4e868f5f9d81
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/sethvargo/go-password v0.2.0 github.com/sethvargo/go-password v0.2.0
github.com/spf13/cobra v1.2.1 github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e golang.org/x/sys v0.0.0-20220209214540-3681064d5158
k8s.io/apimachinery v0.22.5 k8s.io/apimachinery v0.24.0
) )
require ( require (
@ -37,7 +37,7 @@ require (
github.com/containerd/fifo v1.0.0 // indirect github.com/containerd/fifo v1.0.0 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect github.com/containerd/ttrpc v1.1.0 // indirect
github.com/containerd/typeurl v1.0.2 // indirect github.com/containerd/typeurl v1.0.2 // indirect
github.com/containernetworking/cni v1.0.1 // indirect github.com/containernetworking/cni v1.1.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/gogo/googleapis v1.4.0 // indirect github.com/gogo/googleapis v1.4.0 // indirect
@ -54,15 +54,15 @@ require (
github.com/moby/sys/mountinfo v0.5.0 // indirect github.com/moby/sys/mountinfo v0.5.0 // indirect
github.com/moby/sys/signal v0.6.0 // indirect github.com/moby/sys/signal v0.6.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5 // indirect github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.0 // indirect github.com/opencontainers/runc v1.1.1 // indirect
github.com/opencontainers/selinux v1.10.0 // indirect github.com/opencontainers/selinux v1.10.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect github.com/sirupsen/logrus v1.8.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.opencensus.io v0.23.0 // indirect go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/text v0.3.7 // indirect golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect

375
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@ git clone https://github.com/containerd/containerd
cd containerd cd containerd
git fetch origin --tags git fetch origin --tags
git checkout v1.6.2 git checkout v1.6.4
make make
sudo make install sudo make install

View File

@ -29,7 +29,7 @@ git clone https://github.com/containerd/containerd
cd containerd cd containerd
git fetch origin --tags git fetch origin --tags
git checkout v1.6.2 git checkout v1.6.4
make make
sudo make install sudo make install

View File

@ -30,7 +30,7 @@ git clone https://github.com/containerd/containerd
cd containerd cd containerd
git fetch origin --tags git fetch origin --tags
git checkout v1.6.2 git checkout v1.6.4
make make
sudo make install sudo make install

View File

@ -86,7 +86,7 @@ install_cni_plugins() {
install_containerd() { install_containerd() {
arch=$(uname -m) arch=$(uname -m)
CONTAINERD_VER=1.6.2 CONTAINERD_VER=1.6.4
case $arch in case $arch in
x86_64 | amd64) x86_64 | amd64)
curl -sLSf https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VER}/containerd-${CONTAINERD_VER}-linux-amd64.tar.gz | $SUDO tar -xvz --strip-components=1 -C /usr/local/bin/ curl -sLSf https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VER}/containerd-${CONTAINERD_VER}-linux-amd64.tar.gz | $SUDO tar -xvz --strip-components=1 -C /usr/local/bin/

View File

@ -87,6 +87,7 @@ Michael Crosby <crosbymichael@gmail.com> <michael@thepasture.io>
Michael Katsoulis <michaelkatsoulis88@gmail.com> Michael Katsoulis <michaelkatsoulis88@gmail.com>
Mike Brown <brownwm@us.ibm.com> <mikebrow@users.noreply.github.com> Mike Brown <brownwm@us.ibm.com> <mikebrow@users.noreply.github.com>
Mohammad Asif Siddiqui <mohammad.asif.siddiqui1@huawei.com> Mohammad Asif Siddiqui <mohammad.asif.siddiqui1@huawei.com>
Nabeel Rana <nabeelnrana@gmail.com>
Ng Yang <wssccc@qq.com> Ng Yang <wssccc@qq.com>
Ning Li <ning.a.li@transwarp.io> Ning Li <ning.a.li@transwarp.io>
ningmingxiao <ning.mingxiao@zte.com.cn> ningmingxiao <ning.mingxiao@zte.com.cn>
@ -121,6 +122,7 @@ Tõnis Tiigi <tonistiigi@gmail.com>
Wade Lee <weidonglee27@gmail.com> Wade Lee <weidonglee27@gmail.com>
Wade Lee <weidonglee27@gmail.com> <weidonglee29@gmail.com> Wade Lee <weidonglee27@gmail.com> <weidonglee29@gmail.com>
Wade Lee <weidonglee27@gmail.com> <21621232@zju.edu.cn> Wade Lee <weidonglee27@gmail.com> <21621232@zju.edu.cn>
Wang Bing <wangbing.adam@gmail.com>
wanglei <wllenyj@linux.alibaba.com> wanglei <wllenyj@linux.alibaba.com>
wanglei <wllenyj@linux.alibaba.com> <wanglei01@alibaba-inc.com> wanglei <wllenyj@linux.alibaba.com> <wanglei01@alibaba-inc.com>
wangzhan <wang.zhan@smartx.com> wangzhan <wang.zhan@smartx.com>

View File

@ -15,9 +15,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Vagrantfile for cgroup2 and SELinux # Vagrantfile for Fedora and EL
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.box = "fedora/35-cloud-base" config.vm.box = ENV["BOX"] || "fedora/35-cloud-base"
config.vm.box_version = ENV["BOX_VERSION"]
memory = 4096 memory = 4096
cpus = 2 cpus = 2
config.vm.provider :virtualbox do |v| config.vm.provider :virtualbox do |v|
@ -71,22 +72,31 @@ Vagrant.configure("2") do |config|
SHELL SHELL
end end
# EL does not have /usr/local/{bin,sbin} in the PATH by default
config.vm.provision "setup-etc-environment", type: "shell", run: "once" do |sh|
sh.upload_path = "/tmp/vagrant-setup-etc-environment"
sh.inline = <<~SHELL
#!/usr/bin/env bash
set -eux -o pipefail
cat >> /etc/environment <<EOF
PATH=/usr/local/go/bin:/usr/local/bin:/usr/local/sbin:$PATH
EOF
source /etc/environment
SHELL
end
# To re-run this provisioner, installing a different version of go: # To re-run this provisioner, installing a different version of go:
# GO_VERSION="1.14.6" vagrant up --provision-with=install-golang # GO_VERSION="1.14.6" vagrant up --provision-with=install-golang
# #
config.vm.provision "install-golang", type: "shell", run: "once" do |sh| config.vm.provision "install-golang", type: "shell", run: "once" do |sh|
sh.upload_path = "/tmp/vagrant-install-golang" sh.upload_path = "/tmp/vagrant-install-golang"
sh.env = { sh.env = {
'GO_VERSION': ENV['GO_VERSION'] || "1.17.8", 'GO_VERSION': ENV['GO_VERSION'] || "1.17.9",
} }
sh.inline = <<~SHELL sh.inline = <<~SHELL
#!/usr/bin/env bash #!/usr/bin/env bash
set -eux -o pipefail set -eux -o pipefail
curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local
cat >> /etc/environment <<EOF
PATH=/usr/local/go/bin:$PATH
EOF
source /etc/environment
cat >> /etc/profile.d/sh.local <<EOF cat >> /etc/profile.d/sh.local <<EOF
GOPATH=\\$HOME/go GOPATH=\\$HOME/go
PATH=\\$GOPATH/bin:\\$PATH PATH=\\$GOPATH/bin:\\$PATH
@ -218,6 +228,7 @@ EOF
set -eux -o pipefail set -eux -o pipefail
rm -rf /var/lib/containerd-test /run/containerd-test rm -rf /var/lib/containerd-test /run/containerd-test
cd ${GOPATH}/src/github.com/containerd/containerd cd ${GOPATH}/src/github.com/containerd/containerd
go test -v -count=1 -race ./metrics/cgroups
make integration EXTRA_TESTFLAGS="-timeout 15m -no-criu -test.v" TEST_RUNTIME=io.containerd.runc.v2 RUNC_FLAVOR=$RUNC_FLAVOR make integration EXTRA_TESTFLAGS="-timeout 15m -no-criu -test.v" TEST_RUNTIME=io.containerd.runc.v2 RUNC_FLAVOR=$RUNC_FLAVOR
SHELL SHELL
end end

View File

@ -28,6 +28,7 @@ import (
"github.com/containerd/containerd/diff" "github.com/containerd/containerd/diff"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/pkg/kmutex"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/rootfs"
"github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots"
@ -287,6 +288,10 @@ type UnpackConfig struct {
// CheckPlatformSupported is whether to validate that a snapshotter // CheckPlatformSupported is whether to validate that a snapshotter
// supports an image's platform before unpacking // supports an image's platform before unpacking
CheckPlatformSupported bool CheckPlatformSupported bool
// DuplicationSuppressor is used to make sure that there is only one
// in-flight fetch request or unpack handler for a given descriptor's
// digest or chain ID.
DuplicationSuppressor kmutex.KeyedLocker
} }
// UnpackOpt provides configuration for unpack // UnpackOpt provides configuration for unpack
@ -300,6 +305,14 @@ func WithSnapshotterPlatformCheck() UnpackOpt {
} }
} }
// WithUnpackDuplicationSuppressor sets `DuplicationSuppressor` on the UnpackConfig.
func WithUnpackDuplicationSuppressor(suppressor kmutex.KeyedLocker) UnpackOpt {
return func(ctx context.Context, uc *UnpackConfig) error {
uc.DuplicationSuppressor = suppressor
return nil
}
}
func (i *image) Unpack(ctx context.Context, snapshotterName string, opts ...UnpackOpt) error { func (i *image) Unpack(ctx context.Context, snapshotterName string, opts ...UnpackOpt) error {
ctx, done, err := i.client.WithLease(ctx) ctx, done, err := i.client.WithLease(ctx)
if err != nil { if err != nil {

View File

@ -0,0 +1,105 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package kmutex provides synchronization primitives to lock/unlock resource by unique key.
package kmutex
import (
"context"
"fmt"
"sync"
"golang.org/x/sync/semaphore"
)
// KeyedLocker is the interface for acquiring locks based on string.
type KeyedLocker interface {
Lock(ctx context.Context, key string) error
Unlock(key string)
}
func New() KeyedLocker {
return newKeyMutex()
}
func newKeyMutex() *keyMutex {
return &keyMutex{
locks: make(map[string]*klock),
}
}
type keyMutex struct {
mu sync.Mutex
locks map[string]*klock
}
type klock struct {
*semaphore.Weighted
ref int
}
func (km *keyMutex) Lock(ctx context.Context, key string) error {
km.mu.Lock()
l, ok := km.locks[key]
if !ok {
km.locks[key] = &klock{
Weighted: semaphore.NewWeighted(1),
}
l = km.locks[key]
}
l.ref++
km.mu.Unlock()
if err := l.Acquire(ctx, 1); err != nil {
km.mu.Lock()
defer km.mu.Unlock()
l.ref--
if l.ref < 0 {
panic(fmt.Errorf("kmutex: release of unlocked key %v", key))
}
if l.ref == 0 {
delete(km.locks, key)
}
return err
}
return nil
}
func (km *keyMutex) Unlock(key string) {
km.mu.Lock()
defer km.mu.Unlock()
l, ok := km.locks[key]
if !ok {
panic(fmt.Errorf("kmutex: unlock of unlocked key %v", key))
}
l.Release(1)
l.ref--
if l.ref < 0 {
panic(fmt.Errorf("kmutex: released of unlocked key %v", key))
}
if l.ref == 0 {
delete(km.locks, key)
}
}

View File

@ -0,0 +1,33 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kmutex
import "context"
func NewNoop() KeyedLocker {
return &noopMutex{}
}
type noopMutex struct {
}
func (*noopMutex) Lock(_ context.Context, _ string) error {
return nil
}
func (*noopMutex) Unlock(_ string) {
}

View File

@ -32,6 +32,7 @@ import (
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/pkg/kmutex"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
@ -59,7 +60,9 @@ func (c *Client) newUnpacker(ctx context.Context, rCtx *RemoteContext) (*unpacke
if err != nil { if err != nil {
return nil, err return nil, err
} }
var config UnpackConfig var config = UnpackConfig{
DuplicationSuppressor: kmutex.NewNoop(),
}
for _, o := range rCtx.UnpackOpts { for _, o := range rCtx.UnpackOpts {
if err := o(ctx, &config); err != nil { if err := o(ctx, &config); err != nil {
return nil, err return nil, err
@ -127,15 +130,20 @@ func (u *unpacker) unpack(
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
EachLayer: doUnpackFn := func(i int, desc ocispec.Descriptor) error {
for i, desc := range layers {
parent := identity.ChainID(chain) parent := identity.ChainID(chain)
chain = append(chain, diffIDs[i]) chain = append(chain, diffIDs[i])
chainID := identity.ChainID(chain).String() chainID := identity.ChainID(chain).String()
unlock, err := u.lockSnChainID(ctx, chainID)
if err != nil {
return err
}
defer unlock()
if _, err := sn.Stat(ctx, chainID); err == nil { if _, err := sn.Stat(ctx, chainID); err == nil {
// no need to handle // no need to handle
continue return nil
} else if !errdefs.IsNotFound(err) { } else if !errdefs.IsNotFound(err) {
return fmt.Errorf("failed to stat snapshot %s: %w", chainID, err) return fmt.Errorf("failed to stat snapshot %s: %w", chainID, err)
} }
@ -167,7 +175,7 @@ EachLayer:
log.G(ctx).WithField("key", key).WithField("chainid", chainID).Debug("extraction snapshot already exists, chain id not found") log.G(ctx).WithField("key", key).WithField("chainid", chainID).Debug("extraction snapshot already exists, chain id not found")
} else { } else {
// no need to handle, snapshot now found with chain id // no need to handle, snapshot now found with chain id
continue EachLayer return nil
} }
} else { } else {
return fmt.Errorf("failed to prepare extraction snapshot %q: %w", key, err) return fmt.Errorf("failed to prepare extraction snapshot %q: %w", key, err)
@ -227,7 +235,7 @@ EachLayer:
if err = sn.Commit(ctx, chainID, key, opts...); err != nil { if err = sn.Commit(ctx, chainID, key, opts...); err != nil {
abort() abort()
if errdefs.IsAlreadyExists(err) { if errdefs.IsAlreadyExists(err) {
continue return nil
} }
return fmt.Errorf("failed to commit snapshot %s: %w", key, err) return fmt.Errorf("failed to commit snapshot %s: %w", key, err)
} }
@ -243,7 +251,13 @@ EachLayer:
if _, err := cs.Update(ctx, cinfo, "labels.containerd.io/uncompressed"); err != nil { if _, err := cs.Update(ctx, cinfo, "labels.containerd.io/uncompressed"); err != nil {
return err return err
} }
return nil
}
for i, desc := range layers {
if err := doUnpackFn(i, desc); err != nil {
return err
}
} }
chainID := identity.ChainID(chain).String() chainID := identity.ChainID(chain).String()
@ -271,17 +285,22 @@ func (u *unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec
desc := desc desc := desc
i := i i := i
if u.limiter != nil { if err := u.acquire(ctx); err != nil {
if err := u.limiter.Acquire(ctx, 1); err != nil { return err
return err
}
} }
eg.Go(func() error { eg.Go(func() error {
_, err := h.Handle(ctx2, desc) unlock, err := u.lockBlobDescriptor(ctx2, desc)
if u.limiter != nil { if err != nil {
u.limiter.Release(1) u.release()
return err
} }
_, err = h.Handle(ctx2, desc)
unlock()
u.release()
if err != nil && !errors.Is(err, images.ErrSkipDesc) { if err != nil && !errors.Is(err, images.ErrSkipDesc) {
return err return err
} }
@ -306,7 +325,13 @@ func (u *unpacker) handlerWrapper(
layers = map[digest.Digest][]ocispec.Descriptor{} layers = map[digest.Digest][]ocispec.Descriptor{}
) )
return images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { return images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
unlock, err := u.lockBlobDescriptor(ctx, desc)
if err != nil {
return nil, err
}
children, err := f.Handle(ctx, desc) children, err := f.Handle(ctx, desc)
unlock()
if err != nil { if err != nil {
return children, err return children, err
} }
@ -349,6 +374,50 @@ func (u *unpacker) handlerWrapper(
}, eg }, eg
} }
func (u *unpacker) acquire(ctx context.Context) error {
if u.limiter == nil {
return nil
}
return u.limiter.Acquire(ctx, 1)
}
func (u *unpacker) release() {
if u.limiter == nil {
return
}
u.limiter.Release(1)
}
func (u *unpacker) lockSnChainID(ctx context.Context, chainID string) (func(), error) {
key := u.makeChainIDKeyWithSnapshotter(chainID)
if err := u.config.DuplicationSuppressor.Lock(ctx, key); err != nil {
return nil, err
}
return func() {
u.config.DuplicationSuppressor.Unlock(key)
}, nil
}
func (u *unpacker) lockBlobDescriptor(ctx context.Context, desc ocispec.Descriptor) (func(), error) {
key := u.makeBlobDescriptorKey(desc)
if err := u.config.DuplicationSuppressor.Lock(ctx, key); err != nil {
return nil, err
}
return func() {
u.config.DuplicationSuppressor.Unlock(key)
}, nil
}
func (u *unpacker) makeChainIDKeyWithSnapshotter(chainID string) string {
return fmt.Sprintf("sn://%s/%v", u.snapshotter, chainID)
}
func (u *unpacker) makeBlobDescriptorKey(desc ocispec.Descriptor) string {
return fmt.Sprintf("blob://%v", desc.Digest)
}
func uniquePart() string { func uniquePart() string {
t := time.Now() t := time.Now()
var b [3]byte var b [3]byte

View File

@ -23,7 +23,7 @@ var (
Package = "github.com/containerd/containerd" Package = "github.com/containerd/containerd"
// Version holds the complete version number. Filled in at linking time. // Version holds the complete version number. Filled in at linking time.
Version = "1.6.2+unknown" Version = "1.6.4+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build // Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time. // the program at linking time.

3
vendor/github.com/containerd/go-cni/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
/bin/
coverage.txt
profile.out

View File

@ -6,7 +6,7 @@ linters:
- unconvert - unconvert
- gofmt - gofmt
- goimports - goimports
- golint - revive
- ineffassign - ineffassign
- vet - vet
- unused - unused

43
vendor/github.com/containerd/go-cni/Makefile generated vendored Normal file
View File

@ -0,0 +1,43 @@
# Copyright The containerd Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTFLAGS_PARALLEL ?= 8
EXTRA_TESTFLAGS ?=
# quiet or not
ifeq ($(V),1)
Q =
else
Q = @
endif
.PHONY: test integration clean help
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
test: ## run tests, except integration tests and tests that require root
$(Q)go test -v -race $(EXTRA_TESTFLAGS) -count=1 ./...
integration: ## run integration test
$(Q)bin/integration.test -test.v -test.count=1 -test.root $(EXTRA_TESTFLAGS) -test.parallel $(TESTFLAGS_PARALLEL)
FORCE:
bin/integration.test: FORCE ## build integration test binary into bin
$(Q)cd ./integration && go test -race -c . -o ../bin/integration.test
clean: ## clean up binaries
$(Q)rm -rf bin/

View File

@ -19,10 +19,10 @@ package cni
import types100 "github.com/containernetworking/cni/pkg/types/100" import types100 "github.com/containernetworking/cni/pkg/types/100"
// Deprecated: use cni.Opt instead // Deprecated: use cni.Opt instead
type CNIOpt = Opt //nolint: golint // type name will be used as cni.CNIOpt by other packages, and that stutters type CNIOpt = Opt //revive:disable // type name will be used as cni.CNIOpt by other packages, and that stutters
// Deprecated: use cni.Result instead // Deprecated: use cni.Result instead
type CNIResult = Result //nolint: golint // type name will be used as cni.CNIResult by other packages, and that stutters type CNIResult = Result //revive:disable // type name will be used as cni.CNIResult by other packages, and that stutters
// GetCNIResultFromResults creates a Result from the given slice of types100.Result, // GetCNIResultFromResults creates a Result from the given slice of types100.Result,
// adding structured data containing the interface configuration for each of the // adding structured data containing the interface configuration for each of the

View File

@ -18,7 +18,7 @@ package cni
type NamespaceOpts func(s *Namespace) error type NamespaceOpts func(s *Namespace) error
// Capabilities // WithCapabilityPortMap adds support for port mappings
func WithCapabilityPortMap(portMapping []PortMapping) NamespaceOpts { func WithCapabilityPortMap(portMapping []PortMapping) NamespaceOpts {
return func(c *Namespace) error { return func(c *Namespace) error {
c.capabilityArgs["portMappings"] = portMapping c.capabilityArgs["portMappings"] = portMapping
@ -26,6 +26,7 @@ func WithCapabilityPortMap(portMapping []PortMapping) NamespaceOpts {
} }
} }
// WithCapabilityIPRanges adds support for ip ranges
func WithCapabilityIPRanges(ipRanges []IPRanges) NamespaceOpts { func WithCapabilityIPRanges(ipRanges []IPRanges) NamespaceOpts {
return func(c *Namespace) error { return func(c *Namespace) error {
c.capabilityArgs["ipRanges"] = ipRanges c.capabilityArgs["ipRanges"] = ipRanges
@ -33,8 +34,7 @@ func WithCapabilityIPRanges(ipRanges []IPRanges) NamespaceOpts {
} }
} }
// WithCapabilityBandWitdh adds support for traffic shaping: // WithCapabilityBandWitdh adds support for bandwidth limits
// https://github.com/heptio/cni-plugins/tree/master/plugins/meta/bandwidth
func WithCapabilityBandWidth(bandWidth BandWidth) NamespaceOpts { func WithCapabilityBandWidth(bandWidth BandWidth) NamespaceOpts {
return func(c *Namespace) error { return func(c *Namespace) error {
c.capabilityArgs["bandwidth"] = bandWidth c.capabilityArgs["bandwidth"] = bandWidth
@ -50,6 +50,8 @@ func WithCapabilityDNS(dns DNS) NamespaceOpts {
} }
} }
// WithCapability support well-known capabilities
// https://www.cni.dev/docs/conventions/#well-known-capabilities
func WithCapability(name string, capability interface{}) NamespaceOpts { func WithCapability(name string, capability interface{}) NamespaceOpts {
return func(c *Namespace) error { return func(c *Namespace) error {
c.capabilityArgs[name] = capability c.capabilityArgs[name] = capability

View File

@ -21,6 +21,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"github.com/containernetworking/cni/pkg/types"
) )
type NotFoundError struct { type NotFoundError struct {
@ -41,8 +43,8 @@ func (e NoConfigsFoundError) Error() string {
} }
func ConfFromBytes(bytes []byte) (*NetworkConfig, error) { func ConfFromBytes(bytes []byte) (*NetworkConfig, error) {
conf := &NetworkConfig{Bytes: bytes} conf := &NetworkConfig{Bytes: bytes, Network: &types.NetConf{}}
if err := json.Unmarshal(bytes, &conf.Network); err != nil { if err := json.Unmarshal(bytes, conf.Network); err != nil {
return nil, fmt.Errorf("error parsing configuration: %w", err) return nil, fmt.Errorf("error parsing configuration: %w", err)
} }
if conf.Network.Type == "" { if conf.Network.Type == "" {

View File

@ -86,8 +86,8 @@ func (*PluginDecoder) Decode(jsonBytes []byte) (PluginInfo, error) {
// minor, and micro numbers or returns an error // minor, and micro numbers or returns an error
func ParseVersion(version string) (int, int, int, error) { func ParseVersion(version string) (int, int, int, error) {
var major, minor, micro int var major, minor, micro int
if version == "" { if version == "" { // special case: no version declared == v0.1.0
return -1, -1, -1, fmt.Errorf("invalid version %q: the version is empty", version) return 0, 1, 0, nil
} }
parts := strings.Split(version, ".") parts := strings.Split(version, ".")

View File

@ -12,7 +12,7 @@ import (
func rchcon(fpath, label string) error { func rchcon(fpath, label string) error {
return pwalkdir.Walk(fpath, func(p string, _ fs.DirEntry, _ error) error { return pwalkdir.Walk(fpath, func(p string, _ fs.DirEntry, _ error) error {
e := setFileLabel(p, label) e := lSetFileLabel(p, label)
// Walk a file tree can race with removal, so ignore ENOENT. // Walk a file tree can race with removal, so ignore ENOENT.
if errors.Is(e, os.ErrNotExist) { if errors.Is(e, os.ErrNotExist) {
return nil return nil

View File

@ -11,7 +11,7 @@ import (
func rchcon(fpath, label string) error { func rchcon(fpath, label string) error {
return pwalk.Walk(fpath, func(p string, _ os.FileInfo, _ error) error { return pwalk.Walk(fpath, func(p string, _ os.FileInfo, _ error) error {
e := setFileLabel(p, label) e := lSetFileLabel(p, label)
// Walk a file tree can race with removal, so ignore ENOENT. // Walk a file tree can race with removal, so ignore ENOENT.
if errors.Is(e, os.ErrNotExist) { if errors.Is(e, os.ErrNotExist) {
return nil return nil

View File

@ -53,19 +53,19 @@ func Serve(handlers *types.FaaSHandlers, config *types.FaaSConfig) {
} }
// System (auth) endpoints // System (auth) endpoints
r.HandleFunc("/system/functions", handlers.FunctionReader).Methods("GET") r.HandleFunc("/system/functions", handlers.FunctionReader).Methods(http.MethodGet)
r.HandleFunc("/system/functions", handlers.DeployHandler).Methods("POST") r.HandleFunc("/system/functions", handlers.DeployHandler).Methods(http.MethodPost)
r.HandleFunc("/system/functions", handlers.DeleteHandler).Methods("DELETE") r.HandleFunc("/system/functions", handlers.DeleteHandler).Methods(http.MethodDelete)
r.HandleFunc("/system/functions", handlers.UpdateHandler).Methods("PUT") r.HandleFunc("/system/functions", handlers.UpdateHandler).Methods(http.MethodPut)
r.HandleFunc("/system/function/{name:["+NameExpression+"]+}", handlers.ReplicaReader).Methods("GET") r.HandleFunc("/system/function/{name:["+NameExpression+"]+}", handlers.ReplicaReader).Methods(http.MethodGet)
r.HandleFunc("/system/scale-function/{name:["+NameExpression+"]+}", handlers.ReplicaUpdater).Methods("POST") r.HandleFunc("/system/scale-function/{name:["+NameExpression+"]+}", handlers.ReplicaUpdater).Methods(http.MethodPost)
r.HandleFunc("/system/info", handlers.InfoHandler).Methods("GET") r.HandleFunc("/system/info", handlers.InfoHandler).Methods(http.MethodGet)
r.HandleFunc("/system/secrets", handlers.SecretHandler).Methods(http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete) r.HandleFunc("/system/secrets", handlers.SecretHandler).Methods(http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete)
r.HandleFunc("/system/logs", handlers.LogHandler).Methods(http.MethodGet) r.HandleFunc("/system/logs", handlers.LogHandler).Methods(http.MethodGet)
r.HandleFunc("/system/namespaces", handlers.ListNamespaceHandler).Methods("GET") r.HandleFunc("/system/namespaces", handlers.ListNamespaceHandler).Methods(http.MethodGet)
// Open endpoints // Open endpoints
r.HandleFunc("/function/{name:["+NameExpression+"]+}", handlers.FunctionProxy) r.HandleFunc("/function/{name:["+NameExpression+"]+}", handlers.FunctionProxy)
@ -73,19 +73,19 @@ func Serve(handlers *types.FaaSHandlers, config *types.FaaSConfig) {
r.HandleFunc("/function/{name:["+NameExpression+"]+}/{params:.*}", handlers.FunctionProxy) r.HandleFunc("/function/{name:["+NameExpression+"]+}/{params:.*}", handlers.FunctionProxy)
if handlers.HealthHandler != nil { if handlers.HealthHandler != nil {
r.HandleFunc("/healthz", handlers.HealthHandler).Methods("GET") r.HandleFunc("/healthz", handlers.HealthHandler).Methods(http.MethodGet)
} }
readTimeout := config.ReadTimeout readTimeout := config.ReadTimeout
writeTimeout := config.WriteTimeout writeTimeout := config.WriteTimeout
tcpPort := 8080 port := 8080
if config.TCPPort != nil { if config.TCPPort != nil {
tcpPort = *config.TCPPort port = *config.TCPPort
} }
s := &http.Server{ s := &http.Server{
Addr: fmt.Sprintf(":%d", tcpPort), Addr: fmt.Sprintf(":%d", port),
ReadTimeout: readTimeout, ReadTimeout: readTimeout,
WriteTimeout: writeTimeout, WriteTimeout: writeTimeout,
MaxHeaderBytes: http.DefaultMaxHeaderBytes, // 1MB - can be overridden by setting Server.MaxHeaderBytes. MaxHeaderBytes: http.DefaultMaxHeaderBytes, // 1MB - can be overridden by setting Server.MaxHeaderBytes.

13
vendor/github.com/spf13/cobra/MAINTAINERS generated vendored Normal file
View File

@ -0,0 +1,13 @@
maintainers:
- spf13
- johnSchnake
- jpmcb
- marckhouzam
inactive:
- anthonyfok
- bep
- bogem
- broady
- eparis
- jharshman
- wfernandes

View File

@ -9,11 +9,11 @@ ifeq (, $(shell which richgo))
$(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo") $(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo")
endif endif
.PHONY: fmt lint test cobra_generator install_deps clean .PHONY: fmt lint test install_deps clean
default: all default: all
all: fmt test cobra_generator all: fmt test
fmt: fmt:
$(info ******************** checking formatting ********************) $(info ******************** checking formatting ********************)
@ -23,15 +23,10 @@ lint:
$(info ******************** running lint tools ********************) $(info ******************** running lint tools ********************)
golangci-lint run -v golangci-lint run -v
test: install_deps lint test: install_deps
$(info ******************** running tests ********************) $(info ******************** running tests ********************)
richgo test -v ./... richgo test -v ./...
cobra_generator: install_deps
$(info ******************** building generator ********************)
mkdir -p $(BIN)
make -C cobra all
install_deps: install_deps:
$(info ******************** downloading dependencies ********************) $(info ******************** downloading dependencies ********************)
go get -v ./... go get -v ./...

View File

@ -1,52 +1,26 @@
![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png) ![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png)
Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files. Cobra is a library for creating powerful modern CLI applications.
Cobra is used in many Go projects such as [Kubernetes](http://kubernetes.io/), Cobra is used in many Go projects such as [Kubernetes](http://kubernetes.io/),
[Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to [Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to
name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra. name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra.
[![](https://img.shields.io/github/workflow/status/spf13/cobra/Test?longCache=tru&label=Test&logo=github%20actions&logoColor=fff)](https://github.com/spf13/cobra/actions?query=workflow%3ATest) [![](https://img.shields.io/github/workflow/status/spf13/cobra/Test?longCache=tru&label=Test&logo=github%20actions&logoColor=fff)](https://github.com/spf13/cobra/actions?query=workflow%3ATest)
[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra) [![Go Reference](https://pkg.go.dev/badge/github.com/spf13/cobra.svg)](https://pkg.go.dev/github.com/spf13/cobra)
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra) [![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra)
[![Slack](https://img.shields.io/badge/Slack-cobra-brightgreen)](https://gophers.slack.com/archives/CD3LP1199) [![Slack](https://img.shields.io/badge/Slack-cobra-brightgreen)](https://gophers.slack.com/archives/CD3LP1199)
# Table of Contents
- [Overview](#overview)
- [Concepts](#concepts)
* [Commands](#commands)
* [Flags](#flags)
- [Installing](#installing)
- [Usage](#usage)
* [Using the Cobra Generator](user_guide.md#using-the-cobra-generator)
* [Using the Cobra Library](user_guide.md#using-the-cobra-library)
* [Working with Flags](user_guide.md#working-with-flags)
* [Positional and Custom Arguments](user_guide.md#positional-and-custom-arguments)
* [Example](user_guide.md#example)
* [Help Command](user_guide.md#help-command)
* [Usage Message](user_guide.md#usage-message)
* [PreRun and PostRun Hooks](user_guide.md#prerun-and-postrun-hooks)
* [Suggestions when "unknown command" happens](user_guide.md#suggestions-when-unknown-command-happens)
* [Generating documentation for your command](user_guide.md#generating-documentation-for-your-command)
* [Generating shell completions](user_guide.md#generating-shell-completions)
- [Contributing](CONTRIBUTING.md)
- [License](#license)
# Overview # Overview
Cobra is a library providing a simple interface to create powerful modern CLI Cobra is a library providing a simple interface to create powerful modern CLI
interfaces similar to git & go tools. interfaces similar to git & go tools.
Cobra is also an application that will generate your application scaffolding to rapidly
develop a Cobra-based application.
Cobra provides: Cobra provides:
* Easy subcommand-based CLIs: `app server`, `app fetch`, etc. * Easy subcommand-based CLIs: `app server`, `app fetch`, etc.
* Fully POSIX-compliant flags (including short & long versions) * Fully POSIX-compliant flags (including short & long versions)
* Nested subcommands * Nested subcommands
* Global, local and cascading flags * Global, local and cascading flags
* Easy generation of applications & commands with `cobra init appname` & `cobra add cmdname`
* Intelligent suggestions (`app srver`... did you mean `app server`?) * Intelligent suggestions (`app srver`... did you mean `app server`?)
* Automatic help generation for commands and flags * Automatic help generation for commands and flags
* Automatic help flag recognition of `-h`, `--help`, etc. * Automatic help flag recognition of `-h`, `--help`, etc.
@ -54,7 +28,7 @@ Cobra provides:
* Automatically generated man pages for your application * Automatically generated man pages for your application
* Command aliases so you can change things without breaking them * Command aliases so you can change things without breaking them
* The flexibility to define your own help, usage, etc. * The flexibility to define your own help, usage, etc.
* Optional tight integration with [viper](http://github.com/spf13/viper) for 12-factor apps * Optional seamless integration with [viper](http://github.com/spf13/viper) for 12-factor apps
# Concepts # Concepts
@ -88,7 +62,7 @@ have children commands and optionally run an action.
In the example above, 'server' is the command. In the example above, 'server' is the command.
[More about cobra.Command](https://godoc.org/github.com/spf13/cobra#Command) [More about cobra.Command](https://pkg.go.dev/github.com/spf13/cobra#Command)
## Flags ## Flags
@ -105,10 +79,11 @@ which maintains the same interface while adding POSIX compliance.
# Installing # Installing
Using Cobra is easy. First, use `go get` to install the latest version Using Cobra is easy. First, use `go get` to install the latest version
of the library. This command will install the `cobra` generator executable of the library.
along with the library and its dependencies:
go get -u github.com/spf13/cobra ```
go get -u github.com/spf13/cobra@latest
```
Next, include Cobra in your application: Next, include Cobra in your application:
@ -117,8 +92,19 @@ import "github.com/spf13/cobra"
``` ```
# Usage # Usage
`cobra-cli` is a command line program to generate cobra applications and command files.
It will bootstrap your application scaffolding to rapidly
develop a Cobra-based application. It is the easiest way to incorporate Cobra into your application.
See [User Guide](user_guide.md). It can be installed by running:
```
go install github.com/spf13/cobra-cli@latest
```
For complete details on using the Cobra-CLI generator, please read [The Cobra Generator README](https://github.com/spf13/cobra-cli/blob/master/README.md)
For complete details on using the Cobra library, please read the [The Cobra User Guide](user_guide.md).
# License # License

View File

@ -107,3 +107,15 @@ func RangeArgs(min int, max int) PositionalArgs {
return nil return nil
} }
} }
// MatchAll allows combining several PositionalArgs to work in concert.
func MatchAll(pargs ...PositionalArgs) PositionalArgs {
return func(cmd *Command, args []string) error {
for _, parg := range pargs {
if err := parg(cmd, args); err != nil {
return err
}
}
return nil
}
}

View File

@ -24,7 +24,7 @@ func writePreamble(buf io.StringWriter, name string) {
WriteStringAndCheck(buf, fmt.Sprintf(` WriteStringAndCheck(buf, fmt.Sprintf(`
__%[1]s_debug() __%[1]s_debug()
{ {
if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then if [[ -n ${BASH_COMP_DEBUG_FILE:-} ]]; then
echo "$*" >> "${BASH_COMP_DEBUG_FILE}" echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
fi fi
} }
@ -134,7 +134,7 @@ __%[1]s_handle_go_custom_completion()
$filteringCmd $filteringCmd
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
# File completion for directories only # File completion for directories only
local subDir local subdir
# Use printf to strip any trailing newline # Use printf to strip any trailing newline
subdir=$(printf "%%s" "${out[0]}") subdir=$(printf "%%s" "${out[0]}")
if [ -n "$subdir" ]; then if [ -n "$subdir" ]; then
@ -187,13 +187,19 @@ __%[1]s_handle_reply()
PREFIX="" PREFIX=""
cur="${cur#*=}" cur="${cur#*=}"
${flags_completion[${index}]} ${flags_completion[${index}]}
if [ -n "${ZSH_VERSION}" ]; then if [ -n "${ZSH_VERSION:-}" ]; then
# zsh completion needs --flag= prefix # zsh completion needs --flag= prefix
eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )" eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
fi fi
fi fi
fi fi
return 0;
if [[ -z "${flag_parsing_disabled}" ]]; then
# If flag parsing is enabled, we have completed the flags and can return.
# If flag parsing is disabled, we may not know all (or any) of the flags, so we fallthrough
# to possibly call handle_go_custom_completion.
return 0;
fi
;; ;;
esac esac
@ -232,13 +238,13 @@ __%[1]s_handle_reply()
fi fi
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
if declare -F __%[1]s_custom_func >/dev/null; then if declare -F __%[1]s_custom_func >/dev/null; then
# try command name qualified custom func # try command name qualified custom func
__%[1]s_custom_func __%[1]s_custom_func
else else
# otherwise fall back to unqualified for compatibility # otherwise fall back to unqualified for compatibility
declare -F __custom_func >/dev/null && __custom_func declare -F __custom_func >/dev/null && __custom_func
fi fi
fi fi
# available in bash-completion >= 2, not always present on macOS # available in bash-completion >= 2, not always present on macOS
@ -272,7 +278,7 @@ __%[1]s_handle_flag()
# if a command required a flag, and we found it, unset must_have_one_flag() # if a command required a flag, and we found it, unset must_have_one_flag()
local flagname=${words[c]} local flagname=${words[c]}
local flagvalue local flagvalue=""
# if the word contained an = # if the word contained an =
if [[ ${words[c]} == *"="* ]]; then if [[ ${words[c]} == *"="* ]]; then
flagvalue=${flagname#*=} # take in as flagvalue after the = flagvalue=${flagname#*=} # take in as flagvalue after the =
@ -291,7 +297,7 @@ __%[1]s_handle_flag()
# keep flag value with flagname as flaghash # keep flag value with flagname as flaghash
# flaghash variable is an associative array which is only supported in bash > 3. # flaghash variable is an associative array which is only supported in bash > 3.
if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then
if [ -n "${flagvalue}" ] ; then if [ -n "${flagvalue}" ] ; then
flaghash[${flagname}]=${flagvalue} flaghash[${flagname}]=${flagvalue}
elif [ -n "${words[ $((c+1)) ]}" ] ; then elif [ -n "${words[ $((c+1)) ]}" ] ; then
@ -303,7 +309,7 @@ __%[1]s_handle_flag()
# skip the argument to a two word flag # skip the argument to a two word flag
if [[ ${words[c]} != *"="* ]] && __%[1]s_contains_word "${words[c]}" "${two_word_flags[@]}"; then if [[ ${words[c]} != *"="* ]] && __%[1]s_contains_word "${words[c]}" "${two_word_flags[@]}"; then
__%[1]s_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument" __%[1]s_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
c=$((c+1)) c=$((c+1))
# if we are looking for a flags value, don't show commands # if we are looking for a flags value, don't show commands
if [[ $c -eq $cword ]]; then if [[ $c -eq $cword ]]; then
@ -363,7 +369,7 @@ __%[1]s_handle_word()
__%[1]s_handle_command __%[1]s_handle_command
elif __%[1]s_contains_word "${words[c]}" "${command_aliases[@]}"; then elif __%[1]s_contains_word "${words[c]}" "${command_aliases[@]}"; then
# aliashash variable is an associative array which is only supported in bash > 3. # aliashash variable is an associative array which is only supported in bash > 3.
if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then
words[c]=${aliashash[${words[c]}]} words[c]=${aliashash[${words[c]}]}
__%[1]s_handle_command __%[1]s_handle_command
else else
@ -394,6 +400,7 @@ func writePostscript(buf io.StringWriter, name string) {
fi fi
local c=0 local c=0
local flag_parsing_disabled=
local flags=() local flags=()
local two_word_flags=() local two_word_flags=()
local local_nonpersistent_flags=() local local_nonpersistent_flags=()
@ -403,8 +410,8 @@ func writePostscript(buf io.StringWriter, name string) {
local command_aliases=() local command_aliases=()
local must_have_one_flag=() local must_have_one_flag=()
local must_have_one_noun=() local must_have_one_noun=()
local has_completion_function local has_completion_function=""
local last_command local last_command=""
local nouns=() local nouns=()
local noun_aliases=() local noun_aliases=()
@ -535,6 +542,11 @@ func writeFlags(buf io.StringWriter, cmd *Command) {
flags_completion=() flags_completion=()
`) `)
if cmd.DisableFlagParsing {
WriteStringAndCheck(buf, " flag_parsing_disabled=1\n")
}
localNonPersistentFlags := cmd.LocalNonPersistentFlags() localNonPersistentFlags := cmd.LocalNonPersistentFlags()
cmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) { cmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
if nonCompletableFlag(flag) { if nonCompletableFlag(flag) {
@ -609,7 +621,7 @@ func writeCmdAliases(buf io.StringWriter, cmd *Command) {
sort.Strings(cmd.Aliases) sort.Strings(cmd.Aliases)
WriteStringAndCheck(buf, fmt.Sprint(` if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then`, "\n")) WriteStringAndCheck(buf, fmt.Sprint(` if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then`, "\n"))
for _, value := range cmd.Aliases { for _, value := range cmd.Aliases {
WriteStringAndCheck(buf, fmt.Sprintf(" command_aliases+=(%q)\n", value)) WriteStringAndCheck(buf, fmt.Sprintf(" command_aliases+=(%q)\n", value))
WriteStringAndCheck(buf, fmt.Sprintf(" aliashash[%q]=%q\n", value, cmd.Name())) WriteStringAndCheck(buf, fmt.Sprintf(" aliashash[%q]=%q\n", value, cmd.Name()))

View File

@ -138,13 +138,42 @@ __%[1]s_process_completion_results() {
_filedir -d _filedir -d
fi fi
else else
__%[1]s_handle_standard_completion_case __%[1]s_handle_completion_types
fi fi
__%[1]s_handle_special_char "$cur" : __%[1]s_handle_special_char "$cur" :
__%[1]s_handle_special_char "$cur" = __%[1]s_handle_special_char "$cur" =
} }
__%[1]s_handle_completion_types() {
__%[1]s_debug "__%[1]s_handle_completion_types: COMP_TYPE is $COMP_TYPE"
case $COMP_TYPE in
37|42)
# Type: menu-complete/menu-complete-backward and insert-completions
# If the user requested inserting one completion at a time, or all
# completions at once on the command-line we must remove the descriptions.
# https://github.com/spf13/cobra/issues/1508
local tab comp
tab=$(printf '\t')
while IFS='' read -r comp; do
# Strip any description
comp=${comp%%%%$tab*}
# Only consider the completions that match
comp=$(compgen -W "$comp" -- "$cur")
if [ -n "$comp" ]; then
COMPREPLY+=("$comp")
fi
done < <(printf "%%s\n" "${out[@]}")
;;
*)
# Type: complete (normal completion)
__%[1]s_handle_standard_completion_case
;;
esac
}
__%[1]s_handle_standard_completion_case() { __%[1]s_handle_standard_completion_case() {
local tab comp local tab comp
tab=$(printf '\t') tab=$(printf '\t')

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
package cobra package cobra

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package cobra package cobra

View File

@ -93,6 +93,8 @@ type CompletionOptions struct {
// DisableDescriptions turns off all completion descriptions for shells // DisableDescriptions turns off all completion descriptions for shells
// that support them // that support them
DisableDescriptions bool DisableDescriptions bool
// HiddenDefaultCmd makes the default 'completion' command hidden
HiddenDefaultCmd bool
} }
// NoFileCompletions can be used to disable file completion for commands that should // NoFileCompletions can be used to disable file completion for commands that should
@ -226,7 +228,17 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
if c.Root().TraverseChildren { if c.Root().TraverseChildren {
finalCmd, finalArgs, err = c.Root().Traverse(trimmedArgs) finalCmd, finalArgs, err = c.Root().Traverse(trimmedArgs)
} else { } else {
finalCmd, finalArgs, err = c.Root().Find(trimmedArgs) // For Root commands that don't specify any value for their Args fields, when we call
// Find(), if those Root commands don't have any sub-commands, they will accept arguments.
// However, because we have added the __complete sub-command in the current code path, the
// call to Find() -> legacyArgs() will return an error if there are any arguments.
// To avoid this, we first remove the __complete command to get back to having no sub-commands.
rootCmd := c.Root()
if len(rootCmd.Commands()) == 1 {
rootCmd.RemoveCommand(c)
}
finalCmd, finalArgs, err = rootCmd.Find(trimmedArgs)
} }
if err != nil { if err != nil {
// Unable to find the real command. E.g., <program> someInvalidCmd <TAB> // Unable to find the real command. E.g., <program> someInvalidCmd <TAB>
@ -266,6 +278,12 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
} }
} }
// We only remove the flags from the arguments if DisableFlagParsing is not set.
// This is important for commands which have requested to do their own flag completion.
if !finalCmd.DisableFlagParsing {
finalArgs = finalCmd.Flags().Args()
}
if flag != nil && flagCompletion { if flag != nil && flagCompletion {
// Check if we are completing a flag value subject to annotations // Check if we are completing a flag value subject to annotations
if validExts, present := flag.Annotations[BashCompFilenameExt]; present { if validExts, present := flag.Annotations[BashCompFilenameExt]; present {
@ -290,12 +308,16 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
} }
} }
var completions []string
var directive ShellCompDirective
// Note that we want to perform flagname completion even if finalCmd.DisableFlagParsing==true;
// doing this allows for completion of persistant flag names even for commands that disable flag parsing.
//
// When doing completion of a flag name, as soon as an argument starts with // When doing completion of a flag name, as soon as an argument starts with
// a '-' we know it is a flag. We cannot use isFlagArg() here as it requires // a '-' we know it is a flag. We cannot use isFlagArg() here as it requires
// the flag name to be complete // the flag name to be complete
if flag == nil && len(toComplete) > 0 && toComplete[0] == '-' && !strings.Contains(toComplete, "=") && flagCompletion { if flag == nil && len(toComplete) > 0 && toComplete[0] == '-' && !strings.Contains(toComplete, "=") && flagCompletion {
var completions []string
// First check for required flags // First check for required flags
completions = completeRequireFlags(finalCmd, toComplete) completions = completeRequireFlags(finalCmd, toComplete)
@ -322,86 +344,86 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
}) })
} }
directive := ShellCompDirectiveNoFileComp directive = ShellCompDirectiveNoFileComp
if len(completions) == 1 && strings.HasSuffix(completions[0], "=") { if len(completions) == 1 && strings.HasSuffix(completions[0], "=") {
// If there is a single completion, the shell usually adds a space // If there is a single completion, the shell usually adds a space
// after the completion. We don't want that if the flag ends with an = // after the completion. We don't want that if the flag ends with an =
directive = ShellCompDirectiveNoSpace directive = ShellCompDirectiveNoSpace
} }
return finalCmd, completions, directive, nil
}
// We only remove the flags from the arguments if DisableFlagParsing is not set. if !finalCmd.DisableFlagParsing {
// This is important for commands which have requested to do their own flag completion. // If DisableFlagParsing==false, we have completed the flags as known by Cobra;
if !finalCmd.DisableFlagParsing { // we can return what we found.
finalArgs = finalCmd.Flags().Args() // If DisableFlagParsing==true, Cobra may not be aware of all flags, so we
} // let the logic continue to see if ValidArgsFunction needs to be called.
return finalCmd, completions, directive, nil
var completions []string
directive := ShellCompDirectiveDefault
if flag == nil {
foundLocalNonPersistentFlag := false
// If TraverseChildren is true on the root command we don't check for
// local flags because we can use a local flag on a parent command
if !finalCmd.Root().TraverseChildren {
// Check if there are any local, non-persistent flags on the command-line
localNonPersistentFlags := finalCmd.LocalNonPersistentFlags()
finalCmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
if localNonPersistentFlags.Lookup(flag.Name) != nil && flag.Changed {
foundLocalNonPersistentFlag = true
}
})
} }
} else {
// Complete subcommand names, including the help command directive = ShellCompDirectiveDefault
if len(finalArgs) == 0 && !foundLocalNonPersistentFlag { if flag == nil {
// We only complete sub-commands if: foundLocalNonPersistentFlag := false
// - there are no arguments on the command-line and // If TraverseChildren is true on the root command we don't check for
// - there are no local, non-persistent flags on the command-line or TraverseChildren is true // local flags because we can use a local flag on a parent command
for _, subCmd := range finalCmd.Commands() { if !finalCmd.Root().TraverseChildren {
if subCmd.IsAvailableCommand() || subCmd == finalCmd.helpCommand { // Check if there are any local, non-persistent flags on the command-line
if strings.HasPrefix(subCmd.Name(), toComplete) { localNonPersistentFlags := finalCmd.LocalNonPersistentFlags()
completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short)) finalCmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
if localNonPersistentFlags.Lookup(flag.Name) != nil && flag.Changed {
foundLocalNonPersistentFlag = true
}
})
}
// Complete subcommand names, including the help command
if len(finalArgs) == 0 && !foundLocalNonPersistentFlag {
// We only complete sub-commands if:
// - there are no arguments on the command-line and
// - there are no local, non-persistent flags on the command-line or TraverseChildren is true
for _, subCmd := range finalCmd.Commands() {
if subCmd.IsAvailableCommand() || subCmd == finalCmd.helpCommand {
if strings.HasPrefix(subCmd.Name(), toComplete) {
completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
}
directive = ShellCompDirectiveNoFileComp
} }
directive = ShellCompDirectiveNoFileComp
} }
} }
}
// Complete required flags even without the '-' prefix // Complete required flags even without the '-' prefix
completions = append(completions, completeRequireFlags(finalCmd, toComplete)...) completions = append(completions, completeRequireFlags(finalCmd, toComplete)...)
// Always complete ValidArgs, even if we are completing a subcommand name. // Always complete ValidArgs, even if we are completing a subcommand name.
// This is for commands that have both subcommands and ValidArgs. // This is for commands that have both subcommands and ValidArgs.
if len(finalCmd.ValidArgs) > 0 { if len(finalCmd.ValidArgs) > 0 {
if len(finalArgs) == 0 { if len(finalArgs) == 0 {
// ValidArgs are only for the first argument // ValidArgs are only for the first argument
for _, validArg := range finalCmd.ValidArgs { for _, validArg := range finalCmd.ValidArgs {
if strings.HasPrefix(validArg, toComplete) { if strings.HasPrefix(validArg, toComplete) {
completions = append(completions, validArg) completions = append(completions, validArg)
}
} }
} directive = ShellCompDirectiveNoFileComp
directive = ShellCompDirectiveNoFileComp
// If no completions were found within commands or ValidArgs, // If no completions were found within commands or ValidArgs,
// see if there are any ArgAliases that should be completed. // see if there are any ArgAliases that should be completed.
if len(completions) == 0 { if len(completions) == 0 {
for _, argAlias := range finalCmd.ArgAliases { for _, argAlias := range finalCmd.ArgAliases {
if strings.HasPrefix(argAlias, toComplete) { if strings.HasPrefix(argAlias, toComplete) {
completions = append(completions, argAlias) completions = append(completions, argAlias)
}
} }
} }
} }
// If there are ValidArgs specified (even if they don't match), we stop completion.
// Only one of ValidArgs or ValidArgsFunction can be used for a single command.
return finalCmd, completions, directive, nil
} }
// If there are ValidArgs specified (even if they don't match), we stop completion. // Let the logic continue so as to add any ValidArgsFunction completions,
// Only one of ValidArgs or ValidArgsFunction can be used for a single command. // even if we already found sub-commands.
return finalCmd, completions, directive, nil // This is for commands that have subcommands but also specify a ValidArgsFunction.
} }
// Let the logic continue so as to add any ValidArgsFunction completions,
// even if we already found sub-commands.
// This is for commands that have subcommands but also specify a ValidArgsFunction.
} }
// Find the completion function for the flag or command // Find the completion function for the flag or command
@ -589,39 +611,43 @@ func (c *Command) initDefaultCompletionCmd() {
completionCmd := &Command{ completionCmd := &Command{
Use: compCmdName, Use: compCmdName,
Short: "generate the autocompletion script for the specified shell", Short: "Generate the autocompletion script for the specified shell",
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for %[1]s for the specified shell.
Generate the autocompletion script for %[1]s for the specified shell.
See each sub-command's help for details on how to use the generated script. See each sub-command's help for details on how to use the generated script.
`, c.Root().Name()), `, c.Root().Name()),
Args: NoArgs, Args: NoArgs,
ValidArgsFunction: NoFileCompletions, ValidArgsFunction: NoFileCompletions,
Hidden: c.CompletionOptions.HiddenDefaultCmd,
} }
c.AddCommand(completionCmd) c.AddCommand(completionCmd)
out := c.OutOrStdout() out := c.OutOrStdout()
noDesc := c.CompletionOptions.DisableDescriptions noDesc := c.CompletionOptions.DisableDescriptions
shortDesc := "generate the autocompletion script for %s" shortDesc := "Generate the autocompletion script for %s"
bash := &Command{ bash := &Command{
Use: "bash", Use: "bash",
Short: fmt.Sprintf(shortDesc, "bash"), Short: fmt.Sprintf(shortDesc, "bash"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for the bash shell.
Generate the autocompletion script for the bash shell.
This script depends on the 'bash-completion' package. This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager. If it is not installed already, you can install it via your OS's package manager.
To load completions in your current shell session: To load completions in your current shell session:
$ source <(%[1]s completion bash)
source <(%[1]s completion bash)
To load completions for every new session, execute once: To load completions for every new session, execute once:
Linux:
$ %[1]s completion bash > /etc/bash_completion.d/%[1]s #### Linux:
MacOS:
$ %[1]s completion bash > /usr/local/etc/bash_completion.d/%[1]s %[1]s completion bash > /etc/bash_completion.d/%[1]s
#### macOS:
%[1]s completion bash > /usr/local/etc/bash_completion.d/%[1]s
You will need to start a new shell for this setup to take effect. You will need to start a new shell for this setup to take effect.
`, c.Root().Name()), `, c.Root().Name()),
Args: NoArgs, Args: NoArgs,
DisableFlagsInUseLine: true, DisableFlagsInUseLine: true,
ValidArgsFunction: NoFileCompletions, ValidArgsFunction: NoFileCompletions,
@ -636,19 +662,22 @@ You will need to start a new shell for this setup to take effect.
zsh := &Command{ zsh := &Command{
Use: "zsh", Use: "zsh",
Short: fmt.Sprintf(shortDesc, "zsh"), Short: fmt.Sprintf(shortDesc, "zsh"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for the zsh shell.
Generate the autocompletion script for the zsh shell.
If shell completion is not already enabled in your environment you will need If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once: to enable it. You can execute the following once:
$ echo "autoload -U compinit; compinit" >> ~/.zshrc echo "autoload -U compinit; compinit" >> ~/.zshrc
To load completions for every new session, execute once: To load completions for every new session, execute once:
# Linux:
$ %[1]s completion zsh > "${fpath[1]}/_%[1]s" #### Linux:
# macOS:
$ %[1]s completion zsh > /usr/local/share/zsh/site-functions/_%[1]s %[1]s completion zsh > "${fpath[1]}/_%[1]s"
#### macOS:
%[1]s completion zsh > /usr/local/share/zsh/site-functions/_%[1]s
You will need to start a new shell for this setup to take effect. You will need to start a new shell for this setup to take effect.
`, c.Root().Name()), `, c.Root().Name()),
@ -668,14 +697,15 @@ You will need to start a new shell for this setup to take effect.
fish := &Command{ fish := &Command{
Use: "fish", Use: "fish",
Short: fmt.Sprintf(shortDesc, "fish"), Short: fmt.Sprintf(shortDesc, "fish"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for the fish shell.
Generate the autocompletion script for the fish shell.
To load completions in your current shell session: To load completions in your current shell session:
$ %[1]s completion fish | source
%[1]s completion fish | source
To load completions for every new session, execute once: To load completions for every new session, execute once:
$ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish
%[1]s completion fish > ~/.config/fish/completions/%[1]s.fish
You will need to start a new shell for this setup to take effect. You will need to start a new shell for this setup to take effect.
`, c.Root().Name()), `, c.Root().Name()),
@ -692,11 +722,11 @@ You will need to start a new shell for this setup to take effect.
powershell := &Command{ powershell := &Command{
Use: "powershell", Use: "powershell",
Short: fmt.Sprintf(shortDesc, "powershell"), Short: fmt.Sprintf(shortDesc, "powershell"),
Long: fmt.Sprintf(` Long: fmt.Sprintf(`Generate the autocompletion script for powershell.
Generate the autocompletion script for powershell.
To load completions in your current shell session: To load completions in your current shell session:
PS C:\> %[1]s completion powershell | Out-String | Invoke-Expression
%[1]s completion powershell | Out-String | Invoke-Expression
To load completions for every new session, add the output of the above command To load completions for every new session, add the output of the above command
to your powershell profile. to your powershell profile.

View File

@ -50,7 +50,7 @@ Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock {
if ($Command.Length -gt $CursorPosition) { if ($Command.Length -gt $CursorPosition) {
$Command=$Command.Substring(0,$CursorPosition) $Command=$Command.Substring(0,$CursorPosition)
} }
__%[1]s_debug "Truncated command: $Command" __%[1]s_debug "Truncated command: $Command"
$ShellCompDirectiveError=%[3]d $ShellCompDirectiveError=%[3]d
$ShellCompDirectiveNoSpace=%[4]d $ShellCompDirectiveNoSpace=%[4]d
@ -58,7 +58,7 @@ Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock {
$ShellCompDirectiveFilterFileExt=%[6]d $ShellCompDirectiveFilterFileExt=%[6]d
$ShellCompDirectiveFilterDirs=%[7]d $ShellCompDirectiveFilterDirs=%[7]d
# Prepare the command to request completions for the program. # Prepare the command to request completions for the program.
# Split the command at the first space to separate the program and arguments. # Split the command at the first space to separate the program and arguments.
$Program,$Arguments = $Command.Split(" ",2) $Program,$Arguments = $Command.Split(" ",2)
$RequestComp="$Program %[2]s $Arguments" $RequestComp="$Program %[2]s $Arguments"
@ -233,7 +233,7 @@ Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock {
Default { Default {
# Like MenuComplete but we don't want to add a space here because # Like MenuComplete but we don't want to add a space here because
# the user need to press space anyway to get the completion. # the user need to press space anyway to get the completion.
# Description will not be shown because thats not possible with TabCompleteNext # Description will not be shown because that's not possible with TabCompleteNext
[System.Management.Automation.CompletionResult]::new($($comp.Name | __%[1]s_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)") [System.Management.Automation.CompletionResult]::new($($comp.Name | __%[1]s_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
} }
} }

View File

@ -4,6 +4,7 @@
- [Bleve](http://www.blevesearch.com/) - [Bleve](http://www.blevesearch.com/)
- [CockroachDB](http://www.cockroachlabs.com/) - [CockroachDB](http://www.cockroachlabs.com/)
- [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) - [Cosmos SDK](https://github.com/cosmos/cosmos-sdk)
- [Datree](https://github.com/datreeio/datree)
- [Delve](https://github.com/derekparker/delve) - [Delve](https://github.com/derekparker/delve)
- [Docker (distribution)](https://github.com/docker/distribution) - [Docker (distribution)](https://github.com/docker/distribution)
- [Etcd](https://etcd.io/) - [Etcd](https://etcd.io/)
@ -14,25 +15,37 @@
- [GitHub Labeler](https://github.com/erdaltsksn/gh-label) - [GitHub Labeler](https://github.com/erdaltsksn/gh-label)
- [Golangci-lint](https://golangci-lint.run) - [Golangci-lint](https://golangci-lint.run)
- [GopherJS](http://www.gopherjs.org/) - [GopherJS](http://www.gopherjs.org/)
- [GoReleaser](https://goreleaser.com)
- [Helm](https://helm.sh) - [Helm](https://helm.sh)
- [Hugo](https://gohugo.io) - [Hugo](https://gohugo.io)
- [Infracost](https://github.com/infracost/infracost)
- [Istio](https://istio.io) - [Istio](https://istio.io)
- [Kool](https://github.com/kool-dev/kool) - [Kool](https://github.com/kool-dev/kool)
- [Kubernetes](http://kubernetes.io/) - [Kubernetes](http://kubernetes.io/)
- [Linkerd](https://linkerd.io/) - [Linkerd](https://linkerd.io/)
- [Mattermost-server](https://github.com/mattermost/mattermost-server) - [Mattermost-server](https://github.com/mattermost/mattermost-server)
- [Mercure](https://mercure.rocks/)
- [Meroxa CLI](https://github.com/meroxa/cli)
- [Metal Stack CLI](https://github.com/metal-stack/metalctl) - [Metal Stack CLI](https://github.com/metal-stack/metalctl)
- [Moby (former Docker)](https://github.com/moby/moby) - [Moby (former Docker)](https://github.com/moby/moby)
- [Moldy](https://github.com/Moldy-Community/moldy)
- [Multi-gitter](https://github.com/lindell/multi-gitter)
- [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack) - [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
- [nFPM](https://nfpm.goreleaser.com)
- [OpenShift](https://www.openshift.com/) - [OpenShift](https://www.openshift.com/)
- [Ory Hydra](https://github.com/ory/hydra) - [Ory Hydra](https://github.com/ory/hydra)
- [Ory Kratos](https://github.com/ory/kratos) - [Ory Kratos](https://github.com/ory/kratos)
- [Pixie](https://github.com/pixie-io/pixie)
- [Pouch](https://github.com/alibaba/pouch) - [Pouch](https://github.com/alibaba/pouch)
- [ProjectAtomic (enterprise)](http://www.projectatomic.io/) - [ProjectAtomic (enterprise)](http://www.projectatomic.io/)
- [Prototool](https://github.com/uber/prototool) - [Prototool](https://github.com/uber/prototool)
- [QRcp](https://github.com/claudiodangelis/qrcp)
- [Random](https://github.com/erdaltsksn/random) - [Random](https://github.com/erdaltsksn/random)
- [Rclone](https://rclone.org/) - [Rclone](https://rclone.org/)
- [Scaleway CLI](https://github.com/scaleway/scaleway-cli)
- [Skaffold](https://skaffold.dev/) - [Skaffold](https://skaffold.dev/)
- [Tendermint](https://github.com/tendermint/tendermint) - [Tendermint](https://github.com/tendermint/tendermint)
- [Twitch CLI](https://github.com/twitchdev/twitch-cli) - [Twitch CLI](https://github.com/twitchdev/twitch-cli)
- [UpCloud CLI (`upctl`)](https://github.com/UpCloudLtd/upcloud-cli)
- VMware's [Tanzu Community Edition](https://github.com/vmware-tanzu/community-edition) & [Tanzu Framework](https://github.com/vmware-tanzu/tanzu-framework)
- [Werf](https://werf.io/) - [Werf](https://werf.io/)

View File

@ -16,10 +16,12 @@ If you do not wish to use the default `completion` command, you can choose to
provide your own, which will take precedence over the default one. (This also provides provide your own, which will take precedence over the default one. (This also provides
backwards-compatibility with programs that already have their own `completion` command.) backwards-compatibility with programs that already have their own `completion` command.)
If you are using the generator, you can create a completion command by running If you are using the `cobra-cli` generator,
which can be found at [spf13/cobra-cli](https://github.com/spf13/cobra-cli),
you can create a completion command by running
```bash ```bash
cobra add completion cobra-cli add completion
``` ```
and then modifying the generated `cmd/completion.go` file to look something like this and then modifying the generated `cmd/completion.go` file to look something like this
(writing the shell script to stdout allows the most flexible use): (writing the shell script to stdout allows the most flexible use):
@ -28,17 +30,17 @@ and then modifying the generated `cmd/completion.go` file to look something like
var completionCmd = &cobra.Command{ var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]", Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script", Short: "Generate completion script",
Long: `To load completions: Long: fmt.Sprintf(`To load completions:
Bash: Bash:
$ source <(yourprogram completion bash) $ source <(%[1]s completion bash)
# To load completions for each session, execute once: # To load completions for each session, execute once:
# Linux: # Linux:
$ yourprogram completion bash > /etc/bash_completion.d/yourprogram $ %[1]s completion bash > /etc/bash_completion.d/%[1]s
# macOS: # macOS:
$ yourprogram completion bash > /usr/local/etc/bash_completion.d/yourprogram $ %[1]s completion bash > /usr/local/etc/bash_completion.d/%[1]s
Zsh: Zsh:
@ -48,25 +50,25 @@ Zsh:
$ echo "autoload -U compinit; compinit" >> ~/.zshrc $ echo "autoload -U compinit; compinit" >> ~/.zshrc
# To load completions for each session, execute once: # To load completions for each session, execute once:
$ yourprogram completion zsh > "${fpath[1]}/_yourprogram" $ %[1]s completion zsh > "${fpath[1]}/_%[1]s"
# You will need to start a new shell for this setup to take effect. # You will need to start a new shell for this setup to take effect.
fish: fish:
$ yourprogram completion fish | source $ %[1]s completion fish | source
# To load completions for each session, execute once: # To load completions for each session, execute once:
$ yourprogram completion fish > ~/.config/fish/completions/yourprogram.fish $ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish
PowerShell: PowerShell:
PS> yourprogram completion powershell | Out-String | Invoke-Expression PS> %[1]s completion powershell | Out-String | Invoke-Expression
# To load completions for every new session, run: # To load completions for every new session, run:
PS> yourprogram completion powershell > yourprogram.ps1 PS> %[1]s completion powershell > %[1]s.ps1
# and source this file from your PowerShell profile. # and source this file from your PowerShell profile.
`, `,cmd.Root().Name()),
DisableFlagsInUseLine: true, DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactValidArgs(1), Args: cobra.ExactValidArgs(1),

View File

@ -29,10 +29,10 @@ func main() {
## Using the Cobra Generator ## Using the Cobra Generator
Cobra provides its own program that will create your application and add any Cobra-CLI is its own program that will create your application and add any
commands you want. It's the easiest way to incorporate Cobra into your application. commands you want. It's the easiest way to incorporate Cobra into your application.
[Here](https://github.com/spf13/cobra/blob/master/cobra/README.md) you can find more information about it. For complete details on using the Cobra generator, please refer to [The Cobra-CLI Generator README](https://github.com/spf13/cobra-cli/blob/master/README.md)
## Using the Cobra Library ## Using the Cobra Library
@ -86,7 +86,7 @@ var (
userLicense string userLicense string
rootCmd = &cobra.Command{ rootCmd = &cobra.Command{
Use: "cobra", Use: "cobra-cli",
Short: "A generator for Cobra based Applications", Short: "A generator for Cobra based Applications",
Long: `Cobra is a CLI library for Go that empowers applications. Long: `Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
@ -281,7 +281,7 @@ func init() {
In this example, the persistent flag `author` is bound with `viper`. In this example, the persistent flag `author` is bound with `viper`.
**Note**: the variable `author` will not be set to the value from config, **Note**: the variable `author` will not be set to the value from config,
when the `--author` flag is not provided by user. when the `--author` flag is provided by user.
More in [viper documentation](https://github.com/spf13/viper#working-with-flags). More in [viper documentation](https://github.com/spf13/viper#working-with-flags).
@ -315,6 +315,7 @@ The following validators are built in:
- `ExactArgs(int)` - the command will report an error if there are not exactly N positional args. - `ExactArgs(int)` - the command will report an error if there are not exactly N positional args.
- `ExactValidArgs(int)` - the command will report an error if there are not exactly N positional args OR if there are any positional args that are not in the `ValidArgs` field of `Command` - `ExactValidArgs(int)` - the command will report an error if there are not exactly N positional args OR if there are any positional args that are not in the `ValidArgs` field of `Command`
- `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args. - `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args.
- `MatchAll(pargs ...PositionalArgs)` - enables combining existing checks with arbitrary other checks (e.g. you want to check the ExactArgs length along with other qualities).
An example of setting the custom validator: An example of setting the custom validator:

View File

@ -202,7 +202,7 @@ _%[1]s()
_arguments '*:filename:'"$filteringCmd" _arguments '*:filename:'"$filteringCmd"
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
# File completion for directories only # File completion for directories only
local subDir local subdir
subdir="${completions[1]}" subdir="${completions[1]}"
if [ -n "$subdir" ]; then if [ -n "$subdir" ]; then
__%[1]s_debug "Listing directories in $subdir" __%[1]s_debug "Listing directories in $subdir"
@ -250,7 +250,7 @@ _%[1]s()
# don't run the completion function when being source-ed or eval-ed # don't run the completion function when being source-ed or eval-ed
if [ "$funcstack[1]" = "_%[1]s" ]; then if [ "$funcstack[1]" = "_%[1]s" ]; then
_%[1]s _%[1]s
fi fi
`, name, compCmd, `, name, compCmd,
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp, ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,

View File

@ -597,6 +597,7 @@ ccflags="$@"
$2 ~ /^DEVLINK_/ || $2 ~ /^DEVLINK_/ ||
$2 ~ /^ETHTOOL_/ || $2 ~ /^ETHTOOL_/ ||
$2 ~ /^LWTUNNEL_IP/ || $2 ~ /^LWTUNNEL_IP/ ||
$2 ~ /^ITIMER_/ ||
$2 !~ "WMESGLEN" && $2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ || $2 ~ /^W[A-Z0-9]+$/ ||
$2 ~/^PPPIOC/ || $2 ~/^PPPIOC/ ||

View File

@ -14,6 +14,7 @@ package unix
import ( import (
"encoding/binary" "encoding/binary"
"syscall" "syscall"
"time"
"unsafe" "unsafe"
) )
@ -2314,11 +2315,56 @@ type RemoteIovec struct {
//sys shmdt(addr uintptr) (err error) //sys shmdt(addr uintptr) (err error)
//sys shmget(key int, size int, flag int) (id int, err error) //sys shmget(key int, size int, flag int) (id int, err error)
//sys getitimer(which int, currValue *Itimerval) (err error)
//sys setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error)
// MakeItimerval creates an Itimerval from interval and value durations.
func MakeItimerval(interval, value time.Duration) Itimerval {
return Itimerval{
Interval: NsecToTimeval(interval.Nanoseconds()),
Value: NsecToTimeval(value.Nanoseconds()),
}
}
// A value which may be passed to the which parameter for Getitimer and
// Setitimer.
type ItimerWhich int
// Possible which values for Getitimer and Setitimer.
const (
ItimerReal ItimerWhich = ITIMER_REAL
ItimerVirtual ItimerWhich = ITIMER_VIRTUAL
ItimerProf ItimerWhich = ITIMER_PROF
)
// Getitimer wraps getitimer(2) to return the current value of the timer
// specified by which.
func Getitimer(which ItimerWhich) (Itimerval, error) {
var it Itimerval
if err := getitimer(int(which), &it); err != nil {
return Itimerval{}, err
}
return it, nil
}
// Setitimer wraps setitimer(2) to arm or disarm the timer specified by which.
// It returns the previous value of the timer.
//
// If the Itimerval argument is the zero value, the timer will be disarmed.
func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) {
var prev Itimerval
if err := setitimer(int(which), &it, &prev); err != nil {
return Itimerval{}, err
}
return prev, nil
}
/* /*
* Unimplemented * Unimplemented
*/ */
// AfsSyscall // AfsSyscall
// Alarm
// ArchPrctl // ArchPrctl
// Brk // Brk
// ClockNanosleep // ClockNanosleep
@ -2334,7 +2380,6 @@ type RemoteIovec struct {
// GetMempolicy // GetMempolicy
// GetRobustList // GetRobustList
// GetThreadArea // GetThreadArea
// Getitimer
// Getpmsg // Getpmsg
// IoCancel // IoCancel
// IoDestroy // IoDestroy

14
vendor/golang.org/x/sys/unix/syscall_linux_alarm.go generated vendored Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64)
// +build linux
// +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64
package unix
// SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH
// values.
//sys Alarm(seconds uint) (remaining uint, err error)

View File

@ -38,7 +38,8 @@ const (
AF_KEY = 0xf AF_KEY = 0xf
AF_LLC = 0x1a AF_LLC = 0x1a
AF_LOCAL = 0x1 AF_LOCAL = 0x1
AF_MAX = 0x2d AF_MAX = 0x2e
AF_MCTP = 0x2d
AF_MPLS = 0x1c AF_MPLS = 0x1c
AF_NETBEUI = 0xd AF_NETBEUI = 0xd
AF_NETLINK = 0x10 AF_NETLINK = 0x10
@ -741,6 +742,7 @@ const (
ETH_P_QINQ2 = 0x9200 ETH_P_QINQ2 = 0x9200
ETH_P_QINQ3 = 0x9300 ETH_P_QINQ3 = 0x9300
ETH_P_RARP = 0x8035 ETH_P_RARP = 0x8035
ETH_P_REALTEK = 0x8899
ETH_P_SCA = 0x6007 ETH_P_SCA = 0x6007
ETH_P_SLOW = 0x8809 ETH_P_SLOW = 0x8809
ETH_P_SNAP = 0x5 ETH_P_SNAP = 0x5
@ -810,10 +812,12 @@ const (
FAN_EPIDFD = -0x2 FAN_EPIDFD = -0x2
FAN_EVENT_INFO_TYPE_DFID = 0x3 FAN_EVENT_INFO_TYPE_DFID = 0x3
FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
FAN_EVENT_INFO_TYPE_ERROR = 0x5
FAN_EVENT_INFO_TYPE_FID = 0x1 FAN_EVENT_INFO_TYPE_FID = 0x1
FAN_EVENT_INFO_TYPE_PIDFD = 0x4 FAN_EVENT_INFO_TYPE_PIDFD = 0x4
FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_METADATA_LEN = 0x18
FAN_EVENT_ON_CHILD = 0x8000000 FAN_EVENT_ON_CHILD = 0x8000000
FAN_FS_ERROR = 0x8000
FAN_MARK_ADD = 0x1 FAN_MARK_ADD = 0x1
FAN_MARK_DONT_FOLLOW = 0x4 FAN_MARK_DONT_FOLLOW = 0x4
FAN_MARK_FILESYSTEM = 0x100 FAN_MARK_FILESYSTEM = 0x100
@ -1264,6 +1268,9 @@ const (
IP_XFRM_POLICY = 0x11 IP_XFRM_POLICY = 0x11
ISOFS_SUPER_MAGIC = 0x9660 ISOFS_SUPER_MAGIC = 0x9660
ISTRIP = 0x20 ISTRIP = 0x20
ITIMER_PROF = 0x2
ITIMER_REAL = 0x0
ITIMER_VIRTUAL = 0x1
IUTF8 = 0x4000 IUTF8 = 0x4000
IXANY = 0x800 IXANY = 0x800
JFFS2_SUPER_MAGIC = 0x72b6 JFFS2_SUPER_MAGIC = 0x72b6
@ -1827,6 +1834,8 @@ const (
PERF_MEM_BLK_DATA = 0x2 PERF_MEM_BLK_DATA = 0x2
PERF_MEM_BLK_NA = 0x1 PERF_MEM_BLK_NA = 0x1
PERF_MEM_BLK_SHIFT = 0x28 PERF_MEM_BLK_SHIFT = 0x28
PERF_MEM_HOPS_0 = 0x1
PERF_MEM_HOPS_SHIFT = 0x2b
PERF_MEM_LOCK_LOCKED = 0x2 PERF_MEM_LOCK_LOCKED = 0x2
PERF_MEM_LOCK_NA = 0x1 PERF_MEM_LOCK_NA = 0x1
PERF_MEM_LOCK_SHIFT = 0x18 PERF_MEM_LOCK_SHIFT = 0x18
@ -1986,6 +1995,9 @@ const (
PR_SCHED_CORE_CREATE = 0x1 PR_SCHED_CORE_CREATE = 0x1
PR_SCHED_CORE_GET = 0x0 PR_SCHED_CORE_GET = 0x0
PR_SCHED_CORE_MAX = 0x4 PR_SCHED_CORE_MAX = 0x4
PR_SCHED_CORE_SCOPE_PROCESS_GROUP = 0x2
PR_SCHED_CORE_SCOPE_THREAD = 0x0
PR_SCHED_CORE_SCOPE_THREAD_GROUP = 0x1
PR_SCHED_CORE_SHARE_FROM = 0x3 PR_SCHED_CORE_SHARE_FROM = 0x3
PR_SCHED_CORE_SHARE_TO = 0x2 PR_SCHED_CORE_SHARE_TO = 0x2
PR_SET_CHILD_SUBREAPER = 0x24 PR_SET_CHILD_SUBREAPER = 0x24
@ -2167,12 +2179,23 @@ const (
RTCF_NAT = 0x800000 RTCF_NAT = 0x800000
RTCF_VALVE = 0x200000 RTCF_VALVE = 0x200000
RTC_AF = 0x20 RTC_AF = 0x20
RTC_BSM_DIRECT = 0x1
RTC_BSM_DISABLED = 0x0
RTC_BSM_LEVEL = 0x2
RTC_BSM_STANDBY = 0x3
RTC_FEATURE_ALARM = 0x0 RTC_FEATURE_ALARM = 0x0
RTC_FEATURE_ALARM_RES_2S = 0x3
RTC_FEATURE_ALARM_RES_MINUTE = 0x1 RTC_FEATURE_ALARM_RES_MINUTE = 0x1
RTC_FEATURE_CNT = 0x3 RTC_FEATURE_BACKUP_SWITCH_MODE = 0x6
RTC_FEATURE_CNT = 0x7
RTC_FEATURE_CORRECTION = 0x5
RTC_FEATURE_NEED_WEEK_DAY = 0x2 RTC_FEATURE_NEED_WEEK_DAY = 0x2
RTC_FEATURE_UPDATE_INTERRUPT = 0x4
RTC_IRQF = 0x80 RTC_IRQF = 0x80
RTC_MAX_FREQ = 0x2000 RTC_MAX_FREQ = 0x2000
RTC_PARAM_BACKUP_SWITCH_MODE = 0x2
RTC_PARAM_CORRECTION = 0x1
RTC_PARAM_FEATURES = 0x0
RTC_PF = 0x40 RTC_PF = 0x40
RTC_UF = 0x10 RTC_UF = 0x10
RTF_ADDRCLASSMASK = 0xf8000000 RTF_ADDRCLASSMASK = 0xf8000000
@ -2532,6 +2555,8 @@ const (
SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1 SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1
SO_VM_SOCKETS_BUFFER_SIZE = 0x0 SO_VM_SOCKETS_BUFFER_SIZE = 0x0
SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6 SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6
SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW = 0x8
SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD = 0x6
SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7 SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7
SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3 SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3
SO_VM_SOCKETS_TRUSTED = 0x5 SO_VM_SOCKETS_TRUSTED = 0x5

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x4004700e RTC_EPOCH_SET = 0x4004700e
RTC_IRQP_READ = 0x8004700b RTC_IRQP_READ = 0x8004700b
RTC_IRQP_SET = 0x4004700c RTC_IRQP_SET = 0x4004700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x801c7011 RTC_PLL_GET = 0x801c7011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -251,6 +251,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -328,6 +330,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -257,6 +257,8 @@ const (
RTC_EPOCH_SET = 0x4004700e RTC_EPOCH_SET = 0x4004700e
RTC_IRQP_READ = 0x8004700b RTC_IRQP_READ = 0x8004700b
RTC_IRQP_SET = 0x4004700c RTC_IRQP_SET = 0x4004700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x801c7011 RTC_PLL_GET = 0x801c7011
@ -334,6 +336,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -247,6 +247,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -324,6 +326,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8004700e RTC_EPOCH_SET = 0x8004700e
RTC_IRQP_READ = 0x4004700b RTC_IRQP_READ = 0x4004700b
RTC_IRQP_SET = 0x8004700c RTC_IRQP_SET = 0x8004700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x401c7011 RTC_PLL_GET = 0x401c7011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8004700e RTC_EPOCH_SET = 0x8004700e
RTC_IRQP_READ = 0x4004700b RTC_IRQP_READ = 0x4004700b
RTC_IRQP_SET = 0x8004700c RTC_IRQP_SET = 0x8004700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x401c7011 RTC_PLL_GET = 0x401c7011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -305,6 +305,8 @@ const (
RTC_EPOCH_SET = 0x8004700e RTC_EPOCH_SET = 0x8004700e
RTC_IRQP_READ = 0x4004700b RTC_IRQP_READ = 0x4004700b
RTC_IRQP_SET = 0x8004700c RTC_IRQP_SET = 0x8004700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x401c7011 RTC_PLL_GET = 0x401c7011
@ -382,6 +384,7 @@ const (
SO_RCVTIMEO = 0x12 SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12 SO_RCVTIMEO_OLD = 0x12
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -309,6 +309,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -386,6 +388,7 @@ const (
SO_RCVTIMEO = 0x12 SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12 SO_RCVTIMEO_OLD = 0x12
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -309,6 +309,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -386,6 +388,7 @@ const (
SO_RCVTIMEO = 0x12 SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12 SO_RCVTIMEO_OLD = 0x12
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -238,6 +238,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -315,6 +317,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -313,6 +313,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -390,6 +392,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -304,6 +304,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -381,6 +383,7 @@ const (
SO_RCVTIMEO = 0x2000 SO_RCVTIMEO = 0x2000
SO_RCVTIMEO_NEW = 0x44 SO_RCVTIMEO_NEW = 0x44
SO_RCVTIMEO_OLD = 0x2000 SO_RCVTIMEO_OLD = 0x2000
SO_RESERVE_MEM = 0x52
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x24 SO_RXQ_OVFL = 0x24

View File

@ -2032,3 +2032,23 @@ func shmget(key int, size int, flag int) (id int, err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getitimer(which int, currValue *Itimerval) (err error) {
_, _, e1 := Syscall(SYS_GETITIMER, uintptr(which), uintptr(unsafe.Pointer(currValue)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error) {
_, _, e1 := Syscall(SYS_SETITIMER, uintptr(which), uintptr(unsafe.Pointer(newValue)), uintptr(unsafe.Pointer(oldValue)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go // go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && 386 //go:build linux && 386
@ -524,3 +524,14 @@ func utimes(path string, times *[2]Timeval) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go // go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && amd64 //go:build linux && amd64
@ -691,3 +691,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go // go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mips //go:build linux && mips
@ -702,3 +702,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go // go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mips64 //go:build linux && mips64
@ -696,3 +696,14 @@ func stat(path string, st *stat_t) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go // go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mipsle //go:build linux && mipsle
@ -702,3 +702,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go // go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc //go:build linux && ppc
@ -707,3 +707,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go // go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc64 //go:build linux && ppc64
@ -753,3 +753,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go // go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc64le //go:build linux && ppc64le
@ -753,3 +753,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go // go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && s390x //go:build linux && s390x
@ -533,3 +533,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go // go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && sparc64 //go:build linux && sparc64
@ -697,3 +697,14 @@ func utimes(path string, times *[2]Timeval) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -445,4 +445,5 @@ const (
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447 SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -367,4 +367,5 @@ const (
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447 SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -409,4 +409,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -312,4 +312,5 @@ const (
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447 SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -429,4 +429,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_ADD_RULE = 4445
SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_LANDLOCK_RESTRICT_SELF = 4446
SYS_PROCESS_MRELEASE = 4448 SYS_PROCESS_MRELEASE = 4448
SYS_FUTEX_WAITV = 4449
) )

View File

@ -359,4 +359,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_ADD_RULE = 5445
SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_LANDLOCK_RESTRICT_SELF = 5446
SYS_PROCESS_MRELEASE = 5448 SYS_PROCESS_MRELEASE = 5448
SYS_FUTEX_WAITV = 5449
) )

View File

@ -359,4 +359,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_ADD_RULE = 5445
SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_LANDLOCK_RESTRICT_SELF = 5446
SYS_PROCESS_MRELEASE = 5448 SYS_PROCESS_MRELEASE = 5448
SYS_FUTEX_WAITV = 5449
) )

View File

@ -429,4 +429,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_ADD_RULE = 4445
SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_LANDLOCK_RESTRICT_SELF = 4446
SYS_PROCESS_MRELEASE = 4448 SYS_PROCESS_MRELEASE = 4448
SYS_FUTEX_WAITV = 4449
) )

View File

@ -436,4 +436,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -408,4 +408,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -408,4 +408,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -310,4 +310,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -373,4 +373,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -387,4 +387,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -24,6 +24,11 @@ type ItimerSpec struct {
Value Timespec Value Timespec
} }
type Itimerval struct {
Interval Timeval
Value Timeval
}
const ( const (
TIME_OK = 0x0 TIME_OK = 0x0
TIME_INS = 0x1 TIME_INS = 0x1
@ -1144,7 +1149,8 @@ const (
PERF_RECORD_BPF_EVENT = 0x12 PERF_RECORD_BPF_EVENT = 0x12
PERF_RECORD_CGROUP = 0x13 PERF_RECORD_CGROUP = 0x13
PERF_RECORD_TEXT_POKE = 0x14 PERF_RECORD_TEXT_POKE = 0x14
PERF_RECORD_MAX = 0x15 PERF_RECORD_AUX_OUTPUT_HW_ID = 0x15
PERF_RECORD_MAX = 0x16
PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0 PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0
PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1 PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1
PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2 PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2
@ -1784,7 +1790,8 @@ const (
const ( const (
NF_NETDEV_INGRESS = 0x0 NF_NETDEV_INGRESS = 0x0
NF_NETDEV_NUMHOOKS = 0x1 NF_NETDEV_EGRESS = 0x1
NF_NETDEV_NUMHOOKS = 0x2
) )
const ( const (
@ -3166,7 +3173,13 @@ const (
DEVLINK_ATTR_RELOAD_ACTION_INFO = 0xa2 DEVLINK_ATTR_RELOAD_ACTION_INFO = 0xa2
DEVLINK_ATTR_RELOAD_ACTION_STATS = 0xa3 DEVLINK_ATTR_RELOAD_ACTION_STATS = 0xa3
DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 0xa4 DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 0xa4
DEVLINK_ATTR_MAX = 0xa9 DEVLINK_ATTR_RATE_TYPE = 0xa5
DEVLINK_ATTR_RATE_TX_SHARE = 0xa6
DEVLINK_ATTR_RATE_TX_MAX = 0xa7
DEVLINK_ATTR_RATE_NODE_NAME = 0xa8
DEVLINK_ATTR_RATE_PARENT_NODE_NAME = 0xa9
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS = 0xaa
DEVLINK_ATTR_MAX = 0xaa
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1
DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0
@ -3463,7 +3476,14 @@ const (
ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a
ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b
ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c
ETHTOOL_MSG_USER_MAX = 0x21 ETHTOOL_MSG_FEC_GET = 0x1d
ETHTOOL_MSG_FEC_SET = 0x1e
ETHTOOL_MSG_MODULE_EEPROM_GET = 0x1f
ETHTOOL_MSG_STATS_GET = 0x20
ETHTOOL_MSG_PHC_VCLOCKS_GET = 0x21
ETHTOOL_MSG_MODULE_GET = 0x22
ETHTOOL_MSG_MODULE_SET = 0x23
ETHTOOL_MSG_USER_MAX = 0x23
ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@ -3494,7 +3514,14 @@ const (
ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b
ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c
ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d
ETHTOOL_MSG_KERNEL_MAX = 0x22 ETHTOOL_MSG_FEC_GET_REPLY = 0x1e
ETHTOOL_MSG_FEC_NTF = 0x1f
ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY = 0x20
ETHTOOL_MSG_STATS_GET_REPLY = 0x21
ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY = 0x22
ETHTOOL_MSG_MODULE_GET_REPLY = 0x23
ETHTOOL_MSG_MODULE_NTF = 0x24
ETHTOOL_MSG_KERNEL_MAX = 0x24
ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_UNSPEC = 0x0
ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_INDEX = 0x1
ETHTOOL_A_HEADER_DEV_NAME = 0x2 ETHTOOL_A_HEADER_DEV_NAME = 0x2

View File

@ -363,6 +363,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) //sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error)
//sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) //sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) //sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys GetActiveProcessorCount(groupNumber uint16) (ret uint32)
//sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32)
// Volume Management Functions // Volume Management Functions
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW

View File

@ -3172,3 +3172,5 @@ type ModuleInfo struct {
SizeOfImage uint32 SizeOfImage uint32
EntryPoint uintptr EntryPoint uintptr
} }
const ALL_PROCESSOR_GROUPS = 0xFFFF

View File

@ -226,6 +226,7 @@ var (
procFreeLibrary = modkernel32.NewProc("FreeLibrary") procFreeLibrary = modkernel32.NewProc("FreeLibrary")
procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent") procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
procGetACP = modkernel32.NewProc("GetACP") procGetACP = modkernel32.NewProc("GetACP")
procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts") procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts")
procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
@ -251,6 +252,7 @@ var (
procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW") procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW") procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
@ -1967,6 +1969,12 @@ func GetACP() (acp uint32) {
return return
} }
func GetActiveProcessorCount(groupNumber uint16) (ret uint32) {
r0, _, _ := syscall.Syscall(procGetActiveProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
ret = uint32(r0)
return
}
func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) { func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0) r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
if r1 == 0 { if r1 == 0 {
@ -2169,6 +2177,12 @@ func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err er
return return
} }
func GetMaximumProcessorCount(groupNumber uint16) (ret uint32) {
r0, _, _ := syscall.Syscall(procGetMaximumProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
ret = uint32(r0)
return
}
func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) { func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) {
r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size)) r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size))
n = uint32(r0) n = uint32(r0)

View File

@ -1,12 +1,11 @@
# See the OWNERS docs at https://go.k8s.io/owners # See the OWNERS docs at https://go.k8s.io/owners
reviewers: reviewers:
- thockin - thockin
- lavalamp - lavalamp
- smarterclayton - smarterclayton
- wojtek-t - wojtek-t
- derekwaynecarr - derekwaynecarr
- mikedanese - mikedanese
- saad-ali - saad-ali
- janetkuo - janetkuo
- xiang90

View File

@ -61,8 +61,32 @@ func (m *Quantity) XXX_DiscardUnknown() {
var xxx_messageInfo_Quantity proto.InternalMessageInfo var xxx_messageInfo_Quantity proto.InternalMessageInfo
func (m *QuantityValue) Reset() { *m = QuantityValue{} }
func (*QuantityValue) ProtoMessage() {}
func (*QuantityValue) Descriptor() ([]byte, []int) {
return fileDescriptor_612bba87bd70906c, []int{1}
}
func (m *QuantityValue) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QuantityValue.Unmarshal(m, b)
}
func (m *QuantityValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_QuantityValue.Marshal(b, m, deterministic)
}
func (m *QuantityValue) XXX_Merge(src proto.Message) {
xxx_messageInfo_QuantityValue.Merge(m, src)
}
func (m *QuantityValue) XXX_Size() int {
return xxx_messageInfo_QuantityValue.Size(m)
}
func (m *QuantityValue) XXX_DiscardUnknown() {
xxx_messageInfo_QuantityValue.DiscardUnknown(m)
}
var xxx_messageInfo_QuantityValue proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*Quantity)(nil), "k8s.io.apimachinery.pkg.api.resource.Quantity") proto.RegisterType((*Quantity)(nil), "k8s.io.apimachinery.pkg.api.resource.Quantity")
proto.RegisterType((*QuantityValue)(nil), "k8s.io.apimachinery.pkg.api.resource.QuantityValue")
} }
func init() { func init() {
@ -70,20 +94,21 @@ func init() {
} }
var fileDescriptor_612bba87bd70906c = []byte{ var fileDescriptor_612bba87bd70906c = []byte{
// 237 bytes of a gzipped FileDescriptorProto // 254 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8e, 0xb1, 0x4e, 0xc3, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0xcd, 0xb6, 0x28, 0xd6,
0x10, 0x40, 0xcf, 0x0b, 0x2a, 0x19, 0x2b, 0x84, 0x10, 0xc3, 0xa5, 0x42, 0x0c, 0x2c, 0xd8, 0x6b, 0xcb, 0xcc, 0xd7, 0xcf, 0x2e, 0x4d, 0x4a, 0x2d, 0xca, 0x4b, 0x2d, 0x49, 0x2d, 0xd6, 0x2f, 0x4b,
0xc5, 0xc8, 0xce, 0x00, 0x23, 0x5b, 0x92, 0x1e, 0xae, 0x15, 0xd5, 0x8e, 0x2e, 0x36, 0x52, 0xb7, 0xcd, 0x4b, 0xc9, 0x2f, 0xd2, 0x87, 0x4a, 0x24, 0x16, 0x64, 0xe6, 0x26, 0x26, 0x67, 0x64, 0xe6,
0x8e, 0x8c, 0x1d, 0x19, 0x9b, 0xbf, 0xe9, 0xd8, 0xb1, 0x03, 0x03, 0x31, 0x3f, 0x82, 0xea, 0x36, 0xa5, 0x16, 0x55, 0xea, 0x17, 0x64, 0xa7, 0x83, 0x04, 0xf4, 0x8b, 0x52, 0x8b, 0xf3, 0x4b, 0x8b,
0x52, 0xb7, 0x7b, 0xef, 0xf4, 0x4e, 0x97, 0xbd, 0xd4, 0xd3, 0x56, 0x1a, 0xa7, 0xea, 0x50, 0x12, 0x92, 0x53, 0xf5, 0xd3, 0x53, 0xf3, 0x52, 0x8b, 0x12, 0x4b, 0x52, 0x53, 0xf4, 0x0a, 0x8a, 0xf2,
0x5b, 0xf2, 0xd4, 0xaa, 0x4f, 0xb2, 0x33, 0xc7, 0xea, 0xb4, 0x28, 0x1a, 0xb3, 0x28, 0xaa, 0xb9, 0x4b, 0xf2, 0x85, 0x54, 0x20, 0xba, 0xf4, 0x90, 0x75, 0xe9, 0x15, 0x64, 0xa7, 0x83, 0x04, 0xf4,
0xb1, 0xc4, 0x4b, 0xd5, 0xd4, 0xfa, 0x20, 0x14, 0x53, 0xeb, 0x02, 0x57, 0xa4, 0x34, 0x59, 0xe2, 0x60, 0xba, 0xa4, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xd3,
0xc2, 0xd3, 0x4c, 0x36, 0xec, 0xbc, 0x1b, 0xdf, 0x1f, 0x2b, 0x79, 0x5e, 0xc9, 0xa6, 0xd6, 0x07, 0xf3, 0xd3, 0xf3, 0xf5, 0xc1, 0x9a, 0x93, 0x4a, 0xd3, 0xc0, 0x3c, 0x30, 0x07, 0xcc, 0x82, 0x18,
0x21, 0x87, 0xea, 0xf6, 0x51, 0x1b, 0x3f, 0x0f, 0xa5, 0xac, 0xdc, 0x42, 0x69, 0xa7, 0x9d, 0x4a, 0xaa, 0x64, 0xc1, 0xc5, 0x11, 0x58, 0x9a, 0x98, 0x57, 0x92, 0x59, 0x52, 0x29, 0x24, 0xc6, 0xc5,
0x71, 0x19, 0x3e, 0x12, 0x25, 0x48, 0xd3, 0xf1, 0xe8, 0xdd, 0x34, 0x1b, 0xbd, 0x86, 0xc2, 0x7a, 0x56, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe5, 0x59,
0xe3, 0x97, 0xe3, 0xeb, 0xec, 0xa2, 0xf5, 0x6c, 0xac, 0xbe, 0x11, 0x13, 0xf1, 0x70, 0xf9, 0x76, 0x89, 0xcc, 0x58, 0x20, 0xcf, 0xd0, 0xb1, 0x50, 0x9e, 0x61, 0xc2, 0x42, 0x79, 0x86, 0x05, 0x0b,
0xa2, 0xa7, 0xab, 0xef, 0x4d, 0x0e, 0x5f, 0x5d, 0x0e, 0xeb, 0x2e, 0x87, 0x4d, 0x97, 0xc3, 0xea, 0xe5, 0x19, 0x1a, 0xee, 0x28, 0x30, 0x28, 0xd9, 0x72, 0xf1, 0xc2, 0x74, 0x86, 0x25, 0xe6, 0x94,
0x67, 0x02, 0xcf, 0x72, 0xdb, 0x23, 0xec, 0x7a, 0x84, 0x7d, 0x8f, 0xb0, 0x8a, 0x28, 0xb6, 0x11, 0xa6, 0x92, 0xa6, 0xdd, 0xc9, 0xeb, 0xc4, 0x43, 0x39, 0x86, 0x0b, 0x0f, 0xe5, 0x18, 0x6e, 0x3c,
0xc5, 0x2e, 0xa2, 0xd8, 0x47, 0x14, 0xbf, 0x11, 0xc5, 0xfa, 0x0f, 0xe1, 0x7d, 0x34, 0x3c, 0xf6, 0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x37,
0x1f, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x08, 0x88, 0x49, 0x0e, 0x01, 0x00, 0x00, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0x43, 0x94, 0x0a, 0x31, 0x21,
0x05, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x70, 0x98, 0xa3, 0x69, 0x01, 0x00, 0x00,
} }

View File

@ -22,7 +22,7 @@ syntax = "proto2";
package k8s.io.apimachinery.pkg.api.resource; package k8s.io.apimachinery.pkg.api.resource;
// Package-wide variables from generator "generated". // Package-wide variables from generator "generated".
option go_package = "resource"; option go_package = "k8s.io/apimachinery/pkg/api/resource";
// Quantity is a fixed-point representation of a number. // Quantity is a fixed-point representation of a number.
// It provides convenient marshaling/unmarshaling in JSON and YAML, // It provides convenient marshaling/unmarshaling in JSON and YAML,
@ -86,3 +86,15 @@ message Quantity {
optional string string = 1; optional string string = 1;
} }
// QuantityValue makes it possible to use a Quantity as value for a command
// line parameter.
//
// +protobuf=true
// +protobuf.embed=string
// +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:deepcopy-gen=true
message QuantityValue {
optional string string = 1;
}

View File

@ -397,6 +397,10 @@ func (_ Quantity) OpenAPISchemaType() []string { return []string{"string"} }
// the OpenAPI spec of this type. // the OpenAPI spec of this type.
func (_ Quantity) OpenAPISchemaFormat() string { return "" } func (_ Quantity) OpenAPISchemaFormat() string { return "" }
// OpenAPIV3OneOfTypes is used by the kube-openapi generator when constructing
// the OpenAPI v3 spec of this type.
func (Quantity) OpenAPIV3OneOfTypes() []string { return []string{"string", "number"} }
// CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity). // CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity).
// //
// Note about BinarySI: // Note about BinarySI:
@ -460,17 +464,7 @@ func (q *Quantity) AsApproximateFloat64() float64 {
return base return base
} }
// multiply by the appropriate exponential scale return base * math.Pow10(exponent)
switch q.Format {
case DecimalExponent, DecimalSI:
return base * math.Pow10(exponent)
default:
// fast path for exponents that can fit in 64 bits
if exponent > 0 && exponent < 7 {
return base * float64(int64(1)<<(exponent*10))
}
return base * math.Pow(2, float64(exponent*10))
}
} }
// AsInt64 returns a representation of the current value as an int64 if a fast conversion // AsInt64 returns a representation of the current value as an int64 if a fast conversion
@ -774,3 +768,30 @@ func (q *Quantity) SetScaled(value int64, scale Scale) {
q.d.Dec = nil q.d.Dec = nil
q.i = int64Amount{value: value, scale: scale} q.i = int64Amount{value: value, scale: scale}
} }
// QuantityValue makes it possible to use a Quantity as value for a command
// line parameter.
//
// +protobuf=true
// +protobuf.embed=string
// +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:deepcopy-gen=true
type QuantityValue struct {
Quantity
}
// Set implements pflag.Value.Set and Go flag.Value.Set.
func (q *QuantityValue) Set(s string) error {
quantity, err := ParseQuantity(s)
if err != nil {
return err
}
q.Quantity = quantity
return nil
}
// Type implements pflag.Value.Type.
func (q QuantityValue) Type() string {
return "quantity"
}

View File

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated // +build !ignore_autogenerated
/* /*
@ -25,3 +26,20 @@ func (in *Quantity) DeepCopyInto(out *Quantity) {
*out = in.DeepCopy() *out = in.DeepCopy()
return return
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *QuantityValue) DeepCopyInto(out *QuantityValue) {
*out = *in
out.Quantity = in.Quantity.DeepCopy()
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QuantityValue.
func (in *QuantityValue) DeepCopy() *QuantityValue {
if in == nil {
return nil
}
out := new(QuantityValue)
in.DeepCopyInto(out)
return out
}

33
vendor/modules.txt generated vendored
View File

@ -45,7 +45,7 @@ github.com/compose-spec/compose-go/types
# github.com/containerd/cgroups v1.0.3 # github.com/containerd/cgroups v1.0.3
## explicit; go 1.16 ## explicit; go 1.16
github.com/containerd/cgroups/stats/v1 github.com/containerd/cgroups/stats/v1
# github.com/containerd/containerd v1.6.2 # github.com/containerd/containerd v1.6.4
## explicit; go 1.17 ## explicit; go 1.17
github.com/containerd/containerd github.com/containerd/containerd
github.com/containerd/containerd/api/services/containers/v1 github.com/containerd/containerd/api/services/containers/v1
@ -85,6 +85,7 @@ github.com/containerd/containerd/namespaces
github.com/containerd/containerd/oci github.com/containerd/containerd/oci
github.com/containerd/containerd/pkg/cap github.com/containerd/containerd/pkg/cap
github.com/containerd/containerd/pkg/dialer github.com/containerd/containerd/pkg/dialer
github.com/containerd/containerd/pkg/kmutex
github.com/containerd/containerd/pkg/userns github.com/containerd/containerd/pkg/userns
github.com/containerd/containerd/platforms github.com/containerd/containerd/platforms
github.com/containerd/containerd/plugin github.com/containerd/containerd/plugin
@ -113,8 +114,8 @@ github.com/containerd/continuity/sysx
# github.com/containerd/fifo v1.0.0 # github.com/containerd/fifo v1.0.0
## explicit; go 1.13 ## explicit; go 1.13
github.com/containerd/fifo github.com/containerd/fifo
# github.com/containerd/go-cni v1.1.3 # github.com/containerd/go-cni v1.1.5
## explicit; go 1.13 ## explicit; go 1.17
github.com/containerd/go-cni github.com/containerd/go-cni
# github.com/containerd/ttrpc v1.1.0 # github.com/containerd/ttrpc v1.1.0
## explicit; go 1.13 ## explicit; go 1.13
@ -122,7 +123,7 @@ github.com/containerd/ttrpc
# github.com/containerd/typeurl v1.0.2 # github.com/containerd/typeurl v1.0.2
## explicit; go 1.13 ## explicit; go 1.13
github.com/containerd/typeurl github.com/containerd/typeurl
# github.com/containernetworking/cni v1.0.1 # github.com/containernetworking/cni v1.1.0
## explicit; go 1.14 ## explicit; go 1.14
github.com/containernetworking/cni/libcni github.com/containernetworking/cni/libcni
github.com/containernetworking/cni/pkg/invoke github.com/containernetworking/cni/pkg/invoke
@ -143,7 +144,7 @@ github.com/docker/cli/cli/config
github.com/docker/cli/cli/config/configfile github.com/docker/cli/cli/config/configfile
github.com/docker/cli/cli/config/credentials github.com/docker/cli/cli/config/credentials
github.com/docker/cli/cli/config/types github.com/docker/cli/cli/config/types
# github.com/docker/distribution v2.8.0+incompatible # github.com/docker/distribution v2.8.1+incompatible
## explicit ## explicit
github.com/docker/distribution/digestset github.com/docker/distribution/digestset
github.com/docker/distribution/reference github.com/docker/distribution/reference
@ -226,32 +227,32 @@ github.com/morikuni/aec
# github.com/opencontainers/go-digest v1.0.0 # github.com/opencontainers/go-digest v1.0.0
## explicit; go 1.13 ## explicit; go 1.13
github.com/opencontainers/go-digest github.com/opencontainers/go-digest
# github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5 # github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
## explicit ## explicit
github.com/opencontainers/image-spec/identity github.com/opencontainers/image-spec/identity
github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1 github.com/opencontainers/image-spec/specs-go/v1
# github.com/opencontainers/runc v1.1.0 # github.com/opencontainers/runc v1.1.1
## explicit; go 1.16 ## explicit; go 1.16
github.com/opencontainers/runc/libcontainer/user github.com/opencontainers/runc/libcontainer/user
# github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 # github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
## explicit ## explicit
github.com/opencontainers/runtime-spec/specs-go github.com/opencontainers/runtime-spec/specs-go
# github.com/opencontainers/selinux v1.10.0 # github.com/opencontainers/selinux v1.10.1
## explicit; go 1.13 ## explicit; go 1.13
github.com/opencontainers/selinux/go-selinux github.com/opencontainers/selinux/go-selinux
github.com/opencontainers/selinux/go-selinux/label github.com/opencontainers/selinux/go-selinux/label
github.com/opencontainers/selinux/pkg/pwalk github.com/opencontainers/selinux/pkg/pwalk
github.com/opencontainers/selinux/pkg/pwalkdir github.com/opencontainers/selinux/pkg/pwalkdir
# github.com/openfaas/faas-provider v0.18.9 # github.com/openfaas/faas-provider v0.18.10
## explicit; go 1.16 ## explicit; go 1.17
github.com/openfaas/faas-provider github.com/openfaas/faas-provider
github.com/openfaas/faas-provider/auth github.com/openfaas/faas-provider/auth
github.com/openfaas/faas-provider/httputil github.com/openfaas/faas-provider/httputil
github.com/openfaas/faas-provider/logs github.com/openfaas/faas-provider/logs
github.com/openfaas/faas-provider/proxy github.com/openfaas/faas-provider/proxy
github.com/openfaas/faas-provider/types github.com/openfaas/faas-provider/types
# github.com/openfaas/faas/gateway v0.0.0-20220124164130-cdb6badddaed # github.com/openfaas/faas/gateway v0.0.0-20220509091830-4e868f5f9d81
## explicit; go 1.16 ## explicit; go 1.16
github.com/openfaas/faas/gateway/requests github.com/openfaas/faas/gateway/requests
# github.com/pkg/errors v0.9.1 # github.com/pkg/errors v0.9.1
@ -263,8 +264,8 @@ github.com/sethvargo/go-password/password
# github.com/sirupsen/logrus v1.8.1 # github.com/sirupsen/logrus v1.8.1
## explicit; go 1.13 ## explicit; go 1.13
github.com/sirupsen/logrus github.com/sirupsen/logrus
# github.com/spf13/cobra v1.2.1 # github.com/spf13/cobra v1.4.0
## explicit; go 1.14 ## explicit; go 1.15
github.com/spf13/cobra github.com/spf13/cobra
# github.com/spf13/pflag v1.0.5 # github.com/spf13/pflag v1.0.5
## explicit; go 1.12 ## explicit; go 1.12
@ -292,7 +293,7 @@ go.opencensus.io/internal
go.opencensus.io/trace go.opencensus.io/trace
go.opencensus.io/trace/internal go.opencensus.io/trace/internal
go.opencensus.io/trace/tracestate go.opencensus.io/trace/tracestate
# golang.org/x/net v0.0.0-20211216030914-fe4d6282115f # golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/net/context/ctxhttp golang.org/x/net/context/ctxhttp
golang.org/x/net/http/httpguts golang.org/x/net/http/httpguts
@ -305,7 +306,7 @@ golang.org/x/net/trace
## explicit ## explicit
golang.org/x/sync/errgroup golang.org/x/sync/errgroup
golang.org/x/sync/semaphore golang.org/x/sync/semaphore
# golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e # golang.org/x/sys v0.0.0-20220209214540-3681064d5158
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/sys/execabs golang.org/x/sys/execabs
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader
@ -406,6 +407,6 @@ gopkg.in/inf.v0
# gopkg.in/yaml.v2 v2.4.0 # gopkg.in/yaml.v2 v2.4.0
## explicit; go 1.15 ## explicit; go 1.15
gopkg.in/yaml.v2 gopkg.in/yaml.v2
# k8s.io/apimachinery v0.22.5 # k8s.io/apimachinery v0.24.0
## explicit; go 1.16 ## explicit; go 1.16
k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/api/resource