diff --git a/go.mod b/go.mod index a009f40de0..638742b391 100644 --- a/go.mod +++ b/go.mod @@ -3,31 +3,24 @@ module github.com/google/ko go 1.16 require ( - github.com/containerd/containerd v1.5.7 // indirect - github.com/containerd/stargz-snapshotter/estargz v0.9.0 - github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect + github.com/containerd/stargz-snapshotter/estargz v0.10.0 github.com/docker/docker v20.10.10+incompatible github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 github.com/evanphx/json-patch/v5 v5.5.0 // indirect github.com/fsnotify/fsnotify v1.5.1 github.com/go-training/helloworld v0.0.0-20200225145412-ba5f4379d78b github.com/google/go-cmp v0.5.6 - github.com/google/go-containerregistry v0.6.0 + github.com/google/go-containerregistry v0.7.0 github.com/mattmoor/dep-notify v0.0.0-20190205035814-a45dec370a17 github.com/mattn/go-isatty v0.0.13 // indirect github.com/opencontainers/image-spec v1.0.2-0.20210730191737-8e42a01fb1b7 github.com/spf13/cobra v1.2.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.9.0 - golang.org/x/net v0.0.0-20211007125505-59d4e928ea9d // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect golang.org/x/tools v0.1.7 - google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e // indirect - google.golang.org/grpc v1.41.0 // indirect - gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b k8s.io/apimachinery v0.22.3 sigs.k8s.io/kind v0.11.1 diff --git a/go.sum b/go.sum index 2e283a5f31..d4bf675c02 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSU cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -68,8 +70,8 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= -github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY= +github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ= @@ -134,8 +136,11 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE= github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU= @@ -169,7 +174,6 @@ github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo github.com/containerd/containerd v1.5.0-beta.4/go.mod h1:GmdgZd2zA2GYIBZ0w09ZvgqEq8EfBp/m3lcVZIvPHhI= github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoTJseu1FGOKuoA4nNb2s= github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= -github.com/containerd/containerd v1.5.2/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= github.com/containerd/containerd v1.5.7 h1:rQyoYtj4KddB3bxG6SAqd4+08gePNyJjRqvOIfV3rkM= github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= @@ -199,9 +203,8 @@ github.com/containerd/imgcrypt v1.1.1/go.mod h1:xpLnwiQmEUJPvQoAapeb2SNCxz7Xr6PJ github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c= github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= -github.com/containerd/stargz-snapshotter/estargz v0.7.0/go.mod h1:83VWDqHnurTKliEB0YvWMiCfLDwv4Cjj1X9Vk98GJZw= -github.com/containerd/stargz-snapshotter/estargz v0.9.0 h1:PkB6BSTfOKX23erT2GkoUKkJEcXfNcyKskIViK770v8= -github.com/containerd/stargz-snapshotter/estargz v0.9.0/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= +github.com/containerd/stargz-snapshotter/estargz v0.10.0 h1:glqzafvxBBAMo+x2w2sdDjUDZeTqqLJmqZPY05qehCU= +github.com/containerd/stargz-snapshotter/estargz v0.10.0/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= @@ -251,6 +254,7 @@ github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1S github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I= +github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -259,17 +263,16 @@ github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/cli v20.10.7+incompatible h1:pv/3NqibQKphWZiAskMzdz8w0PRbtTaEB+f6NwdU7Is= -github.com/docker/cli v20.10.7+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v20.10.10+incompatible h1:kcbwdgWbrBOH8QwQzaJmyriHwF7XIl4HT1qh0HTRys4= +github.com/docker/cli v20.10.10+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v20.10.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.10+incompatible h1:GKkP0T7U4ks6X3lmmHKC2QDprnpRJor2Z5a8m62R9ZM= github.com/docker/docker v20.10.10+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker-credential-helpers v0.6.3 h1:zI2p9+1NQYdnG6sMU26EX4aVGlqbInSQxQXLvzJ4RPQ= -github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= +github.com/docker/docker-credential-helpers v0.6.4 h1:axCks+yV+2MR3/kZhAmy07yC56WZ2Pwu/fKWtKuZB0o= +github.com/docker/docker-credential-helpers v0.6.4/go.mod h1:ofX3UI0Gz1TteYBjtgs07O36Pyasyp66D2uKT7H8W1c= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= @@ -400,8 +403,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-containerregistry v0.6.0 h1:niQ+8XD//kKgArIFwDVBXsWVWbde16LPdHMyNwSC8h4= -github.com/google/go-containerregistry v0.6.0/go.mod h1:euCCtNbZ6tKqi1E72vwDj2xZcN5ttKpZLfa/wSo5iLw= +github.com/google/go-containerregistry v0.7.0 h1:u0onUUOcyoCDHEiJoyR1R1gx5er1+r06V5DBhUU5ndk= +github.com/google/go-containerregistry v0.7.0/go.mod h1:2zaoelrL0d08gGbpdP3LqyUuBmhWbpD6IOe2s9nLS2k= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -436,8 +439,8 @@ github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97Dwqy github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -508,8 +511,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.0/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -519,6 +520,7 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= @@ -586,7 +588,6 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -917,10 +918,9 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211007125505-59d4e928ea9d h1:QWMn1lFvU/nZ58ssWqiFJMd3DKIII8NYc4sn708XgKs= -golang.org/x/net v0.0.0-20211007125505-59d4e928ea9d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211111160137-58aab5ef257a h1:c83jeVQW0KGKNaKBRfelNYNHaev+qawl9yaA825s8XE= +golang.org/x/net v0.0.0-20211111160137-58aab5ef257a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -937,6 +937,7 @@ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1042,8 +1043,9 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 h1:WecRHqgE09JBkh/584XIE6PMz5KKE/vER4izNUi30AQ= +golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1157,7 +1159,9 @@ google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtuk google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1222,8 +1226,11 @@ google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKr google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e h1:Im71rbA1N3CbIag/PumYhQcNR8bLNmuOtRIyOnnLsT8= -google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211111162719-482062a4217b h1:qvEQEwKjZRAg6rjY/jqfJ7T8/w/D7jTIFJGcaSka96k= +google.golang.org/genproto v0.0.0-20211111162719-482062a4217b/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1253,8 +1260,8 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E= -google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1277,8 +1284,8 @@ gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/vendor/github.com/Microsoft/go-winio/README.md b/vendor/github.com/Microsoft/go-winio/README.md index 60c93fe506..683be1dcf9 100644 --- a/vendor/github.com/Microsoft/go-winio/README.md +++ b/vendor/github.com/Microsoft/go-winio/README.md @@ -11,12 +11,27 @@ package. Please see the LICENSE file for licensing information. -This project has adopted the [Microsoft Open Source Code of -Conduct](https://opensource.microsoft.com/codeofconduct/). For more information -see the [Code of Conduct -FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact -[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional -questions or comments. +## Contributing +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) +declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR +appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. + +We also require that contributors sign their commits using git commit -s or git commit --signoff to certify they either authored the work themselves +or otherwise have permission to use it in this project. Please see https://developercertificate.org/ for more info, as well as to make sure that you can +attest to the rules listed. Our CI uses the DCO Github app to ensure that all commits in a given PR are signed-off. + + +## Code of Conduct + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + + + +## Special Thanks Thanks to natefinch for the inspiration for this library. See https://github.com/natefinch/npipe for another named pipe implementation. diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go index 3ef0291160..e56319545e 100644 --- a/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go @@ -118,7 +118,7 @@ func Open(sr *io.SectionReader, opt ...OpenOption) (*Reader, error) { } } - gzipCompressors := []Decompressor{new(GzipDecompressor), new(legacyGzipDecompressor)} + gzipCompressors := []Decompressor{new(GzipDecompressor), new(LegacyGzipDecompressor)} decompressors := append(gzipCompressors, opts.decompressors...) // Determine the size to fetch. Try to fetch as many bytes as possible. @@ -184,7 +184,7 @@ func OpenFooter(sr *io.SectionReader) (tocOffset int64, footerSize int64, rErr e return 0, 0, fmt.Errorf("error reading footer: %v", err) } var allErr []error - for _, d := range []Decompressor{new(GzipDecompressor), new(legacyGzipDecompressor)} { + for _, d := range []Decompressor{new(GzipDecompressor), new(LegacyGzipDecompressor)} { fSize := d.FooterSize() fOffset := positive(int64(len(footer)) - fSize) _, tocOffset, _, err := d.ParseFooter(footer[fOffset:]) @@ -279,12 +279,12 @@ func (r *Reader) initFields() error { pdir := r.getOrCreateDir(pdirName) ent.NumLink++ // at least one name(ent.Name) references this entry. if ent.Type == "hardlink" { - if org, ok := r.m[cleanEntryName(ent.LinkName)]; ok { - org.NumLink++ // original entry is referenced by this ent.Name. - ent = org - } else { - return fmt.Errorf("%q is a hardlink but the linkname %q isn't found", ent.Name, ent.LinkName) + org, err := r.getSource(ent) + if err != nil { + return err } + org.NumLink++ // original entry is referenced by this ent.Name. + ent = org } pdir.addChild(path.Base(name), ent) } @@ -303,6 +303,20 @@ func (r *Reader) initFields() error { return nil } +func (r *Reader) getSource(ent *TOCEntry) (_ *TOCEntry, err error) { + if ent.Type == "hardlink" { + org, ok := r.m[cleanEntryName(ent.LinkName)] + if !ok { + return nil, fmt.Errorf("%q is a hardlink but the linkname %q isn't found", ent.Name, ent.LinkName) + } + ent, err = r.getSource(org) + if err != nil { + return nil, err + } + } + return ent, nil +} + func parentDir(p string) string { dir, _ := path.Split(p) return strings.TrimSuffix(dir, "/") @@ -464,7 +478,11 @@ func (r *Reader) Lookup(path string) (e *TOCEntry, ok bool) { } e, ok = r.m[path] if ok && e.Type == "hardlink" { - e, ok = r.m[e.LinkName] + var err error + e, err = r.getSource(e) + if err != nil { + return nil, false + } } return } diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go index 88e1283d85..7330849cb8 100644 --- a/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go @@ -38,30 +38,34 @@ import ( ) type gzipCompression struct { - *gzipCompressor + *GzipCompressor *GzipDecompressor } func newGzipCompressionWithLevel(level int) Compression { return &gzipCompression{ - &gzipCompressor{level}, + &GzipCompressor{level}, &GzipDecompressor{}, } } -func NewGzipCompressorWithLevel(level int) Compressor { - return &gzipCompressor{level} +func NewGzipCompressor() *GzipCompressor { + return &GzipCompressor{gzip.BestCompression} } -type gzipCompressor struct { +func NewGzipCompressorWithLevel(level int) *GzipCompressor { + return &GzipCompressor{level} +} + +type GzipCompressor struct { compressionLevel int } -func (gc *gzipCompressor) Writer(w io.Writer) (io.WriteCloser, error) { +func (gc *GzipCompressor) Writer(w io.Writer) (io.WriteCloser, error) { return gzip.NewWriterLevel(w, gc.compressionLevel) } -func (gc *gzipCompressor) WriteTOCAndFooter(w io.Writer, off int64, toc *JTOC, diffHash hash.Hash) (digest.Digest, error) { +func (gc *GzipCompressor) WriteTOCAndFooter(w io.Writer, off int64, toc *JTOC, diffHash hash.Hash) (digest.Digest, error) { tocJSON, err := json.MarshalIndent(toc, "", "\t") if err != nil { return "", err @@ -155,17 +159,21 @@ func (gz *GzipDecompressor) FooterSize() int64 { return FooterSize } -type legacyGzipDecompressor struct{} +func (gz *GzipDecompressor) DecompressTOC(r io.Reader) (tocJSON io.ReadCloser, err error) { + return decompressTOCEStargz(r) +} + +type LegacyGzipDecompressor struct{} -func (gz *legacyGzipDecompressor) Reader(r io.Reader) (io.ReadCloser, error) { +func (gz *LegacyGzipDecompressor) Reader(r io.Reader) (io.ReadCloser, error) { return gzip.NewReader(r) } -func (gz *legacyGzipDecompressor) ParseTOC(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) { +func (gz *LegacyGzipDecompressor) ParseTOC(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) { return parseTOCEStargz(r) } -func (gz *legacyGzipDecompressor) ParseFooter(p []byte) (blobPayloadSize, tocOffset, tocSize int64, err error) { +func (gz *LegacyGzipDecompressor) ParseFooter(p []byte) (blobPayloadSize, tocOffset, tocSize int64, err error) { if len(p) != legacyFooterSize { return 0, 0, 0, fmt.Errorf("legacy: invalid length %d cannot be parsed", len(p)) } @@ -188,29 +196,43 @@ func (gz *legacyGzipDecompressor) ParseFooter(p []byte) (blobPayloadSize, tocOff return tocOffset, tocOffset, 0, nil } -func (gz *legacyGzipDecompressor) FooterSize() int64 { +func (gz *LegacyGzipDecompressor) FooterSize() int64 { return legacyFooterSize } +func (gz *LegacyGzipDecompressor) DecompressTOC(r io.Reader) (tocJSON io.ReadCloser, err error) { + return decompressTOCEStargz(r) +} + func parseTOCEStargz(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) { + tr, err := decompressTOCEStargz(r) + if err != nil { + return nil, "", err + } + dgstr := digest.Canonical.Digester() + toc = new(JTOC) + if err := json.NewDecoder(io.TeeReader(tr, dgstr.Hash())).Decode(&toc); err != nil { + return nil, "", fmt.Errorf("error decoding TOC JSON: %v", err) + } + if err := tr.Close(); err != nil { + return nil, "", err + } + return toc, dgstr.Digest(), nil +} + +func decompressTOCEStargz(r io.Reader) (tocJSON io.ReadCloser, err error) { zr, err := gzip.NewReader(r) if err != nil { - return nil, "", fmt.Errorf("malformed TOC gzip header: %v", err) + return nil, fmt.Errorf("malformed TOC gzip header: %v", err) } - defer zr.Close() zr.Multistream(false) tr := tar.NewReader(zr) h, err := tr.Next() if err != nil { - return nil, "", fmt.Errorf("failed to find tar header in TOC gzip stream: %v", err) + return nil, fmt.Errorf("failed to find tar header in TOC gzip stream: %v", err) } if h.Name != TOCTarName { - return nil, "", fmt.Errorf("TOC tar entry had name %q; expected %q", h.Name, TOCTarName) + return nil, fmt.Errorf("TOC tar entry had name %q; expected %q", h.Name, TOCTarName) } - dgstr := digest.Canonical.Digester() - toc = new(JTOC) - if err := json.NewDecoder(io.TeeReader(tr, dgstr.Hash())).Decode(&toc); err != nil { - return nil, "", fmt.Errorf("error decoding TOC JSON: %v", err) - } - return toc, dgstr.Digest(), nil + return readCloser{tr, zr.Close}, nil } diff --git a/vendor/github.com/docker/docker-credential-helpers/client/command.go b/vendor/github.com/docker/docker-credential-helpers/client/command.go index 8da3343065..0183c06393 100644 --- a/vendor/github.com/docker/docker-credential-helpers/client/command.go +++ b/vendor/github.com/docker/docker-credential-helpers/client/command.go @@ -4,7 +4,8 @@ import ( "fmt" "io" "os" - "os/exec" + + exec "golang.org/x/sys/execabs" ) // Program is an interface to execute external programs. diff --git a/vendor/github.com/docker/docker-credential-helpers/credentials/version.go b/vendor/github.com/docker/docker-credential-helpers/credentials/version.go index c2cc3e2e02..185e367961 100644 --- a/vendor/github.com/docker/docker-credential-helpers/credentials/version.go +++ b/vendor/github.com/docker/docker-credential-helpers/credentials/version.go @@ -1,4 +1,4 @@ package credentials // Version holds a string describing the current version -const Version = "0.6.3" +const Version = "0.6.4" diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/append.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/append.go index a4addd1118..837749067e 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/append.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/append.go @@ -22,6 +22,8 @@ import ( "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/empty" + "github.com/google/go-containerregistry/pkg/v1/mutate" + specsv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/cobra" ) @@ -29,6 +31,7 @@ import ( func NewCmdAppend(options *[]crane.Option) *cobra.Command { var baseRef, newTag, outFile string var newLayers []string + var annotate bool appendCmd := &cobra.Command{ Use: "append", @@ -44,30 +47,49 @@ func NewCmdAppend(options *[]crane.Option) *cobra.Command { } else { base, err = crane.Pull(baseRef, *options...) if err != nil { - return fmt.Errorf("pulling %s: %v", baseRef, err) + return fmt.Errorf("pulling %s: %w", baseRef, err) } } img, err := crane.Append(base, newLayers...) if err != nil { - return fmt.Errorf("appending %v: %v", newLayers, err) + return fmt.Errorf("appending %v: %w", newLayers, err) + } + + if baseRef != "" && annotate { + ref, err := name.ParseReference(baseRef) + if err != nil { + return fmt.Errorf("parsing ref %q: %w", baseRef, err) + } + + baseDigest, err := base.Digest() + if err != nil { + return err + } + anns := map[string]string{ + specsv1.AnnotationBaseImageDigest: baseDigest.String(), + } + if _, ok := ref.(name.Tag); ok { + anns[specsv1.AnnotationBaseImageName] = ref.Name() + } + img = mutate.Annotations(img, anns).(v1.Image) } if outFile != "" { if err := crane.Save(img, newTag, outFile); err != nil { - return fmt.Errorf("writing output %q: %v", outFile, err) + return fmt.Errorf("writing output %q: %w", outFile, err) } } else { if err := crane.Push(img, newTag, *options...); err != nil { - return fmt.Errorf("pushing image %s: %v", newTag, err) + return fmt.Errorf("pushing image %s: %w", newTag, err) } ref, err := name.ParseReference(newTag) if err != nil { - return fmt.Errorf("parsing reference %s: %v", newTag, err) + return fmt.Errorf("parsing reference %s: %w", newTag, err) } d, err := img.Digest() if err != nil { - return fmt.Errorf("digest: %v", err) + return fmt.Errorf("digest: %w", err) } fmt.Println(ref.Context().Digest(d.String())) } @@ -78,6 +100,7 @@ func NewCmdAppend(options *[]crane.Option) *cobra.Command { appendCmd.Flags().StringVarP(&newTag, "new_tag", "t", "", "Tag to apply to resulting image") appendCmd.Flags().StringSliceVarP(&newLayers, "new_layer", "f", []string{}, "Path to tarball to append to image") appendCmd.Flags().StringVarP(&outFile, "output", "o", "", "Path to new tarball of resulting image") + appendCmd.Flags().BoolVar(&annotate, "set-base-image-annotations", false, "If true, annotate the resulting image as being based on the base image") appendCmd.MarkFlagRequired("new_tag") appendCmd.MarkFlagRequired("new_layer") diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/auth.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/auth.go index 4c2ab2a43a..4914aeaee0 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/auth.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/auth.go @@ -36,9 +36,7 @@ func NewCmdAuth(argv ...string) *cobra.Command { Use: "auth", Short: "Log in or access credentials", Args: cobra.NoArgs, - Run: func(cmd *cobra.Command, args []string) { - cmd.Usage() - }, + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } cmd.AddCommand(NewCmdAuthGet(argv...), NewCmdAuthLogin(argv...)) return cmd diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/blob.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/blob.go index ca32a983bb..fef405f77e 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/blob.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/blob.go @@ -33,14 +33,14 @@ func NewCmdBlob(options *[]crane.Option) *cobra.Command { src := args[0] layer, err := crane.PullLayer(src, *options...) if err != nil { - return fmt.Errorf("pulling layer %s: %v", src, err) + return fmt.Errorf("pulling layer %s: %w", src, err) } blob, err := layer.Compressed() if err != nil { - return fmt.Errorf("fetching blob %s: %v", src, err) + return fmt.Errorf("fetching blob %s: %w", src, err) } if _, err := io.Copy(cmd.OutOrStdout(), blob); err != nil { - return fmt.Errorf("copying blob %s: %v", src, err) + return fmt.Errorf("copying blob %s: %w", src, err) } return nil }, diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/catalog.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/catalog.go index f8eb7cf14a..9e3d13fd65 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/catalog.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/catalog.go @@ -31,7 +31,7 @@ func NewCmdCatalog(options *[]crane.Option) *cobra.Command { reg := args[0] repos, err := crane.Catalog(reg, *options...) if err != nil { - return fmt.Errorf("reading repos for %s: %v", reg, err) + return fmt.Errorf("reading repos for %s: %w", reg, err) } for _, repo := range repos { diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/config.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/config.go index 4fa55162b9..ed2a3fb148 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/config.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/config.go @@ -30,7 +30,7 @@ func NewCmdConfig(options *[]crane.Option) *cobra.Command { RunE: func(_ *cobra.Command, args []string) error { cfg, err := crane.Config(args[0], *options...) if err != nil { - return fmt.Errorf("fetching config: %v", err) + return fmt.Errorf("fetching config: %w", err) } fmt.Print(string(cfg)) return nil diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/digest.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/digest.go index 26e3021861..0447b5dea2 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/digest.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/digest.go @@ -31,7 +31,9 @@ func NewCmdDigest(options *[]crane.Option) *cobra.Command { Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { if tarball == "" && len(args) == 0 { - cmd.Help() + if err := cmd.Help(); err != nil { + return err + } return errors.New("image reference required without --tarball") } @@ -65,11 +67,11 @@ func getTarballDigest(tarball string, args []string, options *[]crane.Option) (s img, err := crane.LoadTag(tarball, tag, *options...) if err != nil { - return "", fmt.Errorf("loading image from %q: %v", tarball, err) + return "", fmt.Errorf("loading image from %q: %w", tarball, err) } digest, err := img.Digest() if err != nil { - return "", fmt.Errorf("computing digest: %v", err) + return "", fmt.Errorf("computing digest: %w", err) } return digest.String(), nil } diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/export.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/export.go index 268fa8ac2d..d1f9ac48e4 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/export.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/export.go @@ -38,13 +38,13 @@ func NewCmdExport(options *[]crane.Option) *cobra.Command { f, err := openFile(dst) if err != nil { - return fmt.Errorf("failed to open %s: %v", dst, err) + return fmt.Errorf("failed to open %s: %w", dst, err) } defer f.Close() img, err := crane.Pull(src, *options...) if err != nil { - return fmt.Errorf("pulling %s: %v", src, err) + return fmt.Errorf("pulling %s: %w", src, err) } return crane.Export(img, f) diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/flatten.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/flatten.go new file mode 100644 index 0000000000..76c13f198e --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/flatten.go @@ -0,0 +1,254 @@ +// Copyright 2021 Google LLC All Rights Reserved. +// +// 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 cmd + +import ( + "compress/gzip" + "encoding/json" + "fmt" + "log" + + "github.com/google/go-containerregistry/pkg/crane" + "github.com/google/go-containerregistry/pkg/logs" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/empty" + "github.com/google/go-containerregistry/pkg/v1/mutate" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/remote" + "github.com/google/go-containerregistry/pkg/v1/stream" + "github.com/spf13/cobra" +) + +// NewCmdFlatten creates a new cobra.Command for the flatten subcommand. +func NewCmdFlatten(options *[]crane.Option) *cobra.Command { + var dst string + + flattenCmd := &cobra.Command{ + Use: "flatten", + Short: "Flatten an image's layers into a single layer", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + // We need direct access to the underlying remote options because crane + // doesn't expose great facilities for working with an index (yet). + o := crane.GetOptions(*options...) + + // Pull image and get config. + src := args[0] + + // If the new ref isn't provided, write over the original image. + // If that ref was provided by digest (e.g., output from + // another crane command), then strip that and push the + // mutated image by digest instead. + if dst == "" { + dst = src + } + + ref, err := name.ParseReference(src, o.Name...) + if err != nil { + log.Fatalf("parsing %s: %v", src, err) + } + newRef, err := name.ParseReference(dst, o.Name...) + if err != nil { + log.Fatalf("parsing %s: %v", dst, err) + } + repo := newRef.Context() + + flat, err := flatten(ref, repo, cmd.Parent().Use, o) + if err != nil { + log.Fatalf("flattening %s: %v", ref, err) + } + + digest, err := flat.Digest() + if err != nil { + log.Fatalf("digesting new image: %v", err) + } + + if _, ok := ref.(name.Digest); ok { + newRef = repo.Digest(digest.String()) + } + + if err := push(flat, newRef, o); err != nil { + log.Fatalf("pushing %s: %v", newRef, err) + } + fmt.Println(repo.Digest(digest.String())) + }, + } + flattenCmd.Flags().StringVarP(&dst, "tag", "t", "", "New tag to apply to flattened image. If not provided, push by digest to the original image repository.") + return flattenCmd +} + +func flatten(ref name.Reference, repo name.Repository, use string, o crane.Options) (partial.Describable, error) { + desc, err := remote.Get(ref, o.Remote...) + if err != nil { + return nil, fmt.Errorf("pulling %s: %w", ref, err) + } + + if desc.MediaType.IsIndex() { + idx, err := desc.ImageIndex() + if err != nil { + return nil, err + } + return flattenIndex(idx, repo, use, o) + } else if desc.MediaType.IsImage() { + img, err := desc.Image() + if err != nil { + return nil, err + } + return flattenImage(img, repo, use, o) + } + + return nil, fmt.Errorf("can't flatten %s", desc.MediaType) +} + +func push(flat partial.Describable, ref name.Reference, o crane.Options) error { + if idx, ok := flat.(v1.ImageIndex); ok { + return remote.WriteIndex(ref, idx, o.Remote...) + } else if img, ok := flat.(v1.Image); ok { + return remote.Write(ref, img, o.Remote...) + } + + return fmt.Errorf("can't push %T", flat) +} + +type remoteIndex interface { + Manifests() ([]partial.Describable, error) +} + +func flattenIndex(old v1.ImageIndex, repo name.Repository, use string, o crane.Options) (partial.Describable, error) { + ri, ok := old.(remoteIndex) + if !ok { + return nil, fmt.Errorf("unexpected index") + } + + m, err := old.IndexManifest() + if err != nil { + return nil, err + } + + manifests, err := ri.Manifests() + if err != nil { + return nil, err + } + + adds := []mutate.IndexAddendum{} + + for _, m := range manifests { + // Keep the old descriptor (annotations and whatnot). + desc, err := partial.Descriptor(m) + if err != nil { + return nil, err + } + + flattened, err := flattenChild(m, repo, use, o) + if err != nil { + return nil, err + } + desc.Size, err = flattened.Size() + if err != nil { + return nil, err + } + desc.Digest, err = flattened.Digest() + if err != nil { + return nil, err + } + adds = append(adds, mutate.IndexAddendum{ + Add: flattened, + Descriptor: *desc, + }) + } + + idx := mutate.AppendManifests(empty.Index, adds...) + + // Retain any annotations from the original index. + if len(m.Annotations) != 0 { + idx = mutate.Annotations(idx, m.Annotations).(v1.ImageIndex) + } + + // This is stupid, but some registries get mad if you try to push OCI media types that reference docker media types. + mt, err := old.MediaType() + if err != nil { + return nil, err + } + idx = mutate.IndexMediaType(idx, mt) + + return idx, nil +} + +func flattenChild(old partial.Describable, repo name.Repository, use string, o crane.Options) (partial.Describable, error) { + if idx, ok := old.(v1.ImageIndex); ok { + return flattenIndex(idx, repo, use, o) + } else if img, ok := old.(v1.Image); ok { + return flattenImage(img, repo, use, o) + } + + logs.Warn.Printf("can't flatten %T, skipping", old) + return old, nil +} + +func flattenImage(old v1.Image, repo name.Repository, use string, o crane.Options) (partial.Describable, error) { + digest, err := old.Digest() + if err != nil { + return nil, fmt.Errorf("getting old digest: %w", err) + } + m, err := old.Manifest() + if err != nil { + return nil, fmt.Errorf("reading manifest: %w", err) + } + + cf, err := old.ConfigFile() + if err != nil { + return nil, fmt.Errorf("getting config: %w", err) + } + cf = cf.DeepCopy() + + oldHistory, err := json.Marshal(cf.History) + if err != nil { + return nil, fmt.Errorf("marshal history") + } + + // Clear layer-specific config file information. + cf.RootFS.DiffIDs = []v1.Hash{} + cf.History = []v1.History{} + + img, err := mutate.ConfigFile(empty.Image, cf) + if err != nil { + return nil, fmt.Errorf("mutating config: %w", err) + } + + // TODO: Make compression configurable? + layer := stream.NewLayer(mutate.Extract(old), stream.WithCompressionLevel(gzip.BestCompression)) + if err := remote.WriteLayer(repo, layer, o.Remote...); err != nil { + return nil, fmt.Errorf("uploading layer: %w", err) + } + + img, err = mutate.Append(img, mutate.Addendum{ + Layer: layer, + History: v1.History{ + CreatedBy: fmt.Sprintf("%s flatten %s", use, digest), + Comment: string(oldHistory), + }, + }) + if err != nil { + return nil, fmt.Errorf("appending layers: %w", err) + } + + // Retain any annotations from the original image. + if len(m.Annotations) != 0 { + img = mutate.Annotations(img, m.Annotations).(v1.Image) + } + + return img, nil +} diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/list.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/list.go index 0db1473b07..6f86f8bbb7 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/list.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/list.go @@ -31,7 +31,7 @@ func NewCmdList(options *[]crane.Option) *cobra.Command { repo := args[0] tags, err := crane.ListTags(repo, *options...) if err != nil { - return fmt.Errorf("reading tags for %s: %v", repo, err) + return fmt.Errorf("reading tags for %s: %w", repo, err) } for _, tag := range tags { diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/manifest.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/manifest.go index 80d70b026f..d9ef7fd8fc 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/manifest.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/manifest.go @@ -31,7 +31,7 @@ func NewCmdManifest(options *[]crane.Option) *cobra.Command { src := args[0] manifest, err := crane.Manifest(src, *options...) if err != nil { - return fmt.Errorf("fetching manifest %s: %v", src, err) + return fmt.Errorf("fetching manifest %s: %w", src, err) } fmt.Print(string(manifest)) return nil diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/pull.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/pull.go index 08a1e9380b..f45e77c592 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/pull.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/pull.go @@ -37,7 +37,7 @@ func NewCmdPull(options *[]crane.Option) *cobra.Command { for _, src := range srcList { img, err := crane.Pull(src, *options...) if err != nil { - return fmt.Errorf("pulling %s: %v", src, err) + return fmt.Errorf("pulling %s: %w", src, err) } if cachePath != "" { img = cache.Image(img, cache.NewFilesystemCache(cachePath)) @@ -49,15 +49,15 @@ func NewCmdPull(options *[]crane.Option) *cobra.Command { switch format { case "tarball": if err := crane.MultiSave(imageMap, path); err != nil { - return fmt.Errorf("saving tarball %s: %v", path, err) + return fmt.Errorf("saving tarball %s: %w", path, err) } case "legacy": if err := crane.MultiSaveLegacy(imageMap, path); err != nil { - return fmt.Errorf("saving legacy tarball %s: %v", path, err) + return fmt.Errorf("saving legacy tarball %s: %w", path, err) } case "oci": if err := crane.MultiSaveOCI(imageMap, path); err != nil { - return fmt.Errorf("saving oci image layout %s: %v", path, err) + return fmt.Errorf("saving oci image layout %s: %w", path, err) } default: return fmt.Errorf("unexpected --format: %q (valid values are: tarball, legacy, and oci)", format) diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/push.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/push.go index 5a4731cdf0..affb4091c5 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/push.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/push.go @@ -31,7 +31,7 @@ func NewCmdPush(options *[]crane.Option) *cobra.Command { path, tag := args[0], args[1] img, err := crane.Load(path) if err != nil { - return fmt.Errorf("loading %s as tarball: %v", path, err) + return fmt.Errorf("loading %s as tarball: %w", path, err) } return crane.Push(img, tag, *options...) diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/rebase.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/rebase.go index 8fe916fe0c..b74a5d8438 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/rebase.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/rebase.go @@ -15,10 +15,16 @@ package cmd import ( + "errors" "fmt" + "log" "github.com/google/go-containerregistry/pkg/crane" + "github.com/google/go-containerregistry/pkg/logs" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/mutate" + specsv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/cobra" ) @@ -29,48 +35,176 @@ func NewCmdRebase(options *[]crane.Option) *cobra.Command { rebaseCmd := &cobra.Command{ Use: "rebase", Short: "Rebase an image onto a new base image", - Args: cobra.NoArgs, - RunE: func(*cobra.Command, []string) error { - origImg, err := crane.Pull(orig, *options...) - if err != nil { - return fmt.Errorf("pulling %s: %v", orig, err) + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if orig == "" { + orig = args[0] + } else if len(args) != 0 || args[0] != "" { + return fmt.Errorf("cannot use --original with positional argument") + } + + // If the new ref isn't provided, write over the original image. + // If that ref was provided by digest (e.g., output from + // another crane command), then strip that and push the + // mutated image by digest instead. + if rebased == "" { + rebased = orig } - oldBaseImg, err := crane.Pull(oldBase, *options...) + // Stupid hack to support insecure flag. + nameOpt := []name.Option{} + if ok, err := cmd.Parent().PersistentFlags().GetBool("insecure"); err != nil { + log.Fatalf("flag problems: %v", err) + } else if ok { + nameOpt = append(nameOpt, name.Insecure) + } + r, err := name.ParseReference(rebased, nameOpt...) if err != nil { - return fmt.Errorf("pulling %s: %v", oldBase, err) + log.Fatalf("parsing %s: %v", rebased, err) } - newBaseImg, err := crane.Pull(newBase, *options...) + desc, err := crane.Head(orig, *options...) if err != nil { - return fmt.Errorf("pulling %s: %v", newBase, err) + log.Fatalf("checking %s: %v", orig, err) + } + if !cmd.Parent().PersistentFlags().Changed("platform") && desc.MediaType.IsIndex() { + log.Fatalf("rebasing an index is not yet supported") } - img, err := mutate.Rebase(origImg, oldBaseImg, newBaseImg) + origImg, err := crane.Pull(orig, *options...) + if err != nil { + return err + } + origMf, err := origImg.Manifest() + if err != nil { + return err + } + anns := origMf.Annotations + if newBase == "" && anns != nil { + newBase = anns[specsv1.AnnotationBaseImageName] + } + if newBase == "" { + return errors.New("could not determine new base image from annotations") + } + newBaseRef, err := name.ParseReference(newBase) if err != nil { - return fmt.Errorf("rebasing: %v", err) + return err + } + if oldBase == "" && anns != nil { + oldBaseDigest := anns[specsv1.AnnotationBaseImageDigest] + oldBase = newBaseRef.Context().Digest(oldBaseDigest).String() + } + if oldBase == "" { + return errors.New("could not determine old base image by digest from annotations") } - if err := crane.Push(img, rebased, *options...); err != nil { - return fmt.Errorf("pushing %s: %v", rebased, err) + rebasedImg, err := rebaseImage(origImg, oldBase, newBase, *options...) + if err != nil { + return fmt.Errorf("rebasing image: %w", err) } - digest, err := img.Digest() + rebasedDigest, err := rebasedImg.Digest() if err != nil { - return fmt.Errorf("digesting rebased: %v", err) + return fmt.Errorf("digesting new image: %w", err) + } + origDigest, err := origImg.Digest() + if err != nil { + return err + } + if rebasedDigest == origDigest { + logs.Warn.Println("rebasing was no-op") + } + + if _, ok := r.(name.Digest); ok { + rebased = r.Context().Digest(rebasedDigest.String()).String() + } + logs.Progress.Println("pushing rebased image as", rebased) + if err := crane.Push(rebasedImg, rebased, *options...); err != nil { + log.Fatalf("pushing %s: %v", rebased, err) } - fmt.Println(digest.String()) + + fmt.Println(r.Context().Digest(rebasedDigest.String())) return nil }, } - rebaseCmd.Flags().StringVarP(&orig, "original", "", "", "Original image to rebase") - rebaseCmd.Flags().StringVarP(&oldBase, "old_base", "", "", "Old base image to remove") - rebaseCmd.Flags().StringVarP(&newBase, "new_base", "", "", "New base image to insert") - rebaseCmd.Flags().StringVarP(&rebased, "rebased", "", "", "Tag to apply to rebased image") - - rebaseCmd.MarkFlagRequired("original") - rebaseCmd.MarkFlagRequired("old_base") - rebaseCmd.MarkFlagRequired("new_base") - rebaseCmd.MarkFlagRequired("rebased") + rebaseCmd.Flags().StringVar(&orig, "original", "", "Original image to rebase (DEPRECATED: use positional arg instead)") + rebaseCmd.Flags().StringVar(&oldBase, "old_base", "", "Old base image to remove") + rebaseCmd.Flags().StringVar(&newBase, "new_base", "", "New base image to insert") + rebaseCmd.Flags().StringVar(&rebased, "rebased", "", "Tag to apply to rebased image (DEPRECATED: use --tag)") + rebaseCmd.Flags().StringVarP(&rebased, "tag", "t", "", "Tag to apply to rebased image") return rebaseCmd } + +// rebaseImage parses the references and uses them to perform a rebase on the +// original image. +// +// If oldBase or newBase are "", rebaseImage attempts to derive them using +// annotations in the original image. If those annotations are not found, +// rebaseImage returns an error. +// +// If rebasing is successful, base image annotations are set on the resulting +// image to facilitate implicit rebasing next time. +func rebaseImage(orig v1.Image, oldBase, newBase string, opt ...crane.Option) (v1.Image, error) { + m, err := orig.Manifest() + if err != nil { + return nil, err + } + if newBase == "" && m.Annotations != nil { + newBase = m.Annotations[specsv1.AnnotationBaseImageName] + if newBase != "" { + logs.Debug.Printf("Detected new base from %q annotation: %s", specsv1.AnnotationBaseImageName, newBase) + } + } + if newBase == "" { + return nil, fmt.Errorf("either new base or %q annotation is required", specsv1.AnnotationBaseImageName) + } + newBaseImg, err := crane.Pull(newBase, opt...) + if err != nil { + return nil, err + } + + if oldBase == "" && m.Annotations != nil { + oldBase = m.Annotations[specsv1.AnnotationBaseImageDigest] + if oldBase != "" { + newBaseRef, err := name.ParseReference(newBase) + if err != nil { + return nil, err + } + + oldBase = newBaseRef.Context().Digest(oldBase).String() + logs.Debug.Printf("Detected old base from %q annotation: %s", specsv1.AnnotationBaseImageDigest, oldBase) + } + } + if oldBase == "" { + return nil, fmt.Errorf("either old base or %q annotation is required", specsv1.AnnotationBaseImageDigest) + } + + oldBaseImg, err := crane.Pull(oldBase, opt...) + if err != nil { + return nil, err + } + + // NB: if newBase is an index, we need to grab the index's digest to + // annotate the resulting image, even though we pull the + // platform-specific image to rebase. + // crane.Digest will pull a platform-specific image, so use crane.Head + // here instead. + newBaseDesc, err := crane.Head(newBase, opt...) + if err != nil { + return nil, err + } + newBaseDigest := newBaseDesc.Digest.String() + + rebased, err := mutate.Rebase(orig, oldBaseImg, newBaseImg) + if err != nil { + return nil, err + } + + // Update base image annotations for the new image manifest. + logs.Debug.Printf("Setting annotation %q: %q", specsv1.AnnotationBaseImageDigest, newBaseDigest) + logs.Debug.Printf("Setting annotation %q: %q", specsv1.AnnotationBaseImageName, newBase) + return mutate.Annotations(rebased, map[string]string{ + specsv1.AnnotationBaseImageDigest: newBaseDigest, + specsv1.AnnotationBaseImageName: newBase, + }).(v1.Image), nil +} diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/root.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/root.go index d0c038b827..87f36fa7d5 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/root.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/root.go @@ -22,6 +22,7 @@ import ( "github.com/docker/cli/cli/config" "github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/logs" + "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/spf13/cobra" ) @@ -38,11 +39,12 @@ func New(use, short string, options []crane.Option) *cobra.Command { verbose := false insecure := false platform := &platformValue{} + var osVersion string root := &cobra.Command{ Use: use, Short: short, - Run: func(cmd *cobra.Command, _ []string) { cmd.Usage() }, + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, DisableAutoGenTag: true, SilenceUsage: true, PersistentPreRun: func(cmd *cobra.Command, args []string) { @@ -62,9 +64,13 @@ func New(use, short string, options []crane.Option) *cobra.Command { options = append(options, crane.WithUserAgent(fmt.Sprintf("%s/%s", binary, Version))) } + if osVersion != "" { + platform.platform.OSVersion = osVersion + } + options = append(options, crane.WithPlatform(platform.platform)) - transport := http.DefaultTransport.(*http.Transport).Clone() + transport := remote.DefaultTransport.Clone() transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: insecure} var rt http.RoundTripper = transport @@ -93,6 +99,7 @@ func New(use, short string, options []crane.Option) *cobra.Command { NewCmdDelete(&options), NewCmdDigest(&options), NewCmdExport(&options), + NewCmdFlatten(&options), NewCmdList(&options), NewCmdManifest(&options), NewCmdOptimize(&options), @@ -110,6 +117,7 @@ func New(use, short string, options []crane.Option) *cobra.Command { root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable debug logs") root.PersistentFlags().BoolVar(&insecure, "insecure", false, "Allow image references to be fetched without TLS") root.PersistentFlags().Var(platform, "platform", "Specifies the platform in the form os/arch[/variant] (e.g. linux/amd64).") + root.PersistentFlags().StringVar(&osVersion, "osversion", "", "Specifies the OS version.") return root } diff --git a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/validate.go b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/validate.go index 843c18f008..4a4acbd95a 100644 --- a/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/validate.go +++ b/vendor/github.com/google/go-containerregistry/cmd/crane/cmd/validate.go @@ -45,7 +45,7 @@ func NewCmdValidate(options *[]crane.Option) *cobra.Command { } img, err := maker(flag, *options...) if err != nil { - return fmt.Errorf("failed to read image %s: %v", flag, err) + return fmt.Errorf("failed to read image %s: %w", flag, err) } opt := []validate.Option{} @@ -55,9 +55,8 @@ func NewCmdValidate(options *[]crane.Option) *cobra.Command { if err := validate.Image(img, opt...); err != nil { fmt.Printf("FAIL: %s: %v\n", flag, err) return err - } else { - fmt.Printf("PASS: %s\n", flag) } + fmt.Printf("PASS: %s\n", flag) } return nil }, @@ -69,6 +68,6 @@ func NewCmdValidate(options *[]crane.Option) *cobra.Command { return validateCmd } -func makeTarball(path string, opts ...crane.Option) (v1.Image, error) { +func makeTarball(path string, _ ...crane.Option) (v1.Image, error) { return tarball.ImageFromPath(path, nil) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/append.go b/vendor/github.com/google/go-containerregistry/pkg/crane/append.go index 6d7253ab50..4f660d8fc9 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/append.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/append.go @@ -30,7 +30,7 @@ func Append(base v1.Image, paths ...string) (v1.Image, error) { for _, path := range paths { layer, err := getLayer(path) if err != nil { - return nil, fmt.Errorf("reading layer %q: %v", path, err) + return nil, fmt.Errorf("reading layer %q: %w", path, err) } layers = append(layers, layer) diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/catalog.go b/vendor/github.com/google/go-containerregistry/pkg/crane/catalog.go index 5453254566..f30800cca3 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/catalog.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/catalog.go @@ -24,12 +24,12 @@ import ( // Catalog returns the repositories in a registry's catalog. func Catalog(src string, opt ...Option) (res []string, err error) { o := makeOptions(opt...) - reg, err := name.NewRegistry(src, o.name...) + reg, err := name.NewRegistry(src, o.Name...) if err != nil { return nil, err } // This context gets overridden by remote.WithContext, which is set by // crane.WithContext. - return remote.Catalog(context.Background(), reg, o.remote...) + return remote.Catalog(context.Background(), reg, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/copy.go b/vendor/github.com/google/go-containerregistry/pkg/crane/copy.go index b922b34a60..a606f96544 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/copy.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/copy.go @@ -27,62 +27,62 @@ import ( // Copy copies a remote image or index from src to dst. func Copy(src, dst string, opt ...Option) error { o := makeOptions(opt...) - srcRef, err := name.ParseReference(src, o.name...) + srcRef, err := name.ParseReference(src, o.Name...) if err != nil { - return fmt.Errorf("parsing reference %q: %v", src, err) + return fmt.Errorf("parsing reference %q: %w", src, err) } - dstRef, err := name.ParseReference(dst, o.name...) + dstRef, err := name.ParseReference(dst, o.Name...) if err != nil { - return fmt.Errorf("parsing reference for %q: %v", dst, err) + return fmt.Errorf("parsing reference for %q: %w", dst, err) } logs.Progress.Printf("Copying from %v to %v", srcRef, dstRef) - desc, err := remote.Get(srcRef, o.remote...) + desc, err := remote.Get(srcRef, o.Remote...) if err != nil { - return fmt.Errorf("fetching %q: %v", src, err) + return fmt.Errorf("fetching %q: %w", src, err) } switch desc.MediaType { case types.OCIImageIndex, types.DockerManifestList: // Handle indexes separately. - if o.platform != nil { + if o.Platform != nil { // If platform is explicitly set, don't copy the whole index, just the appropriate image. if err := copyImage(desc, dstRef, o); err != nil { - return fmt.Errorf("failed to copy image: %v", err) + return fmt.Errorf("failed to copy image: %w", err) } } else { if err := copyIndex(desc, dstRef, o); err != nil { - return fmt.Errorf("failed to copy index: %v", err) + return fmt.Errorf("failed to copy index: %w", err) } } case types.DockerManifestSchema1, types.DockerManifestSchema1Signed: // Handle schema 1 images separately. - if err := legacy.CopySchema1(desc, srcRef, dstRef, o.remote...); err != nil { - return fmt.Errorf("failed to copy schema 1 image: %v", err) + if err := legacy.CopySchema1(desc, srcRef, dstRef, o.Remote...); err != nil { + return fmt.Errorf("failed to copy schema 1 image: %w", err) } default: // Assume anything else is an image, since some registries don't set mediaTypes properly. if err := copyImage(desc, dstRef, o); err != nil { - return fmt.Errorf("failed to copy image: %v", err) + return fmt.Errorf("failed to copy image: %w", err) } } return nil } -func copyImage(desc *remote.Descriptor, dstRef name.Reference, o options) error { +func copyImage(desc *remote.Descriptor, dstRef name.Reference, o Options) error { img, err := desc.Image() if err != nil { return err } - return remote.Write(dstRef, img, o.remote...) + return remote.Write(dstRef, img, o.Remote...) } -func copyIndex(desc *remote.Descriptor, dstRef name.Reference, o options) error { +func copyIndex(desc *remote.Descriptor, dstRef name.Reference, o Options) error { idx, err := desc.ImageIndex() if err != nil { return err } - return remote.WriteIndex(dstRef, idx, o.remote...) + return remote.WriteIndex(dstRef, idx, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/delete.go b/vendor/github.com/google/go-containerregistry/pkg/crane/delete.go index 487c888c69..58a8be1f0b 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/delete.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/delete.go @@ -24,10 +24,10 @@ import ( // Delete deletes the remote reference at src. func Delete(src string, opt ...Option) error { o := makeOptions(opt...) - ref, err := name.ParseReference(src, o.name...) + ref, err := name.ParseReference(src, o.Name...) if err != nil { - return fmt.Errorf("parsing reference %q: %v", src, err) + return fmt.Errorf("parsing reference %q: %w", src, err) } - return remote.Delete(ref, o.remote...) + return remote.Delete(ref, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/digest.go b/vendor/github.com/google/go-containerregistry/pkg/crane/digest.go index 25b9fdf445..868a57010d 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/digest.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/digest.go @@ -19,7 +19,7 @@ import "github.com/google/go-containerregistry/pkg/logs" // Digest returns the sha256 hash of the remote image at ref. func Digest(ref string, opt ...Option) (string, error) { o := makeOptions(opt...) - if o.platform != nil { + if o.Platform != nil { desc, err := getManifest(ref, opt...) if err != nil { return "", err diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/get.go b/vendor/github.com/google/go-containerregistry/pkg/crane/get.go index aec1f89c60..1f12f01d0d 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/get.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/get.go @@ -24,33 +24,33 @@ import ( func getImage(r string, opt ...Option) (v1.Image, name.Reference, error) { o := makeOptions(opt...) - ref, err := name.ParseReference(r, o.name...) + ref, err := name.ParseReference(r, o.Name...) if err != nil { - return nil, nil, fmt.Errorf("parsing reference %q: %v", r, err) + return nil, nil, fmt.Errorf("parsing reference %q: %w", r, err) } - img, err := remote.Image(ref, o.remote...) + img, err := remote.Image(ref, o.Remote...) if err != nil { - return nil, nil, fmt.Errorf("reading image %q: %v", ref, err) + return nil, nil, fmt.Errorf("reading image %q: %w", ref, err) } return img, ref, nil } func getManifest(r string, opt ...Option) (*remote.Descriptor, error) { o := makeOptions(opt...) - ref, err := name.ParseReference(r, o.name...) + ref, err := name.ParseReference(r, o.Name...) if err != nil { - return nil, fmt.Errorf("parsing reference %q: %v", r, err) + return nil, fmt.Errorf("parsing reference %q: %w", r, err) } - return remote.Get(ref, o.remote...) + return remote.Get(ref, o.Remote...) } // Head performs a HEAD request for a manifest and returns a content descriptor // based on the registry's response. func Head(r string, opt ...Option) (*v1.Descriptor, error) { o := makeOptions(opt...) - ref, err := name.ParseReference(r, o.name...) + ref, err := name.ParseReference(r, o.Name...) if err != nil { return nil, err } - return remote.Head(ref, o.remote...) + return remote.Head(ref, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/list.go b/vendor/github.com/google/go-containerregistry/pkg/crane/list.go index 5e3a40dfdc..38352153bb 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/list.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/list.go @@ -24,10 +24,10 @@ import ( // ListTags returns the tags in repository src. func ListTags(src string, opt ...Option) ([]string, error) { o := makeOptions(opt...) - repo, err := name.NewRepository(src, o.name...) + repo, err := name.NewRepository(src, o.Name...) if err != nil { - return nil, fmt.Errorf("parsing repo %q: %v", src, err) + return nil, fmt.Errorf("parsing repo %q: %w", src, err) } - return remote.List(repo, o.remote...) + return remote.List(repo, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/manifest.go b/vendor/github.com/google/go-containerregistry/pkg/crane/manifest.go index 1c8ffa57ab..a54926aef3 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/manifest.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/manifest.go @@ -21,7 +21,7 @@ func Manifest(ref string, opt ...Option) ([]byte, error) { return nil, err } o := makeOptions(opt...) - if o.platform != nil { + if o.Platform != nil { img, err := desc.Image() if err != nil { return nil, err diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/optimize.go b/vendor/github.com/google/go-containerregistry/pkg/crane/optimize.go index 2e0ecdf364..74c665df7a 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/optimize.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/optimize.go @@ -34,33 +34,33 @@ import ( func Optimize(src, dst string, prioritize []string, opt ...Option) error { pset := newStringSet(prioritize) o := makeOptions(opt...) - srcRef, err := name.ParseReference(src, o.name...) + srcRef, err := name.ParseReference(src, o.Name...) if err != nil { - return fmt.Errorf("parsing reference %q: %v", src, err) + return fmt.Errorf("parsing reference %q: %w", src, err) } - dstRef, err := name.ParseReference(dst, o.name...) + dstRef, err := name.ParseReference(dst, o.Name...) if err != nil { - return fmt.Errorf("parsing reference for %q: %v", dst, err) + return fmt.Errorf("parsing reference for %q: %w", dst, err) } logs.Progress.Printf("Optimizing from %v to %v", srcRef, dstRef) - desc, err := remote.Get(srcRef, o.remote...) + desc, err := remote.Get(srcRef, o.Remote...) if err != nil { - return fmt.Errorf("fetching %q: %v", src, err) + return fmt.Errorf("fetching %q: %w", src, err) } switch desc.MediaType { case types.OCIImageIndex, types.DockerManifestList: // Handle indexes separately. - if o.platform != nil { + if o.Platform != nil { // If platform is explicitly set, don't optimize the whole index, just the appropriate image. if err := optimizeAndPushImage(desc, dstRef, pset, o); err != nil { - return fmt.Errorf("failed to optimize image: %v", err) + return fmt.Errorf("failed to optimize image: %w", err) } } else { if err := optimizeAndPushIndex(desc, dstRef, pset, o); err != nil { - return fmt.Errorf("failed to optimize index: %v", err) + return fmt.Errorf("failed to optimize index: %w", err) } } @@ -70,14 +70,14 @@ func Optimize(src, dst string, prioritize []string, opt ...Option) error { default: // Assume anything else is an image, since some registries don't set mediaTypes properly. if err := optimizeAndPushImage(desc, dstRef, pset, o); err != nil { - return fmt.Errorf("failed to optimize image: %v", err) + return fmt.Errorf("failed to optimize image: %w", err) } } return nil } -func optimizeAndPushImage(desc *remote.Descriptor, dstRef name.Reference, prioritize stringSet, o options) error { +func optimizeAndPushImage(desc *remote.Descriptor, dstRef name.Reference, prioritize stringSet, o Options) error { img, err := desc.Image() if err != nil { return err @@ -92,7 +92,7 @@ func optimizeAndPushImage(desc *remote.Descriptor, dstRef name.Reference, priori return fmt.Errorf("the following prioritized files were missing from image: %v", missing.List()) } - return remote.Write(dstRef, oimg, o.remote...) + return remote.Write(dstRef, oimg, o.Remote...) } func optimizeImage(img v1.Image, prioritize stringSet) (stringSet, v1.Image, error) { @@ -142,7 +142,7 @@ func optimizeImage(img v1.Image, prioritize stringSet) (stringSet, v1.Image, err return missingFromImage, oimg, nil } -func optimizeAndPushIndex(desc *remote.Descriptor, dstRef name.Reference, prioritize stringSet, o options) error { +func optimizeAndPushIndex(desc *remote.Descriptor, dstRef name.Reference, prioritize stringSet, o Options) error { idx, err := desc.ImageIndex() if err != nil { return err @@ -157,7 +157,7 @@ func optimizeAndPushIndex(desc *remote.Descriptor, dstRef name.Reference, priori return fmt.Errorf("the following prioritized files were missing from all images: %v", missing.List()) } - return remote.WriteIndex(dstRef, oidx, o.remote...) + return remote.WriteIndex(dstRef, oidx, o.Remote...) } func optimizeIndex(idx v1.ImageIndex, prioritize stringSet) (stringSet, v1.ImageIndex, error) { diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/options.go b/vendor/github.com/google/go-containerregistry/pkg/crane/options.go index 8ee117e6f7..6e1177e4df 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/options.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/options.go @@ -24,15 +24,24 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote" ) -type options struct { - name []name.Option - remote []remote.Option - platform *v1.Platform +// Options hold the options that crane uses when calling other packages. +type Options struct { + Name []name.Option + Remote []remote.Option + Platform *v1.Platform } -func makeOptions(opts ...Option) options { - opt := options{ - remote: []remote.Option{ +// GetOptions exposes the underlying []remote.Option, []name.Option, and +// platform, based on the passed Option. Generally, you shouldn't need to use +// this unless you've painted yourself into a dependency corner as we have +// with the crane and gcrane cli packages. +func GetOptions(opts ...Option) Options { + return makeOptions(opts...) +} + +func makeOptions(opts ...Option) Options { + opt := Options{ + Remote: []remote.Option{ remote.WithAuthFromKeychain(authn.DefaultKeychain), }, } @@ -43,28 +52,28 @@ func makeOptions(opts ...Option) options { } // Option is a functional option for crane. -type Option func(*options) +type Option func(*Options) // WithTransport is a functional option for overriding the default transport // for remote operations. func WithTransport(t http.RoundTripper) Option { - return func(o *options) { - o.remote = append(o.remote, remote.WithTransport(t)) + return func(o *Options) { + o.Remote = append(o.Remote, remote.WithTransport(t)) } } // Insecure is an Option that allows image references to be fetched without TLS. -func Insecure(o *options) { - o.name = append(o.name, name.Insecure) +func Insecure(o *Options) { + o.Name = append(o.Name, name.Insecure) } // WithPlatform is an Option to specify the platform. func WithPlatform(platform *v1.Platform) Option { - return func(o *options) { + return func(o *Options) { if platform != nil { - o.remote = append(o.remote, remote.WithPlatform(*platform)) + o.Remote = append(o.Remote, remote.WithPlatform(*platform)) } - o.platform = platform + o.Platform = platform } } @@ -74,9 +83,9 @@ func WithPlatform(platform *v1.Platform) Option { // // By default, crane will use authn.DefaultKeychain. func WithAuthFromKeychain(keys authn.Keychain) Option { - return func(o *options) { + return func(o *Options) { // Replace the default keychain at position 0. - o.remote[0] = remote.WithAuthFromKeychain(keys) + o.Remote[0] = remote.WithAuthFromKeychain(keys) } } @@ -85,23 +94,23 @@ func WithAuthFromKeychain(keys authn.Keychain) Option { // // By default, crane will use authn.DefaultKeychain. func WithAuth(auth authn.Authenticator) Option { - return func(o *options) { + return func(o *Options) { // Replace the default keychain at position 0. - o.remote[0] = remote.WithAuth(auth) + o.Remote[0] = remote.WithAuth(auth) } } // WithUserAgent adds the given string to the User-Agent header for any HTTP // requests. func WithUserAgent(ua string) Option { - return func(o *options) { - o.remote = append(o.remote, remote.WithUserAgent(ua)) + return func(o *Options) { + o.Remote = append(o.Remote, remote.WithUserAgent(ua)) } } // WithContext is a functional option for setting the context. func WithContext(ctx context.Context) Option { - return func(o *options) { - o.remote = append(o.remote, remote.WithContext(ctx)) + return func(o *Options) { + o.Remote = append(o.Remote, remote.WithContext(ctx)) } } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/pull.go b/vendor/github.com/google/go-containerregistry/pkg/crane/pull.go index 124cfbdb33..7e6e5b7b6e 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/pull.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/pull.go @@ -35,12 +35,12 @@ const iWasADigestTag = "i-was-a-digest" // Pull returns a v1.Image of the remote image src. func Pull(src string, opt ...Option) (v1.Image, error) { o := makeOptions(opt...) - ref, err := name.ParseReference(src, o.name...) + ref, err := name.ParseReference(src, o.Name...) if err != nil { - return nil, fmt.Errorf("parsing reference %q: %v", src, err) + return nil, fmt.Errorf("parsing reference %q: %w", src, err) } - return remote.Image(ref, o.remote...) + return remote.Image(ref, o.Remote...) } // Save writes the v1.Image img as a tarball at path with tag src. @@ -50,13 +50,14 @@ func Save(img v1.Image, src, path string) error { } // MultiSave writes collection of v1.Image img with tag as a tarball. -func MultiSave(imgMap map[string]v1.Image, path string) error { +func MultiSave(imgMap map[string]v1.Image, path string, opt ...Option) error { + o := makeOptions(opt...) tagToImage := map[name.Tag]v1.Image{} for src, img := range imgMap { - ref, err := name.ParseReference(src) + ref, err := name.ParseReference(src, o.Name...) if err != nil { - return fmt.Errorf("parsing ref %q: %v", src, err) + return fmt.Errorf("parsing ref %q: %w", src, err) } // WriteToFile wants a tag to write to the tarball, but we might have @@ -80,12 +81,12 @@ func MultiSave(imgMap map[string]v1.Image, path string) error { // PullLayer returns the given layer from a registry. func PullLayer(ref string, opt ...Option) (v1.Layer, error) { o := makeOptions(opt...) - digest, err := name.NewDigest(ref, o.name...) + digest, err := name.NewDigest(ref, o.Name...) if err != nil { return nil, err } - return remote.Layer(digest, o.remote...) + return remote.Layer(digest, o.Remote...) } // SaveLegacy writes the v1.Image img as a legacy tarball at path with tag src. @@ -101,7 +102,7 @@ func MultiSaveLegacy(imgMap map[string]v1.Image, path string) error { for src, img := range imgMap { ref, err := name.ParseReference(src) if err != nil { - return fmt.Errorf("parsing ref %q: %v", src, err) + return fmt.Errorf("parsing ref %q: %w", src, err) } refToImage[ref] = img } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/push.go b/vendor/github.com/google/go-containerregistry/pkg/crane/push.go index 65dee4f8a6..6d1fbd6cef 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/push.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/push.go @@ -36,9 +36,9 @@ func LoadTag(path, tag string, opt ...Option) (v1.Image, error) { } o := makeOptions(opt...) - t, err := name.NewTag(tag, o.name...) + t, err := name.NewTag(tag, o.Name...) if err != nil { - return nil, fmt.Errorf("parsing tag %q: %v", tag, err) + return nil, fmt.Errorf("parsing tag %q: %w", tag, err) } return tarball.ImageFromPath(path, &t) } @@ -46,9 +46,20 @@ func LoadTag(path, tag string, opt ...Option) (v1.Image, error) { // Push pushes the v1.Image img to a registry as dst. func Push(img v1.Image, dst string, opt ...Option) error { o := makeOptions(opt...) - tag, err := name.ParseReference(dst, o.name...) + tag, err := name.ParseReference(dst, o.Name...) if err != nil { - return fmt.Errorf("parsing reference %q: %v", dst, err) + return fmt.Errorf("parsing reference %q: %w", dst, err) } - return remote.Write(tag, img, o.remote...) + return remote.Write(tag, img, o.Remote...) +} + +// Upload pushes the v1.Layer to a given repo. +func Upload(layer v1.Layer, repo string, opt ...Option) error { + o := makeOptions(opt...) + ref, err := name.NewRepository(repo, o.Name...) + if err != nil { + return fmt.Errorf("parsing repo %q: %w", repo, err) + } + + return remote.WriteLayer(ref, layer, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/crane/tag.go b/vendor/github.com/google/go-containerregistry/pkg/crane/tag.go index d3e9abb31e..13bc395872 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/crane/tag.go +++ b/vendor/github.com/google/go-containerregistry/pkg/crane/tag.go @@ -24,16 +24,16 @@ import ( // Tag adds tag to the remote img. func Tag(img, tag string, opt ...Option) error { o := makeOptions(opt...) - ref, err := name.ParseReference(img, o.name...) + ref, err := name.ParseReference(img, o.Name...) if err != nil { - return fmt.Errorf("parsing reference %q: %v", img, err) + return fmt.Errorf("parsing reference %q: %w", img, err) } - desc, err := remote.Get(ref, o.remote...) + desc, err := remote.Get(ref, o.Remote...) if err != nil { - return fmt.Errorf("fetching %q: %v", img, err) + return fmt.Errorf("fetching %q: %w", img, err) } dst := ref.Context().Tag(tag) - return remote.Tag(dst, desc, o.remote...) + return remote.Tag(dst, desc, o.Remote...) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/legacy/tarball/write.go b/vendor/github.com/google/go-containerregistry/pkg/legacy/tarball/write.go index fb139544e3..77b5eabcd7 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/legacy/tarball/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/legacy/tarball/write.go @@ -57,7 +57,7 @@ func (l *v1Layer) version() []byte { func v1LayerID(layer v1.Layer, parentID string, rawConfig []byte) (string, error) { d, err := layer.Digest() if err != nil { - return "", fmt.Errorf("unable to get layer digest to generate v1 layer ID: %v", err) + return "", fmt.Errorf("unable to get layer digest to generate v1 layer ID: %w", err) } s := fmt.Sprintf("%s %s", d.Hex, parentID) if len(rawConfig) != 0 { @@ -75,7 +75,7 @@ func newV1Layer(layer v1.Layer, parent *v1Layer, history v1.History) (*v1Layer, } id, err := v1LayerID(layer, parentID, nil) if err != nil { - return nil, fmt.Errorf("unable to generate v1 layer ID: %v", err) + return nil, fmt.Errorf("unable to generate v1 layer ID: %w", err) } result := &v1Layer{ layer: layer, @@ -104,7 +104,7 @@ func newTopV1Layer(layer v1.Layer, parent *v1Layer, history v1.History, imgConfi } id, err := v1LayerID(layer, result.config.Parent, rawConfig) if err != nil { - return nil, fmt.Errorf("unable to generate v1 layer ID for top layer: %v", err) + return nil, fmt.Errorf("unable to generate v1 layer ID for top layer: %w", err) } result.config.ID = id result.config.Architecture = imgConfig.Architecture @@ -240,7 +240,7 @@ func MultiWrite(refToImage map[name.Reference]v1.Image, w io.Writer) error { var prev *v1Layer for i, l := range layers { if err := updateLayerSources(layerSources, l, img); err != nil { - return fmt.Errorf("unable to update image metadata to include undistributable layer source information: %v", err) + return fmt.Errorf("unable to update image metadata to include undistributable layer source information: %w", err) } var cur *v1Layer if i < (len(layers) - 1) { diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/check.go b/vendor/github.com/google/go-containerregistry/pkg/name/check.go index 01b03e5626..c15cc03b3c 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/check.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/check.go @@ -35,9 +35,9 @@ func stripRunesFn(runes string) func(rune) rune { func checkElement(name, element, allowedRunes string, minRunes, maxRunes int) error { numRunes := utf8.RuneCountInString(element) if (numRunes < minRunes) || (maxRunes < numRunes) { - return NewErrBadName("%s must be between %d and %d runes in length: %s", name, minRunes, maxRunes, element) + return newErrBadName("%s must be between %d and %d runes in length: %s", name, minRunes, maxRunes, element) } else if len(strings.Map(stripRunesFn(allowedRunes), element)) != 0 { - return NewErrBadName("%s can only contain the runes `%s`: %s", name, allowedRunes, element) + return newErrBadName("%s can only contain the runes `%s`: %s", name, allowedRunes, element) } return nil } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go index 120dd216ab..e465aef491 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go @@ -69,7 +69,7 @@ func NewDigest(name string, opts ...Option) (Digest, error) { // Split on "@" parts := strings.Split(name, digestDelim) if len(parts) != 2 { - return Digest{}, NewErrBadName("a digest must contain exactly one '@' separator (e.g. registry/repository@digest) saw: %s", name) + return Digest{}, newErrBadName("a digest must contain exactly one '@' separator (e.g. registry/repository@digest) saw: %s", name) } base := parts[0] digest := parts[1] diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/errors.go b/vendor/github.com/google/go-containerregistry/pkg/name/errors.go index 7847cc5d1e..035e350693 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/errors.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/errors.go @@ -14,7 +14,10 @@ package name -import "fmt" +import ( + "errors" + "fmt" +) // ErrBadName is an error for when a bad docker name is supplied. type ErrBadName struct { @@ -25,13 +28,15 @@ func (e *ErrBadName) Error() string { return e.info } -// NewErrBadName returns a ErrBadName which returns the given formatted string from Error(). -func NewErrBadName(fmtStr string, args ...interface{}) *ErrBadName { +// newErrBadName returns a ErrBadName which returns the given formatted string from Error(). +func newErrBadName(fmtStr string, args ...interface{}) *ErrBadName { return &ErrBadName{fmt.Sprintf(fmtStr, args...)} } // IsErrBadName returns true if the given error is an ErrBadName. +// +// Deprecated: Use errors.Is. func IsErrBadName(err error) bool { - _, ok := err.(*ErrBadName) - return ok + var berr *ErrBadName + return errors.As(err, &berr) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go index e5180b3d0a..955c59a7bb 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go @@ -44,8 +44,7 @@ func ParseReference(s string, opts ...Option) (Reference, error) { if d, err := NewDigest(s, opts...); err == nil { return d, nil } - return nil, NewErrBadName("could not parse reference: " + s) - + return nil, newErrBadName("could not parse reference: " + s) } type stringConst string diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go index d4da7409e8..2a26b66d04 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go @@ -98,7 +98,7 @@ func checkRegistry(name string) error { // Per RFC 3986, registries (authorities) are required to be prefixed with "//" // url.Host == hostname[:port] == authority if url, err := url.Parse("//" + name); err != nil || url.Host != name { - return NewErrBadName("registries must be valid RFC 3986 URI authorities: %s", name) + return newErrBadName("registries must be valid RFC 3986 URI authorities: %s", name) } return nil } @@ -108,7 +108,7 @@ func checkRegistry(name string) error { func NewRegistry(name string, opts ...Option) (Registry, error) { opt := makeOptions(opts...) if opt.strict && len(name) == 0 { - return Registry{}, NewErrBadName("strict validation requires the registry to be explicitly defined") + return Registry{}, newErrBadName("strict validation requires the registry to be explicitly defined") } if err := checkRegistry(name); err != nil { diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go index 54367a15cd..9250e36252 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go @@ -72,7 +72,7 @@ func checkRepository(repository string) error { func NewRepository(name string, opts ...Option) (Repository, error) { opt := makeOptions(opts...) if len(name) == 0 { - return Repository{}, NewErrBadName("a repository name must be specified") + return Repository{}, newErrBadName("a repository name must be specified") } var registry string @@ -95,7 +95,7 @@ func NewRepository(name string, opts ...Option) (Repository, error) { return Repository{}, err } if hasImplicitNamespace(repo, reg) && opt.strict { - return Repository{}, NewErrBadName("strict validation requires the full repository path (missing 'library')") + return Repository{}, newErrBadName("strict validation requires the full repository path (missing 'library')") } return Repository{reg, repo}, nil } diff --git a/vendor/github.com/google/go-containerregistry/pkg/registry/README.md b/vendor/github.com/google/go-containerregistry/pkg/registry/README.md new file mode 100644 index 0000000000..5e58bbcd5c --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/registry/README.md @@ -0,0 +1,14 @@ +# `pkg/registry` + +This package implements a Docker v2 registry and the OCI distribution specification. + +It is designed to be used anywhere a low dependency container registry is needed, with an initial focus on tests. + +Its goal is to be standards compliant and its strictness will increase over time. + +This is currently a low flightmiles system. It's likely quite safe to use in tests; If you're using it in production, please let us know how and send us PRs for integration tests. + +Before sending a PR, understand that the expectation of this package is that it remain free of extraneous dependencies. +This means that we expect `pkg/registry` to only have dependencies on Go's standard library, and other packages in `go-containerregistry`. + +You may be asked to change your code to reduce dependencies, and your PR might be rejected if this is deemed impossible. diff --git a/vendor/github.com/google/go-containerregistry/pkg/registry/blobs.go b/vendor/github.com/google/go-containerregistry/pkg/registry/blobs.go index 978ff48031..0672272712 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/registry/blobs.go +++ b/vendor/github.com/google/go-containerregistry/pkg/registry/blobs.go @@ -72,7 +72,8 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError { digest := req.URL.Query().Get("digest") contentRange := req.Header.Get("Content-Range") - if req.Method == "HEAD" { + switch req.Method { + case http.MethodHead: b.lock.Lock() defer b.lock.Unlock() b, ok := b.contents[target] @@ -88,9 +89,8 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError { resp.Header().Set("Docker-Content-Digest", target) resp.WriteHeader(http.StatusOK) return nil - } - if req.Method == "GET" { + case http.MethodGet: b.lock.Lock() defer b.lock.Unlock() b, ok := b.contents[target] @@ -107,65 +107,81 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError { resp.WriteHeader(http.StatusOK) io.Copy(resp, bytes.NewReader(b)) return nil - } - if req.Method == "POST" && target == "uploads" && digest != "" { - l := &bytes.Buffer{} - io.Copy(l, req.Body) - rd := sha256.Sum256(l.Bytes()) - d := "sha256:" + hex.EncodeToString(rd[:]) - if d != digest { + case http.MethodPost: + // It is weird that this is "target" instead of "service", but + // that's how the index math works out above. + if target != "uploads" { return ®Error{ Status: http.StatusBadRequest, - Code: "DIGEST_INVALID", - Message: "digest does not match contents", + Code: "METHOD_UNKNOWN", + Message: fmt.Sprintf("POST to /blobs must be followed by /uploads, got %s", target), } } - b.lock.Lock() - defer b.lock.Unlock() - b.contents[d] = l.Bytes() - resp.Header().Set("Docker-Content-Digest", d) - resp.WriteHeader(http.StatusCreated) - return nil - } + if digest != "" { + l := &bytes.Buffer{} + io.Copy(l, req.Body) + rd := sha256.Sum256(l.Bytes()) + d := "sha256:" + hex.EncodeToString(rd[:]) + if d != digest { + return ®Error{ + Status: http.StatusBadRequest, + Code: "DIGEST_INVALID", + Message: "digest does not match contents", + } + } + + b.lock.Lock() + defer b.lock.Unlock() + b.contents[d] = l.Bytes() + resp.Header().Set("Docker-Content-Digest", d) + resp.WriteHeader(http.StatusCreated) + return nil + } - if req.Method == "POST" && target == "uploads" && digest == "" { id := fmt.Sprint(rand.Int63()) resp.Header().Set("Location", "/"+path.Join("v2", path.Join(elem[1:len(elem)-2]...), "blobs/uploads", id)) resp.Header().Set("Range", "0-0") resp.WriteHeader(http.StatusAccepted) return nil - } - if req.Method == "PATCH" && service == "uploads" && contentRange != "" { - start, end := 0, 0 - if _, err := fmt.Sscanf(contentRange, "%d-%d", &start, &end); err != nil { + case http.MethodPatch: + if service != "uploads" { return ®Error{ - Status: http.StatusRequestedRangeNotSatisfiable, - Code: "BLOB_UPLOAD_UNKNOWN", - Message: "We don't understand your Content-Range", + Status: http.StatusBadRequest, + Code: "METHOD_UNKNOWN", + Message: fmt.Sprintf("PATCH to /blobs must be followed by /uploads, got %s", service), } } - b.lock.Lock() - defer b.lock.Unlock() - if start != len(b.uploads[target]) { - return ®Error{ - Status: http.StatusRequestedRangeNotSatisfiable, - Code: "BLOB_UPLOAD_UNKNOWN", - Message: "Your content range doesn't match what we have", + + if contentRange != "" { + start, end := 0, 0 + if _, err := fmt.Sscanf(contentRange, "%d-%d", &start, &end); err != nil { + return ®Error{ + Status: http.StatusRequestedRangeNotSatisfiable, + Code: "BLOB_UPLOAD_UNKNOWN", + Message: "We don't understand your Content-Range", + } + } + b.lock.Lock() + defer b.lock.Unlock() + if start != len(b.uploads[target]) { + return ®Error{ + Status: http.StatusRequestedRangeNotSatisfiable, + Code: "BLOB_UPLOAD_UNKNOWN", + Message: "Your content range doesn't match what we have", + } } + l := bytes.NewBuffer(b.uploads[target]) + io.Copy(l, req.Body) + b.uploads[target] = l.Bytes() + resp.Header().Set("Location", "/"+path.Join("v2", path.Join(elem[1:len(elem)-3]...), "blobs/uploads", target)) + resp.Header().Set("Range", fmt.Sprintf("0-%d", len(l.Bytes())-1)) + resp.WriteHeader(http.StatusNoContent) + return nil } - l := bytes.NewBuffer(b.uploads[target]) - io.Copy(l, req.Body) - b.uploads[target] = l.Bytes() - resp.Header().Set("Location", "/"+path.Join("v2", path.Join(elem[1:len(elem)-3]...), "blobs/uploads", target)) - resp.Header().Set("Range", fmt.Sprintf("0-%d", len(l.Bytes())-1)) - resp.WriteHeader(http.StatusNoContent) - return nil - } - if req.Method == "PATCH" && service == "uploads" && contentRange == "" { b.lock.Lock() defer b.lock.Unlock() if _, ok := b.uploads[target]; ok { @@ -184,17 +200,24 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError { resp.Header().Set("Range", fmt.Sprintf("0-%d", len(l.Bytes())-1)) resp.WriteHeader(http.StatusNoContent) return nil - } - if req.Method == "PUT" && service == "uploads" && digest == "" { - return ®Error{ - Status: http.StatusBadRequest, - Code: "DIGEST_INVALID", - Message: "digest not specified", + case http.MethodPut: + if service != "uploads" { + return ®Error{ + Status: http.StatusBadRequest, + Code: "METHOD_UNKNOWN", + Message: fmt.Sprintf("PUT to /blobs must be followed by /uploads, got %s", service), + } + } + + if digest == "" { + return ®Error{ + Status: http.StatusBadRequest, + Code: "DIGEST_INVALID", + Message: "digest not specified", + } } - } - if req.Method == "PUT" && service == "uploads" && digest != "" { b.lock.Lock() defer b.lock.Unlock() l := bytes.NewBuffer(b.uploads[target]) @@ -214,11 +237,12 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError { resp.Header().Set("Docker-Content-Digest", d) resp.WriteHeader(http.StatusCreated) return nil - } - return ®Error{ - Status: http.StatusBadRequest, - Code: "METHOD_UNKNOWN", - Message: "We don't understand your method + url", + default: + return ®Error{ + Status: http.StatusBadRequest, + Code: "METHOD_UNKNOWN", + Message: "We don't understand your method + url", + } } } diff --git a/vendor/github.com/google/go-containerregistry/pkg/registry/manifest.go b/vendor/github.com/google/go-containerregistry/pkg/registry/manifest.go index 5bb4fe8995..2a97239161 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/registry/manifest.go +++ b/vendor/github.com/google/go-containerregistry/pkg/registry/manifest.go @@ -89,7 +89,8 @@ func (m *manifests) handle(resp http.ResponseWriter, req *http.Request) *regErro target := elem[len(elem)-1] repo := strings.Join(elem[1:len(elem)-2], "/") - if req.Method == "GET" { + switch req.Method { + case http.MethodGet: m.lock.Lock() defer m.lock.Unlock() @@ -117,9 +118,8 @@ func (m *manifests) handle(resp http.ResponseWriter, req *http.Request) *regErro resp.WriteHeader(http.StatusOK) io.Copy(resp, bytes.NewReader(m.blob)) return nil - } - if req.Method == "HEAD" { + case http.MethodHead: m.lock.Lock() defer m.lock.Unlock() if _, ok := m.manifests[repo]; !ok { @@ -144,9 +144,8 @@ func (m *manifests) handle(resp http.ResponseWriter, req *http.Request) *regErro resp.Header().Set("Content-Length", fmt.Sprint(len(m.blob))) resp.WriteHeader(http.StatusOK) return nil - } - if req.Method == "PUT" { + case http.MethodPut: m.lock.Lock() defer m.lock.Unlock() if _, ok := m.manifests[repo]; !ok { @@ -200,9 +199,8 @@ func (m *manifests) handle(resp http.ResponseWriter, req *http.Request) *regErro resp.Header().Set("Docker-Content-Digest", digest) resp.WriteHeader(http.StatusCreated) return nil - } - if req.Method == "DELETE" { + case http.MethodDelete: m.lock.Lock() defer m.lock.Unlock() if _, ok := m.manifests[repo]; !ok { @@ -225,12 +223,13 @@ func (m *manifests) handle(resp http.ResponseWriter, req *http.Request) *regErro delete(m.manifests[repo], target) resp.WriteHeader(http.StatusAccepted) return nil - } - return ®Error{ - Status: http.StatusBadRequest, - Code: "METHOD_UNKNOWN", - Message: "We don't understand your method + url", + default: + return ®Error{ + Status: http.StatusBadRequest, + Code: "METHOD_UNKNOWN", + Message: "We don't understand your method + url", + } } } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/cache/cache.go b/vendor/github.com/google/go-containerregistry/pkg/v1/cache/cache.go index c4e752cecd..83040767d0 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/cache/cache.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/cache/cache.go @@ -1,3 +1,17 @@ +// Copyright 2021 Google LLC All Rights Reserved. +// +// 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 cache provides methods to cache layers. package cache @@ -55,9 +69,9 @@ func (i *image) Layers() ([]v1.Layer, error) { return nil, err } - var out []v1.Layer - for _, l := range ls { - out = append(out, &lazyLayer{inner: l, c: i.c}) + out := make([]v1.Layer, len(ls)) + for idx, l := range ls { + out[idx] = &lazyLayer{inner: l, c: i.c} } return out, nil } @@ -77,7 +91,7 @@ func (l *lazyLayer) Compressed() (io.ReadCloser, error) { // Layer found in the cache. logs.Progress.Printf("Layer %s found (compressed) in cache", digest) return cl.Compressed() - } else if err != ErrNotFound { + } else if !errors.Is(err, ErrNotFound) { return nil, err } @@ -99,7 +113,7 @@ func (l *lazyLayer) Uncompressed() (io.ReadCloser, error) { // Layer found in the cache. logs.Progress.Printf("Layer %s found (uncompressed) in cache", diffID) return cl.Uncompressed() - } else if err != ErrNotFound { + } else if !errors.Is(err, ErrNotFound) { return nil, err } @@ -119,7 +133,7 @@ func (l *lazyLayer) MediaType() (types.MediaType, error) { return l.inner.MediaT func (i *image) LayerByDigest(h v1.Hash) (v1.Layer, error) { l, err := i.c.Get(h) - if err == ErrNotFound { + if errors.Is(err, ErrNotFound) { // Not cached, get it and write it. l, err := i.Image.LayerByDigest(h) if err != nil { @@ -132,7 +146,7 @@ func (i *image) LayerByDigest(h v1.Hash) (v1.Layer, error) { func (i *image) LayerByDiffID(h v1.Hash) (v1.Layer, error) { l, err := i.c.Get(h) - if err == ErrNotFound { + if errors.Is(err, ErrNotFound) { // Not cached, get it and write it. l, err := i.Image.LayerByDiffID(h) if err != nil { diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/cache/fs.go b/vendor/github.com/google/go-containerregistry/pkg/v1/cache/fs.go index 07637104ca..75b826e3e4 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/cache/fs.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/cache/fs.go @@ -1,6 +1,21 @@ +// Copyright 2021 Google LLC All Rights Reserved. +// +// 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 cache import ( + "errors" "fmt" "io" "os" @@ -107,7 +122,7 @@ func (fs *fscache) Get(h v1.Hash) (v1.Layer, error) { if os.IsNotExist(err) { return nil, ErrNotFound } - if err == io.ErrUnexpectedEOF { + if errors.Is(err, io.ErrUnexpectedEOF) { // Delete and return ErrNotFound because the layer was incomplete. if err := fs.Delete(h); err != nil { return nil, err diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/cache/ro.go b/vendor/github.com/google/go-containerregistry/pkg/v1/cache/ro.go index 4d913c821a..028a612461 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/cache/ro.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/cache/ro.go @@ -1,3 +1,17 @@ +// Copyright 2021 Google LLC All Rights Reserved. +// +// 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 cache import v1 "github.com/google/go-containerregistry/pkg/v1" diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go index 5013c3d30d..c78000c8ac 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/image.go @@ -24,8 +24,18 @@ import ( "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/tarball" + "github.com/google/go-containerregistry/pkg/v1/types" ) +type image struct { + ref name.Reference + opener *imageOpener + tarballImage v1.Image + + once sync.Once + err error +} + type imageOpener struct { ref name.Reference ctx context.Context @@ -85,5 +95,96 @@ func Image(ref name.Reference, options ...Option) (v1.Image, error) { ctx: o.ctx, } - return tarball.Image(i.opener(), nil) + return &image{ + ref: ref, + opener: i, + }, nil +} + +func (i *image) initialize() error { + // Don't re-initialize tarball if already initialized. + if i.tarballImage == nil { + i.once.Do(func() { + i.tarballImage, i.err = tarball.Image(i.opener.opener(), nil) + }) + } + return i.err +} + +func (i *image) Layers() ([]v1.Layer, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.Layers() +} + +func (i *image) MediaType() (types.MediaType, error) { + if err := i.initialize(); err != nil { + return "", err + } + return i.tarballImage.MediaType() +} + +func (i *image) Size() (int64, error) { + if err := i.initialize(); err != nil { + return 0, err + } + return i.tarballImage.Size() +} + +func (i *image) ConfigName() (v1.Hash, error) { + res, _, err := i.opener.client.ImageInspectWithRaw(i.opener.ctx, i.ref.String()) + if err != nil { + return v1.Hash{}, err + } + return v1.NewHash(res.ID) +} + +func (i *image) ConfigFile() (*v1.ConfigFile, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.ConfigFile() +} + +func (i *image) RawConfigFile() ([]byte, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.RawConfigFile() +} + +func (i *image) Digest() (v1.Hash, error) { + if err := i.initialize(); err != nil { + return v1.Hash{}, err + } + return i.tarballImage.Digest() +} + +func (i *image) Manifest() (*v1.Manifest, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.Manifest() +} + +func (i *image) RawManifest() ([]byte, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.RawManifest() +} + +func (i *image) LayerByDigest(h v1.Hash) (v1.Layer, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.LayerByDigest(h) +} + +func (i *image) LayerByDiffID(h v1.Hash) (v1.Layer, error) { + if err := i.initialize(); err != nil { + return nil, err + } + return i.tarballImage.LayerByDiffID(h) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go index c3a0ac66b3..e8a5a1e5de 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/options.go @@ -99,4 +99,5 @@ type Client interface { ImageSave(context.Context, []string) (io.ReadCloser, error) ImageLoad(context.Context, io.Reader, bool) (types.ImageLoadResponse, error) ImageTag(context.Context, string, string) error + ImageInspectWithRaw(context.Context, string) (types.ImageInspect, []byte, error) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go index 5d400156fd..6264315c99 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go @@ -49,13 +49,13 @@ func Write(tag name.Tag, img v1.Image, options ...Option) (string, error) { // write the image in docker save format first, then load it resp, err := o.client.ImageLoad(o.ctx, pr, false) if err != nil { - return "", fmt.Errorf("error loading image: %v", err) + return "", fmt.Errorf("error loading image: %w", err) } defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) response := string(b) if err != nil { - return response, fmt.Errorf("error reading load response body: %v", err) + return response, fmt.Errorf("error reading load response body: %w", err) } return response, nil } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/layout/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/layout/image.go index c38ddd1168..c9ae9665c3 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/layout/image.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/layout/image.go @@ -93,17 +93,10 @@ func (li *layoutImage) LayerByDigest(h v1.Hash) (partial.CompressedLayer, error) for _, desc := range manifest.Layers { if h == desc.Digest { - switch desc.MediaType { - case types.OCILayer, types.DockerLayer: - return &compressedBlob{ - path: li.path, - desc: desc, - }, nil - default: - // TODO: We assume everything is a compressed blob, but that might not be true. - // TODO: Handle foreign layers. - return nil, fmt.Errorf("unexpected media type: %v for layer: %v", desc.MediaType, desc.Digest) - } + return &compressedBlob{ + path: li.path, + desc: desc, + }, nil } } @@ -131,6 +124,11 @@ func (b *compressedBlob) MediaType() (types.MediaType, error) { return b.desc.MediaType, nil } +// Descriptor implements partial.withDescriptor. +func (b *compressedBlob) Descriptor() (*v1.Descriptor, error) { + return &b.desc, nil +} + // See partial.Exists. func (b *compressedBlob) Exists() (bool, error) { _, err := os.Stat(b.path.blobPath(b.desc.Digest)) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/layout/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/layout/write.go index a9ff91f7a7..f912b124e0 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/layout/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/layout/write.go @@ -216,7 +216,6 @@ func (l Path) WriteFile(name string, data []byte, perm os.FileMode) error { } return ioutil.WriteFile(l.path(name), data, perm) - } // WriteBlob copies a file to the blobs/ directory in the Path from the given ReadCloser at @@ -410,7 +409,6 @@ func (l Path) WriteIndex(ii v1.ImageIndex) error { indexFile := filepath.Join("blobs", h.Algorithm, h.Hex) return l.writeIndexToFile(indexFile, ii) - } // Write constructs a Path at path from an ImageIndex. diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go index de284c36b6..834cee15fb 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go @@ -30,13 +30,14 @@ type image struct { base v1.Image adds []Addendum - computed bool - configFile *v1.ConfigFile - manifest *v1.Manifest - annotations map[string]string - mediaType *types.MediaType - diffIDMap map[v1.Hash]v1.Layer - digestMap map[v1.Hash]v1.Layer + computed bool + configFile *v1.ConfigFile + manifest *v1.Manifest + annotations map[string]string + mediaType *types.MediaType + configMediaType *types.MediaType + diffIDMap map[v1.Hash]v1.Layer + digestMap map[v1.Hash]v1.Layer } var _ v1.Image = (*image)(nil) @@ -135,6 +136,11 @@ func (i *image) compute() error { manifest.Config.Data = rcfg } + // If the user wants to mutate the media type of the config + if i.configMediaType != nil { + manifest.Config.MediaType = *i.configMediaType + } + // With OCI media types, this should not be set, see discussion: // https://github.com/opencontainers/image-spec/pull/795 if i.mediaType != nil { @@ -166,7 +172,7 @@ func (i *image) compute() error { // Layers returns the ordered collection of filesystem layers that comprise this image. // The order of the list is oldest/base layer first, and most-recent/top layer last. func (i *image) Layers() ([]v1.Layer, error) { - if err := i.compute(); err == stream.ErrNotComputed { + if err := i.compute(); errors.Is(err, stream.ErrNotComputed) { // Image contains a streamable layer which has not yet been // consumed. Just return the layers we have in case the caller // is going to consume the layers. @@ -210,7 +216,7 @@ func (i *image) ConfigFile() (*v1.ConfigFile, error) { if err := i.compute(); err != nil { return nil, err } - return i.configFile, nil + return i.configFile.DeepCopy(), nil } // RawConfigFile returns the serialized bytes of ConfigFile() @@ -242,7 +248,7 @@ func (i *image) Manifest() (*v1.Manifest, error) { if err := i.compute(); err != nil { return nil, err } - return i.manifest, nil + return i.manifest.DeepCopy(), nil } // RawManifest returns the serialized bytes of Manifest() diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go index e1f4937cd2..d9694b29e4 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go @@ -197,7 +197,7 @@ func (i *index) IndexManifest() (*v1.IndexManifest, error) { if err := i.compute(); err != nil { return nil, err } - return i.manifest, nil + return i.manifest.DeepCopy(), nil } // RawManifest returns the serialized bytes of Manifest() diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go index f94ad0b741..d88ecbfb76 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go @@ -18,6 +18,7 @@ import ( "archive/tar" "bytes" "encoding/json" + "errors" "fmt" "io" "io/ioutil" @@ -241,7 +242,7 @@ func extract(img v1.Image, w io.Writer) error { layers, err := img.Layers() if err != nil { - return fmt.Errorf("retrieving image layers: %v", err) + return fmt.Errorf("retrieving image layers: %w", err) } // we iterate through the layers in reverse order because it makes handling // whiteout layers more efficient, since we can just keep track of the removed @@ -250,19 +251,23 @@ func extract(img v1.Image, w io.Writer) error { layer := layers[i] layerReader, err := layer.Uncompressed() if err != nil { - return fmt.Errorf("reading layer contents: %v", err) + return fmt.Errorf("reading layer contents: %w", err) } defer layerReader.Close() tarReader := tar.NewReader(layerReader) for { header, err := tarReader.Next() - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if err != nil { - return fmt.Errorf("reading tar: %v", err) + return fmt.Errorf("reading tar: %w", err) } + // Some tools prepend everything with "./", so if we don't Clean the + // name, we may have duplicate entries, which angers tar-split. + header.Name = filepath.Clean(header.Name) + basename := filepath.Base(header.Name) dirname := filepath.Dir(header.Name) tombstone := strings.HasPrefix(basename, whiteoutPrefix) @@ -327,32 +332,32 @@ func Time(img v1.Image, t time.Time) (v1.Image, error) { layers, err := img.Layers() if err != nil { - return nil, fmt.Errorf("getting image layers: %v", err) + return nil, fmt.Errorf("getting image layers: %w", err) } // Strip away all timestamps from layers - var newLayers []v1.Layer - for _, layer := range layers { + newLayers := make([]v1.Layer, len(layers)) + for idx, layer := range layers { newLayer, err := layerTime(layer, t) if err != nil { - return nil, fmt.Errorf("setting layer times: %v", err) + return nil, fmt.Errorf("setting layer times: %w", err) } - newLayers = append(newLayers, newLayer) + newLayers[idx] = newLayer } newImage, err = AppendLayers(newImage, newLayers...) if err != nil { - return nil, fmt.Errorf("appending layers: %v", err) + return nil, fmt.Errorf("appending layers: %w", err) } ocf, err := img.ConfigFile() if err != nil { - return nil, fmt.Errorf("getting original config file: %v", err) + return nil, fmt.Errorf("getting original config file: %w", err) } cf, err := newImage.ConfigFile() if err != nil { - return nil, fmt.Errorf("setting config file: %v", err) + return nil, fmt.Errorf("setting config file: %w", err) } cfg := cf.DeepCopy() @@ -366,8 +371,13 @@ func Time(img v1.Image, t time.Time) (v1.Image, error) { // Strip away timestamps from the config file cfg.Created = v1.Time{Time: t} - for _, h := range cfg.History { + for i, h := range cfg.History { h.Created = v1.Time{Time: t} + h.CreatedBy = ocf.History[i].CreatedBy + h.Comment = ocf.History[i].Comment + h.EmptyLayer = ocf.History[i].EmptyLayer + // Explicitly ignore Author field; which hinders reproducibility + cfg.History[i] = h } return ConfigFile(newImage, cfg) @@ -376,7 +386,7 @@ func Time(img v1.Image, t time.Time) (v1.Image, error) { func layerTime(layer v1.Layer, t time.Time) (v1.Layer, error) { layerReader, err := layer.Uncompressed() if err != nil { - return nil, fmt.Errorf("getting layer: %v", err) + return nil, fmt.Errorf("getting layer: %w", err) } defer layerReader.Close() w := new(bytes.Buffer) @@ -386,21 +396,21 @@ func layerTime(layer v1.Layer, t time.Time) (v1.Layer, error) { tarReader := tar.NewReader(layerReader) for { header, err := tarReader.Next() - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if err != nil { - return nil, fmt.Errorf("reading layer: %v", err) + return nil, fmt.Errorf("reading layer: %w", err) } header.ModTime = t if err := tarWriter.WriteHeader(header); err != nil { - return nil, fmt.Errorf("writing tar header: %v", err) + return nil, fmt.Errorf("writing tar header: %w", err) } if header.Typeflag == tar.TypeReg { if _, err = io.Copy(tarWriter, tarReader); err != nil { - return nil, fmt.Errorf("writing layer file: %v", err) + return nil, fmt.Errorf("writing layer file: %w", err) } } } @@ -416,7 +426,7 @@ func layerTime(layer v1.Layer, t time.Time) (v1.Layer, error) { } layer, err = tarball.LayerFromOpener(opener) if err != nil { - return nil, fmt.Errorf("creating layer: %v", err) + return nil, fmt.Errorf("creating layer: %w", err) } return layer, nil @@ -455,6 +465,14 @@ func MediaType(img v1.Image, mt types.MediaType) v1.Image { } } +// ConfigMediaType modifies the MediaType() of the given image's Config. +func ConfigMediaType(img v1.Image, mt types.MediaType) v1.Image { + return &image{ + base: img, + configMediaType: &mt, + } +} + // IndexMediaType modifies the MediaType() of the given index. func IndexMediaType(idx v1.ImageIndex, mt types.MediaType) v1.ImageIndex { return &index{ diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go index a86a65243b..c606e0b76e 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go @@ -27,7 +27,7 @@ func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { // not based on oldBase at all. origLayers, err := orig.Layers() if err != nil { - return nil, fmt.Errorf("failed to get layers for original: %v", err) + return nil, fmt.Errorf("failed to get layers for original: %w", err) } oldBaseLayers, err := oldBase.Layers() if err != nil { @@ -39,11 +39,11 @@ func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { for i, l := range oldBaseLayers { oldLayerDigest, err := l.Digest() if err != nil { - return nil, fmt.Errorf("failed to get digest of layer %d of %q: %v", i, oldBase, err) + return nil, fmt.Errorf("failed to get digest of layer %d of %q: %w", i, oldBase, err) } origLayerDigest, err := origLayers[i].Digest() if err != nil { - return nil, fmt.Errorf("failed to get digest of layer %d of %q: %v", i, orig, err) + return nil, fmt.Errorf("failed to get digest of layer %d of %q: %w", i, orig, err) } if oldLayerDigest != origLayerDigest { return nil, fmt.Errorf("image %q is not based on %q (layer %d mismatch)", orig, oldBase, i) @@ -52,17 +52,17 @@ func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { oldConfig, err := oldBase.ConfigFile() if err != nil { - return nil, fmt.Errorf("failed to get config for old base: %v", err) + return nil, fmt.Errorf("failed to get config for old base: %w", err) } origConfig, err := orig.ConfigFile() if err != nil { - return nil, fmt.Errorf("failed to get config for original: %v", err) + return nil, fmt.Errorf("failed to get config for original: %w", err) } newConfig, err := newBase.ConfigFile() if err != nil { - return nil, fmt.Errorf("could not get config for new base: %v", err) + return nil, fmt.Errorf("could not get config for new base: %w", err) } // Stitch together an image that contains: @@ -72,13 +72,13 @@ func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { // - new base image's history + top of original image's history rebasedImage, err := Config(empty.Image, *origConfig.Config.DeepCopy()) if err != nil { - return nil, fmt.Errorf("failed to create empty image with original config: %v", err) + return nil, fmt.Errorf("failed to create empty image with original config: %w", err) } // Add new config properties from existing images. rebasedConfig, err := rebasedImage.ConfigFile() if err != nil { - return nil, fmt.Errorf("could not get config for rebased image: %v", err) + return nil, fmt.Errorf("could not get config for rebased image: %w", err) } // OS/Arch properties from new base rebasedConfig.Architecture = newConfig.Architecture @@ -88,24 +88,24 @@ func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { // Apply config properties to rebased. rebasedImage, err = ConfigFile(rebasedImage, rebasedConfig) if err != nil { - return nil, fmt.Errorf("failed to replace config for rebased image: %v", err) + return nil, fmt.Errorf("failed to replace config for rebased image: %w", err) } // Get new base layers and config for history. newBaseLayers, err := newBase.Layers() if err != nil { - return nil, fmt.Errorf("could not get new base layers for new base: %v", err) + return nil, fmt.Errorf("could not get new base layers for new base: %w", err) } // Add new base layers. rebasedImage, err = Append(rebasedImage, createAddendums(0, 0, newConfig.History, newBaseLayers)...) if err != nil { - return nil, fmt.Errorf("failed to append new base image: %v", err) + return nil, fmt.Errorf("failed to append new base image: %w", err) } // Add original layers above the old base. rebasedImage, err = Append(rebasedImage, createAddendums(len(oldConfig.History), len(oldBaseLayers)+1, origConfig.History, origLayers)...) if err != nil { - return nil, fmt.Errorf("failed to append original image: %v", err) + return nil, fmt.Errorf("failed to append original image: %w", err) } return rebasedImage, nil diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/README.md b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/README.md index c5710f9a0f..53ebbc6ccf 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/README.md +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/README.md @@ -29,7 +29,7 @@ In a tarball, blobs are (often) uncompressed, so it's easiest to implement a `v1 of uncompressed layers. `tarball.uncompressedImage` does this by implementing `UncompressedImageCore`: ```go -type CompressedImageCore interface { +type UncompressedImageCore interface { RawConfigFile() ([]byte, error) MediaType() (types.MediaType, error) LayerByDiffID(v1.Hash) (UncompressedLayer, error) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go index 9c7a92485b..f17f27446f 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go @@ -26,7 +26,7 @@ func FindManifests(index v1.ImageIndex, matcher match.Matcher) ([]v1.Descriptor, // get the actual manifest list indexManifest, err := index.IndexManifest() if err != nil { - return nil, fmt.Errorf("unable to get raw index: %v", err) + return nil, fmt.Errorf("unable to get raw index: %w", err) } manifests := []v1.Descriptor{} // try to get the root of our image diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/platform.go b/vendor/github.com/google/go-containerregistry/pkg/v1/platform.go index a586ab3675..b52f163bf4 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/platform.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/platform.go @@ -50,10 +50,9 @@ func stringSliceEqual(a, b []string) bool { // stringSliceEqualIgnoreOrder compares 2 string slices and returns if their contents are identical, ignoring order func stringSliceEqualIgnoreOrder(a, b []string) bool { - a1, b1 := a[:], b[:] - if a1 != nil && b1 != nil { - sort.Strings(a1) - sort.Strings(b1) + if a != nil && b != nil { + sort.Strings(a) + sort.Strings(b) } - return stringSliceEqual(a1, b1) + return stringSliceEqual(a, b) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go index 2f9ee11db7..eb4306f287 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go @@ -91,9 +91,10 @@ func Catalog(ctx context.Context, target name.Registry, options ...Option) ([]st Scheme: target.Scheme(), Host: target.RegistryStr(), Path: "/v2/_catalog", - // ECR returns an error if n > 1000: - // https://github.com/google/go-containerregistry/issues/1091 - RawQuery: "n=1000", + } + + if o.pageSize > 0 { + uri.RawQuery = fmt.Sprintf("n=%d", o.pageSize) } client := http.Client{Transport: tr} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/check.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/check.go index c841cc0580..25d86956f1 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/check.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/check.go @@ -20,13 +20,13 @@ import ( func CheckPushPermission(ref name.Reference, kc authn.Keychain, t http.RoundTripper) error { auth, err := kc.Resolve(ref.Context().Registry) if err != nil { - return fmt.Errorf("resolving authorization for %v failed: %v", ref.Context().Registry, err) + return fmt.Errorf("resolving authorization for %v failed: %w", ref.Context().Registry, err) } scopes := []string{ref.Scope(transport.PushScope)} tr, err := transport.New(ref.Context().Registry, auth, t, scopes) if err != nil { - return fmt.Errorf("creating push check transport for %v failed: %v", ref.Context().Registry, err) + return fmt.Errorf("creating push check transport for %v failed: %w", ref.Context().Registry, err) } // TODO(jasonhall): Against GCR, just doing the token handshake is // enough, but this doesn't extend to Dockerhub diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go index 7a542b38fd..9898579188 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go @@ -147,6 +147,40 @@ func (r *remoteIndex) Layer(h v1.Hash) (v1.Layer, error) { return nil, fmt.Errorf("layer not found: %s", h) } +// Experiment with a better API for v1.ImageIndex. We might want to move this +// to partial? +func (r *remoteIndex) Manifests() ([]partial.Describable, error) { + m, err := r.IndexManifest() + if err != nil { + return nil, err + } + manifests := []partial.Describable{} + for _, desc := range m.Manifests { + switch { + case desc.MediaType.IsImage(): + img, err := r.Image(desc.Digest) + if err != nil { + return nil, err + } + manifests = append(manifests, img) + case desc.MediaType.IsIndex(): + idx, err := r.ImageIndex(desc.Digest) + if err != nil { + return nil, err + } + manifests = append(manifests, idx) + default: + layer, err := r.Layer(desc.Digest) + if err != nil { + return nil, err + } + manifests = append(manifests, layer) + } + } + + return manifests, nil +} + func (r *remoteIndex) imageByPlatform(platform v1.Platform) (v1.Image, error) { desc, err := r.childByPlatform(platform) if err != nil { @@ -180,7 +214,7 @@ func (r *remoteIndex) childByPlatform(platform v1.Platform) (*Descriptor, error) return r.childDescriptor(childDesc, platform) } } - return nil, fmt.Errorf("no child with platform %s/%s in index %s", platform.OS, platform.Architecture, r.Ref) + return nil, fmt.Errorf("no child with platform %+v in index %s", platform, r.Ref) } func (r *remoteIndex) childByHash(h v1.Hash) (*Descriptor, error) { diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go index 433ccd1e70..e643c49aab 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go @@ -55,9 +55,10 @@ func List(repo name.Repository, options ...Option) ([]string, error) { Scheme: repo.Registry.Scheme(), Host: repo.Registry.RegistryStr(), Path: fmt.Sprintf("/v2/%s/tags/list", repo.RepositoryStr()), - // ECR returns an error if n > 1000: - // https://github.com/google/go-containerregistry/issues/681 - RawQuery: "n=1000", + } + + if o.pageSize > 0 { + uri.RawQuery = fmt.Sprintf("n=%d", o.pageSize) } client := http.Client{Transport: tr} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go index 45408fc4a1..7e41d94c43 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go @@ -15,6 +15,7 @@ package remote import ( + "context" "fmt" "net/http" @@ -91,12 +92,14 @@ func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { context: o.context, updates: o.updates, lastUpdate: &v1.Update{}, + backoff: o.retryBackoff, + predicate: o.retryPredicate, } // Collect the total size of blobs and manifests we're about to write. if o.updates != nil { defer close(o.updates) - defer func() { sendError(o.updates, rerr) }() + defer func() { _ = sendError(o.updates, rerr) }() for _, b := range blobs { size, err := b.Size() if err != nil { @@ -133,12 +136,13 @@ func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { // Upload individual blobs and collect any errors. blobChan := make(chan v1.Layer, 2*o.jobs) - g, ctx := errgroup.WithContext(o.context) + ctx := o.context + g, gctx := errgroup.WithContext(o.context) for i := 0; i < o.jobs; i++ { // Start N workers consuming blobs to upload. g.Go(func() error { for b := range blobChan { - if err := w.uploadOne(b); err != nil { + if err := w.uploadOne(gctx, b); err != nil { return err } } @@ -150,8 +154,8 @@ func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { for _, b := range blobs { select { case blobChan <- b: - case <-ctx.Done(): - return ctx.Err() + case <-gctx.Done(): + return gctx.Err() } } return nil @@ -160,7 +164,8 @@ func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { return err } - commitMany := func(m map[name.Reference]Taggable) error { + commitMany := func(ctx context.Context, m map[name.Reference]Taggable) error { + g, ctx := errgroup.WithContext(ctx) // With all of the constituent elements uploaded, upload the manifests // to commit the images and indexes, and collect any errors. type task struct { @@ -172,7 +177,7 @@ func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { // Start N workers consuming tasks to upload manifests. g.Go(func() error { for t := range taskChan { - if err := w.commitManifest(t.i, t.ref); err != nil { + if err := w.commitManifest(ctx, t.i, t.ref); err != nil { return err } } @@ -189,19 +194,19 @@ func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { } // Push originally requested image manifests. These have no // dependencies. - if err := commitMany(images); err != nil { + if err := commitMany(ctx, images); err != nil { return err } // Push new manifests from lowest levels up. for i := len(newManifests) - 1; i >= 0; i-- { - if err := commitMany(newManifests[i]); err != nil { + if err := commitMany(ctx, newManifests[i]); err != nil { return err } } // Push originally requested index manifests, which might depend on // newly discovered manifests. - return commitMany(indexes) + return commitMany(ctx, indexes) } // addIndexBlobs adds blobs to the set of blobs we intend to upload, and diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go index 7edebdf779..3ed1d7dd07 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go @@ -17,8 +17,13 @@ package remote import ( "context" "errors" + "io" + "net" "net/http" + "syscall" + "time" + "github.com/google/go-containerregistry/internal/retry" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/logs" v1 "github.com/google/go-containerregistry/pkg/v1" @@ -38,6 +43,9 @@ type options struct { userAgent string allowNondistributableArtifacts bool updates chan<- v1.Update + pageSize int + retryBackoff Backoff + retryPredicate retry.Predicate } var defaultPlatform = v1.Platform{ @@ -45,15 +53,63 @@ var defaultPlatform = v1.Platform{ OS: "linux", } -const defaultJobs = 4 +// Backoff is an alias of retry.Backoff to expose this configuration option to consumers of this lib +type Backoff = retry.Backoff + +var defaultRetryPredicate retry.Predicate = func(err error) bool { + // Various failure modes here, as we're often reading from and writing to + // the network. + if retry.IsTemporary(err) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE) { + logs.Warn.Printf("retrying %v", err) + return true + } + return false +} + +// Try this three times, waiting 1s after first failure, 3s after second. +var defaultRetryBackoff = Backoff{ + Duration: 1.0 * time.Second, + Factor: 3.0, + Jitter: 0.1, + Steps: 3, +} + +const ( + defaultJobs = 4 + + // ECR returns an error if n > 1000: + // https://github.com/google/go-containerregistry/issues/1091 + defaultPageSize = 1000 +) + +// DefaultTransport is based on http.DefaultTransport with modifications +// documented inline below. +var DefaultTransport = &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + // By default we wrap the transport in retries, so reduce the + // default dial timeout to 5s to avoid 5x 30s of connection + // timeouts when doing the "ping" on certain http registries. + Timeout: 5 * time.Second, + KeepAlive: 30 * time.Second, + }).DialContext, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, +} func makeOptions(target authn.Resource, opts ...Option) (*options, error) { o := &options{ - auth: authn.Anonymous, - transport: http.DefaultTransport, - platform: defaultPlatform, - context: context.Background(), - jobs: defaultJobs, + auth: authn.Anonymous, + transport: DefaultTransport, + platform: defaultPlatform, + context: context.Background(), + jobs: defaultJobs, + pageSize: defaultPageSize, + retryPredicate: defaultRetryPredicate, + retryBackoff: defaultRetryBackoff, } for _, option := range opts { @@ -70,19 +126,23 @@ func makeOptions(target authn.Resource, opts ...Option) (*options, error) { o.auth = auth } - // Wrap the transport in something that logs requests and responses. - // It's expensive to generate the dumps, so skip it if we're writing - // to nothing. - if logs.Enabled(logs.Debug) { - o.transport = transport.NewLogger(o.transport) - } + // transport.Wrapper is a signal that consumers are opt-ing into providing their own transport without any additional wrapping. + // This is to allow consumers full control over the transports logic, such as providing retry logic. + if _, ok := o.transport.(*transport.Wrapper); !ok { + // Wrap the transport in something that logs requests and responses. + // It's expensive to generate the dumps, so skip it if we're writing + // to nothing. + if logs.Enabled(logs.Debug) { + o.transport = transport.NewLogger(o.transport) + } - // Wrap the transport in something that can retry network flakes. - o.transport = transport.NewRetry(o.transport) + // Wrap the transport in something that can retry network flakes. + o.transport = transport.NewRetry(o.transport) - // Wrap this last to prevent transport.New from double-wrapping. - if o.userAgent != "" { - o.transport = transport.NewUserAgent(o.transport, o.userAgent) + // Wrap this last to prevent transport.New from double-wrapping. + if o.userAgent != "" { + o.transport = transport.NewUserAgent(o.transport, o.userAgent) + } } return o, nil @@ -90,8 +150,10 @@ func makeOptions(target authn.Resource, opts ...Option) (*options, error) { // WithTransport is a functional option for overriding the default transport // for remote operations. +// If transport.Wrapper is provided, this signals that the consumer does *not* want any further wrapping to occur. +// i.e. logging, retry and useragent // -// The default transport its http.DefaultTransport. +// The default transport is DefaultTransport. func WithTransport(t http.RoundTripper) Option { return func(o *options) error { o.transport = t @@ -193,3 +255,30 @@ func WithProgress(updates chan<- v1.Update) Option { return nil } } + +// WithPageSize sets the given size as the value of parameter 'n' in the request. +// +// To omit the `n` parameter entirely, use WithPageSize(0). +// The default value is 1000. +func WithPageSize(size int) Option { + return func(o *options) error { + o.pageSize = size + return nil + } +} + +// WithRetryBackoff sets the httpBackoff for retry HTTP operations. +func WithRetryBackoff(backoff Backoff) Option { + return func(o *options) error { + o.retryBackoff = backoff + return nil + } +} + +// WithRetryPredicate sets the predicate for retry HTTP operations. +func WithRetryPredicate(predicate retry.Predicate) Option { + return func(o *options) error { + o.retryPredicate = predicate + return nil + } +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/bearer.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/bearer.go index 49941bd896..37bbab21b7 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/bearer.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/bearer.go @@ -17,6 +17,7 @@ package transport import ( "context" "encoding/json" + "errors" "fmt" "io/ioutil" "net" @@ -139,7 +140,8 @@ func (bt *bearerTransport) refresh(ctx context.Context) error { // the Username should be set to , which indicates // we are using an oauth flow. content, err = bt.refreshOauth(ctx) - if terr, ok := err.(*Error); ok && terr.StatusCode == http.StatusNotFound { + var terr *Error + if errors.As(err, &terr) && terr.StatusCode == http.StatusNotFound { // Note: Not all token servers implement oauth2. // If the request to the endpoint returns 404 using the HTTP POST method, // refer to Token Documentation for using the HTTP GET method supported by all token servers. diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go index bb59d22e4d..2c57f1a31c 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go @@ -46,10 +46,10 @@ type Error struct { Errors []Diagnostic `json:"errors,omitempty"` // The http status code returned. StatusCode int + // The request that failed. + Request *http.Request // The raw body if we couldn't understand it. rawBody string - // The request that failed. - request *http.Request } // Check that Error implements error @@ -58,8 +58,8 @@ var _ error = (*Error)(nil) // Error implements error func (e *Error) Error() string { prefix := "" - if e.request != nil { - prefix = fmt.Sprintf("%s %s: ", e.request.Method, redactURL(e.request.URL)) + if e.Request != nil { + prefix = fmt.Sprintf("%s %s: ", e.Request.Method, redactURL(e.Request.URL)) } return prefix + e.responseErr() } @@ -68,7 +68,7 @@ func (e *Error) responseErr() string { switch len(e.Errors) { case 0: if len(e.rawBody) == 0 { - if e.request != nil && e.request.Method == http.MethodHead { + if e.Request != nil && e.Request.Method == http.MethodHead { return fmt.Sprintf("unexpected status code %d %s (HEAD responses have no body, use GET for details)", e.StatusCode, http.StatusText(e.StatusCode)) } return fmt.Sprintf("unexpected status code %d %s", e.StatusCode, http.StatusText(e.StatusCode)) @@ -154,12 +154,14 @@ const ( DeniedErrorCode ErrorCode = "DENIED" UnsupportedErrorCode ErrorCode = "UNSUPPORTED" TooManyRequestsErrorCode ErrorCode = "TOOMANYREQUESTS" + UnknownErrorCode ErrorCode = "UNKNOWN" ) // TODO: Include other error types. var temporaryErrorCodes = map[ErrorCode]struct{}{ BlobUploadInvalidErrorCode: {}, TooManyRequestsErrorCode: {}, + UnknownErrorCode: {}, } var temporaryStatusCodes = map[int]struct{}{ @@ -167,6 +169,7 @@ var temporaryStatusCodes = map[int]struct{}{ http.StatusInternalServerError: {}, http.StatusBadGateway: {}, http.StatusServiceUnavailable: {}, + http.StatusGatewayTimeout: {}, } // CheckError returns a structured error if the response status is not in codes. @@ -191,7 +194,7 @@ func CheckError(resp *http.Response, codes ...int) error { structuredError.rawBody = string(b) structuredError.StatusCode = resp.StatusCode - structuredError.request = resp.Request + structuredError.Request = resp.Request return structuredError } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/ping.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/ping.go index c25d1b248d..897aa703c9 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/ping.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/ping.go @@ -129,7 +129,6 @@ func ping(ctx context.Context, reg name.Registry, t http.RoundTripper) (*pingRes } func pickFromMultipleChallenges(challenges []authchallenge.Challenge) authchallenge.Challenge { - // It might happen there are multiple www-authenticate headers, e.g. `Negotiate` and `Basic`. // Picking simply the first one could result eventually in `unrecognized challenge` error, // that's why we're looping through the challenges in search for one that can be handled. diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go index 7f7d1e452e..0a45dc75b9 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go @@ -46,8 +46,11 @@ type options struct { predicate retry.Predicate } +// Backoff is an alias of retry.Backoff to expose this configuration option to consumers of this lib +type Backoff = retry.Backoff + // WithRetryBackoff sets the backoff for retry operations. -func WithRetryBackoff(backoff retry.Backoff) Option { +func WithRetryBackoff(backoff Backoff) Option { return func(o *options) { o.backoff = backoff } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/transport.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/transport.go index 5c35fc7c9b..ea40e3a4fb 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/transport.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/transport.go @@ -69,9 +69,9 @@ func NewWithContext(ctx context.Context, reg name.Registry, auth authn.Authentic switch pr.challenge.Canonical() { case anonymous: - return t, nil + return &Wrapper{t}, nil case basic: - return &basicTransport{inner: t, auth: auth, target: reg.RegistryStr()}, nil + return &Wrapper{&basicTransport{inner: t, auth: auth, target: reg.RegistryStr()}}, nil case bearer: // We require the realm, which tells us where to send our Basic auth to turn it into Bearer auth. realm, ok := pr.parameters["realm"] @@ -96,8 +96,19 @@ func NewWithContext(ctx context.Context, reg name.Registry, auth authn.Authentic if err := bt.refresh(ctx); err != nil { return nil, err } - return bt, nil + return &Wrapper{bt}, nil default: return nil, fmt.Errorf("unrecognized challenge: %s", pr.challenge) } } + +// Wrapper results in *not* wrapping supplied transport with additional logic such as retries, useragent and debug logging +// Consumers are opt-ing into providing their own transport without any additional wrapping. +type Wrapper struct { + inner http.RoundTripper +} + +// RoundTrip delegates to the inner RoundTripper +func (w *Wrapper) RoundTrip(in *http.Request) (*http.Response, error) { + return w.inner.RoundTrip(in) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go index 4e2ec35fdd..41b19fcae7 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go @@ -24,8 +24,6 @@ import ( "net/url" "strings" "sync/atomic" - "syscall" - "time" "github.com/google/go-containerregistry/internal/redact" "github.com/google/go-containerregistry/internal/retry" @@ -59,12 +57,12 @@ func Write(ref name.Reference, img v1.Image, options ...Option) (rerr error) { return err } defer close(o.updates) - defer func() { sendError(o.updates, rerr) }() + defer func() { _ = sendError(o.updates, rerr) }() } - return writeImage(ref, img, o, lastUpdate) + return writeImage(o.context, ref, img, o, lastUpdate) } -func writeImage(ref name.Reference, img v1.Image, o *options, lastUpdate *v1.Update) error { +func writeImage(ctx context.Context, ref name.Reference, img v1.Image, o *options, lastUpdate *v1.Update) error { ls, err := img.Layers() if err != nil { return err @@ -77,19 +75,21 @@ func writeImage(ref name.Reference, img v1.Image, o *options, lastUpdate *v1.Upd w := writer{ repo: ref.Context(), client: &http.Client{Transport: tr}, - context: o.context, + context: ctx, updates: o.updates, lastUpdate: lastUpdate, + backoff: o.retryBackoff, + predicate: o.retryPredicate, } // Upload individual blobs and collect any errors. blobChan := make(chan v1.Layer, 2*o.jobs) - g, ctx := errgroup.WithContext(o.context) + g, gctx := errgroup.WithContext(ctx) for i := 0; i < o.jobs; i++ { // Start N workers consuming blobs to upload. g.Go(func() error { for b := range blobChan { - if err := w.uploadOne(b); err != nil { + if err := w.uploadOne(gctx, b); err != nil { return err } } @@ -128,15 +128,12 @@ func writeImage(ref name.Reference, img v1.Image, o *options, lastUpdate *v1.Upd } select { case blobChan <- l: - case <-ctx.Done(): - return ctx.Err() + case <-gctx.Done(): + return gctx.Err() } } return nil }) - if err := g.Wait(); err != nil { - return err - } if l, err := partial.ConfigLayer(img); err != nil { // We can't read the ConfigLayer, possibly because of streaming layers, @@ -151,13 +148,13 @@ func writeImage(ref name.Reference, img v1.Image, o *options, lastUpdate *v1.Upd if err != nil { return err } - if err := w.uploadOne(l); err != nil { + if err := w.uploadOne(ctx, l); err != nil { return err } } else { // We *can* read the ConfigLayer, so upload it concurrently with the layers. g.Go(func() error { - return w.uploadOne(l) + return w.uploadOne(gctx, l) }) // Wait for the layers + config. @@ -168,7 +165,7 @@ func writeImage(ref name.Reference, img v1.Image, o *options, lastUpdate *v1.Upd // With all of the constituent elements uploaded, upload the manifest // to commit the image. - return w.commitManifest(img, ref) + return w.commitManifest(ctx, img, ref) } // writer writes the elements of an image to a remote image reference. @@ -179,6 +176,8 @@ type writer struct { updates chan<- v1.Update lastUpdate *v1.Update + backoff Backoff + predicate retry.Predicate } func sendError(ch chan<- v1.Update, err error) error { @@ -405,30 +404,12 @@ func (w *writer) incrProgress(written int64) { } w.updates <- v1.Update{ Total: w.lastUpdate.Total, - Complete: atomic.AddInt64(&w.lastUpdate.Complete, int64(written)), + Complete: atomic.AddInt64(&w.lastUpdate.Complete, written), } } -var shouldRetry retry.Predicate = func(err error) bool { - // Various failure modes here, as we're often reading from and writing to - // the network. - if retry.IsTemporary(err) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE) { - logs.Warn.Printf("retrying %v", err) - return true - } - return false -} - -// Try this three times, waiting 1s after first failure, 3s after second. -var backoff = retry.Backoff{ - Duration: 1.0 * time.Second, - Factor: 3.0, - Jitter: 0.1, - Steps: 3, -} - // uploadOne performs a complete upload of a single layer. -func (w *writer) uploadOne(l v1.Layer) error { +func (w *writer) uploadOne(ctx context.Context, l v1.Layer) error { var from, mount string if h, err := l.Digest(); err == nil { // If we know the digest, this isn't a streaming layer. Do an existence @@ -455,8 +436,6 @@ func (w *writer) uploadOne(l v1.Layer) error { } } - ctx := w.context - tryUpload := func() error { location, mounted, err := w.initiateUpload(from, mount) if err != nil { @@ -508,14 +487,14 @@ func (w *writer) uploadOne(l v1.Layer) error { return nil } - return retry.Retry(tryUpload, shouldRetry, backoff) + return retry.Retry(tryUpload, w.predicate, w.backoff) } type withLayer interface { Layer(v1.Hash) (v1.Layer, error) } -func (w *writer) writeIndex(ref name.Reference, ii v1.ImageIndex, options ...Option) error { +func (w *writer) writeIndex(ctx context.Context, ref name.Reference, ii v1.ImageIndex, options ...Option) error { index, err := ii.IndexManifest() if err != nil { return err @@ -544,7 +523,7 @@ func (w *writer) writeIndex(ref name.Reference, ii v1.ImageIndex, options ...Opt if err != nil { return err } - if err := w.writeIndex(ref, ii); err != nil { + if err := w.writeIndex(ctx, ref, ii, options...); err != nil { return err } case types.OCIManifestSchema1, types.DockerManifestSchema2: @@ -552,7 +531,7 @@ func (w *writer) writeIndex(ref name.Reference, ii v1.ImageIndex, options ...Opt if err != nil { return err } - if err := writeImage(ref, img, o, w.lastUpdate); err != nil { + if err := writeImage(ctx, ref, img, o, w.lastUpdate); err != nil { return err } default: @@ -562,7 +541,7 @@ func (w *writer) writeIndex(ref name.Reference, ii v1.ImageIndex, options ...Opt if err != nil { return err } - if err := w.uploadOne(layer); err != nil { + if err := w.uploadOne(ctx, layer); err != nil { return err } } @@ -571,7 +550,7 @@ func (w *writer) writeIndex(ref name.Reference, ii v1.ImageIndex, options ...Opt // With all of the constituent elements uploaded, upload the manifest // to commit the image. - return w.commitManifest(ii, ref) + return w.commitManifest(ctx, ii, ref) } type withMediaType interface { @@ -617,7 +596,7 @@ func unpackTaggable(t Taggable) ([]byte, *v1.Descriptor, error) { } // commitManifest does a PUT of the image's manifest. -func (w *writer) commitManifest(t Taggable, ref name.Reference) error { +func (w *writer) commitManifest(ctx context.Context, t Taggable, ref name.Reference) error { tryUpload := func() error { raw, desc, err := unpackTaggable(t) if err != nil { @@ -633,7 +612,7 @@ func (w *writer) commitManifest(t Taggable, ref name.Reference) error { } req.Header.Set("Content-Type", string(desc.MediaType)) - resp, err := w.client.Do(req.WithContext(w.context)) + resp, err := w.client.Do(req.WithContext(ctx)) if err != nil { return err } @@ -649,7 +628,7 @@ func (w *writer) commitManifest(t Taggable, ref name.Reference) error { return nil } - return retry.Retry(tryUpload, shouldRetry, backoff) + return retry.Retry(tryUpload, w.predicate, w.backoff) } func scopesForUploadingImage(repo name.Repository, layers []v1.Layer) []string { @@ -692,10 +671,12 @@ func WriteIndex(ref name.Reference, ii v1.ImageIndex, options ...Option) (rerr e return err } w := writer{ - repo: ref.Context(), - client: &http.Client{Transport: tr}, - context: o.context, - updates: o.updates, + repo: ref.Context(), + client: &http.Client{Transport: tr}, + context: o.context, + updates: o.updates, + backoff: o.retryBackoff, + predicate: o.retryPredicate, } if o.updates != nil { @@ -708,7 +689,7 @@ func WriteIndex(ref name.Reference, ii v1.ImageIndex, options ...Option) (rerr e defer func() { sendError(o.updates, rerr) }() } - return w.writeIndex(ref, ii, options...) + return w.writeIndex(o.context, ref, ii, options...) } // countImage counts the total size of all layers + config blob + manifest for @@ -831,10 +812,12 @@ func WriteLayer(repo name.Repository, layer v1.Layer, options ...Option) (rerr e return err } w := writer{ - repo: repo, - client: &http.Client{Transport: tr}, - context: o.context, - updates: o.updates, + repo: repo, + client: &http.Client{Transport: tr}, + context: o.context, + updates: o.updates, + backoff: o.retryBackoff, + predicate: o.retryPredicate, } if o.updates != nil { @@ -851,7 +834,7 @@ func WriteLayer(repo name.Repository, layer v1.Layer, options ...Option) (rerr e } w.lastUpdate = &v1.Update{Total: size} } - return w.uploadOne(layer) + return w.uploadOne(o.context, layer) } // Tag adds a tag to the given Taggable via PUT /v2/.../manifests/ @@ -898,10 +881,12 @@ func Put(ref name.Reference, t Taggable, options ...Option) error { return err } w := writer{ - repo: ref.Context(), - client: &http.Client{Transport: tr}, - context: o.context, + repo: ref.Context(), + client: &http.Client{Transport: tr}, + context: o.context, + backoff: o.retryBackoff, + predicate: o.retryPredicate, } - return w.commitManifest(t, ref) + return w.commitManifest(o.context, t, ref) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go index 997e91cfab..564a5ef765 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go @@ -227,7 +227,7 @@ func extractFileFromTar(opener Opener, filePath string) (io.ReadCloser, error) { tf := tar.NewReader(f) for { hdr, err := tf.Next() - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if err != nil { diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go index f9298158e3..add390df88 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go @@ -98,7 +98,7 @@ func MultiRefWrite(refToImage map[name.Reference]v1.Image, w io.Writer, opts ... } } - size, _, mBytes, err := getSizeAndManifest(refToImage) + size, mBytes, err := getSizeAndManifest(refToImage) if err != nil { return sendUpdateReturn(o, err) } @@ -290,25 +290,25 @@ func calculateManifest(refToImage map[name.Reference]v1.Image) (m Manifest, err // CalculateSize calculates the expected complete size of the output tar file func CalculateSize(refToImage map[name.Reference]v1.Image) (size int64, err error) { - size, _, _, err = getSizeAndManifest(refToImage) + size, _, err = getSizeAndManifest(refToImage) return size, err } -func getSizeAndManifest(refToImage map[name.Reference]v1.Image) (size int64, m Manifest, mBytes []byte, err error) { - m, err = calculateManifest(refToImage) +func getSizeAndManifest(refToImage map[name.Reference]v1.Image) (int64, []byte, error) { + m, err := calculateManifest(refToImage) if err != nil { - return 0, nil, nil, fmt.Errorf("unable to calculate manifest: %v", err) + return 0, nil, fmt.Errorf("unable to calculate manifest: %w", err) } - mBytes, err = json.Marshal(m) + mBytes, err := json.Marshal(m) if err != nil { - return 0, nil, nil, fmt.Errorf("could not marshall manifest to bytes: %v", err) + return 0, nil, fmt.Errorf("could not marshall manifest to bytes: %w", err) } - size, err = calculateTarballSize(refToImage, mBytes) + size, err := calculateTarballSize(refToImage, mBytes) if err != nil { - return 0, nil, nil, fmt.Errorf("error calculating tarball size: %v", err) + return 0, nil, fmt.Errorf("error calculating tarball size: %w", err) } - return size, m, mBytes, nil + return size, mBytes, nil } // calculateTarballSize calculates the size of the tar file @@ -318,7 +318,7 @@ func calculateTarballSize(refToImage map[name.Reference]v1.Image, mBytes []byte) for img, name := range imageToTags { manifest, err := img.Manifest() if err != nil { - return size, fmt.Errorf("unable to get manifest for img %s: %v", name, err) + return size, fmt.Errorf("unable to get manifest for img %s: %w", name, err) } size += calculateSingleFileInTarSize(manifest.Config.Size) for _, l := range manifest.Layers { @@ -354,10 +354,8 @@ func dedupRefToImage(refToImage map[name.Reference]v1.Image) map[v1.Image][]stri ts = fmt.Sprintf("%s:%s", ts, name.DefaultTag) } imageToTags[img] = append(imageToTags[img], ts) - } else { - if _, ok := imageToTags[img]; !ok { - imageToTags[img] = nil - } + } else if _, ok := imageToTags[img]; !ok { + imageToTags[img] = nil } } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/validate/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/validate/index.go index 13e1e2af2b..7514dc48a0 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/validate/index.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/validate/index.go @@ -84,7 +84,7 @@ func validateChildren(idx v1.ImageIndex, opt ...Option) error { if wl, ok := idx.(withLayer); ok { layer, err := wl.Layer(desc.Digest) if err != nil { - return fmt.Errorf("failed to get layer Manifests[%d]: %v", i, err) + return fmt.Errorf("failed to get layer Manifests[%d]: %w", i, err) } if err := Layer(layer, opt...); err != nil { lerr := fmt.Sprintf("failed to validate layer Manifests[%d](%s): %v", i, desc.Digest, err) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/validate/layer.go b/vendor/github.com/google/go-containerregistry/pkg/v1/validate/layer.go index 9acbfc27f5..639e7b3eb5 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/validate/layer.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/validate/layer.go @@ -141,7 +141,7 @@ func computeLayer(layer v1.Layer) (*computedLayer, error) { files := make(map[string]struct{}) for { hdr, err := tarReader.Next() - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if err != nil { diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/zz_deepcopy_generated.go b/vendor/github.com/google/go-containerregistry/pkg/v1/zz_deepcopy_generated.go index b32b8b77a1..0cb1586f1e 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/zz_deepcopy_generated.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/zz_deepcopy_generated.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright 2018 Google LLC All Rights Reserved. diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_linux.go b/vendor/golang.org/x/sys/unix/sockcmsg_linux.go index 8bf4570594..5f63147e06 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_linux.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_linux.go @@ -34,3 +34,52 @@ func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) return &ucred, nil } + +// PktInfo4 encodes Inet4Pktinfo into a socket control message of type IP_PKTINFO. +func PktInfo4(info *Inet4Pktinfo) []byte { + b := make([]byte, CmsgSpace(SizeofInet4Pktinfo)) + h := (*Cmsghdr)(unsafe.Pointer(&b[0])) + h.Level = SOL_IP + h.Type = IP_PKTINFO + h.SetLen(CmsgLen(SizeofInet4Pktinfo)) + *(*Inet4Pktinfo)(h.data(0)) = *info + return b +} + +// PktInfo6 encodes Inet6Pktinfo into a socket control message of type IPV6_PKTINFO. +func PktInfo6(info *Inet6Pktinfo) []byte { + b := make([]byte, CmsgSpace(SizeofInet6Pktinfo)) + h := (*Cmsghdr)(unsafe.Pointer(&b[0])) + h.Level = SOL_IPV6 + h.Type = IPV6_PKTINFO + h.SetLen(CmsgLen(SizeofInet6Pktinfo)) + *(*Inet6Pktinfo)(h.data(0)) = *info + return b +} + +// ParseOrigDstAddr decodes a socket control message containing the original +// destination address. To receive such a message the IP_RECVORIGDSTADDR or +// IPV6_RECVORIGDSTADDR option must be enabled on the socket. +func ParseOrigDstAddr(m *SocketControlMessage) (Sockaddr, error) { + switch { + case m.Header.Level == SOL_IP && m.Header.Type == IP_ORIGDSTADDR: + pp := (*RawSockaddrInet4)(unsafe.Pointer(&m.Data[0])) + sa := new(SockaddrInet4) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.Addr = pp.Addr + return sa, nil + + case m.Header.Level == SOL_IPV6 && m.Header.Type == IPV6_ORIGDSTADDR: + pp := (*RawSockaddrInet6)(unsafe.Pointer(&m.Data[0])) + sa := new(SockaddrInet6) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.ZoneId = pp.Scope_id + sa.Addr = pp.Addr + return sa, nil + + default: + return nil, EINVAL + } +} diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index d8efb715ff..6192750ce3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -70,9 +70,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -85,9 +83,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -261,9 +257,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -272,9 +266,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT @@ -385,6 +377,11 @@ func (w WaitStatus) TrapCause() int { return -1 } //sys fcntl(fd int, cmd int, arg int) (val int, err error) +//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range +func Fsync(fd int) error { + return fsyncRange(fd, O_SYNC, 0, 0) +} + /* * Direct access */ @@ -401,7 +398,6 @@ func (w WaitStatus) TrapCause() int { return -1 } //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Fdatasync(fd int) (err error) -//sys Fsync(fd int) (err error) // readdir_r //sysnb Getpgid(pid int) (pgid int, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index 95ac3946b5..0ce4523261 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -163,9 +163,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -179,9 +177,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -210,9 +206,7 @@ func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Nlen = sa.Nlen sa.raw.Alen = sa.Alen sa.raw.Slen = sa.Slen - for i := 0; i < len(sa.raw.Data); i++ { - sa.raw.Data[i] = sa.Data[i] - } + sa.raw.Data = sa.Data return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil } @@ -228,9 +222,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa.Nlen = pp.Nlen sa.Alen = pp.Alen sa.Slen = pp.Slen - for i := 0; i < len(sa.Data); i++ { - sa.Data[i] = pp.Data[i] - } + sa.Data = pp.Data return sa, nil case AF_UNIX: @@ -262,9 +254,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -273,9 +263,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return anyToSockaddrGOOS(fd, rsa) diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index a8c13317d7..8826f41435 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -430,8 +430,25 @@ func GetsockoptXucred(fd, level, opt int) (*Xucred, error) { return x, err } -func SysctlKinfoProcSlice(name string) ([]KinfoProc, error) { - mib, err := sysctlmib(name) +func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return nil, err + } + + var kinfo KinfoProc + n := uintptr(SizeofKinfoProc) + if err := sysctl(mib, (*byte)(unsafe.Pointer(&kinfo)), &n, nil, 0); err != nil { + return nil, err + } + if n != SizeofKinfoProc { + return nil, EIO + } + return &kinfo, nil +} + +func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { + mib, err := sysctlmib(name, args...) if err != nil { return nil, err } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index fff38a84c9..bc9dc2e10a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -372,9 +372,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -387,9 +385,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -438,9 +434,7 @@ func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Hatype = sa.Hatype sa.raw.Pkttype = sa.Pkttype sa.raw.Halen = sa.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil } @@ -855,12 +849,10 @@ func (sa *SockaddrTIPC) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Addr == nil { return nil, 0, EINVAL } - sa.raw.Family = AF_TIPC sa.raw.Scope = int8(sa.Scope) sa.raw.Addrtype = sa.Addr.tipcAddrtype() sa.raw.Addr = sa.Addr.tipcAddr() - return unsafe.Pointer(&sa.raw), SizeofSockaddrTIPC, nil } @@ -874,9 +866,7 @@ type SockaddrL2TPIP struct { func (sa *SockaddrL2TPIP) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Family = AF_INET sa.raw.Conn_id = sa.ConnId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrL2TPIP, nil } @@ -892,9 +882,7 @@ func (sa *SockaddrL2TPIP6) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Family = AF_INET6 sa.raw.Conn_id = sa.ConnId sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrL2TPIP6, nil } @@ -990,9 +978,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa.Hatype = pp.Hatype sa.Pkttype = pp.Pkttype sa.Halen = pp.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_UNIX: @@ -1031,18 +1017,14 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { pp := (*RawSockaddrL2TPIP)(unsafe.Pointer(rsa)) sa := new(SockaddrL2TPIP) sa.ConnId = pp.Conn_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil default: pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } @@ -1058,9 +1040,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrL2TPIP6) sa.ConnId = pp.Conn_id sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil default: pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) @@ -1068,9 +1048,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index d2a6495c7e..8b88ac2133 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -92,9 +92,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -107,9 +105,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -417,9 +413,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -428,9 +422,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index 1ffd8bfcfb..5fb76a1468 100644 --- a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -67,9 +67,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -83,9 +81,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -144,9 +140,7 @@ func anyToSockaddr(_ int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -155,9 +149,7 @@ func anyToSockaddr(_ int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 78d4b85ece..3bbc527519 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -116,6 +116,7 @@ const ( ARPHRD_LAPB = 0x204 ARPHRD_LOCALTLK = 0x305 ARPHRD_LOOPBACK = 0x304 + ARPHRD_MCTP = 0x122 ARPHRD_METRICOM = 0x17 ARPHRD_NETLINK = 0x338 ARPHRD_NETROM = 0x0 @@ -472,6 +473,7 @@ const ( DM_DEV_WAIT = 0xc138fd08 DM_DIR = "mapper" DM_GET_TARGET_VERSION = 0xc138fd11 + DM_IMA_MEASUREMENT_FLAG = 0x80000 DM_INACTIVE_PRESENT_FLAG = 0x40 DM_INTERNAL_SUSPEND_FLAG = 0x40000 DM_IOCTL = 0xfd @@ -716,6 +718,7 @@ const ( ETH_P_LOOPBACK = 0x9000 ETH_P_MACSEC = 0x88e5 ETH_P_MAP = 0xf9 + ETH_P_MCTP = 0xfa ETH_P_MOBITEX = 0x15 ETH_P_MPLS_MC = 0x8848 ETH_P_MPLS_UC = 0x8847 @@ -751,6 +754,21 @@ const ( ETH_P_WCCP = 0x883e ETH_P_X25 = 0x805 ETH_P_XDSA = 0xf8 + EV_ABS = 0x3 + EV_CNT = 0x20 + EV_FF = 0x15 + EV_FF_STATUS = 0x17 + EV_KEY = 0x1 + EV_LED = 0x11 + EV_MAX = 0x1f + EV_MSC = 0x4 + EV_PWR = 0x16 + EV_REL = 0x2 + EV_REP = 0x14 + EV_SND = 0x12 + EV_SW = 0x5 + EV_SYN = 0x0 + EV_VERSION = 0x10001 EXABYTE_ENABLE_NEST = 0xf0 EXT2_SUPER_MAGIC = 0xef53 EXT3_SUPER_MAGIC = 0xef53 @@ -789,9 +807,11 @@ const ( FAN_DELETE_SELF = 0x400 FAN_DENY = 0x2 FAN_ENABLE_AUDIT = 0x40 + FAN_EPIDFD = -0x2 FAN_EVENT_INFO_TYPE_DFID = 0x3 FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 FAN_EVENT_INFO_TYPE_FID = 0x1 + FAN_EVENT_INFO_TYPE_PIDFD = 0x4 FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_ON_CHILD = 0x8000000 FAN_MARK_ADD = 0x1 @@ -811,6 +831,7 @@ const ( FAN_MOVE_SELF = 0x800 FAN_NOFD = -0x1 FAN_NONBLOCK = 0x2 + FAN_NOPIDFD = -0x1 FAN_ONDIR = 0x40000000 FAN_OPEN = 0x20 FAN_OPEN_EXEC = 0x1000 @@ -821,6 +842,7 @@ const ( FAN_REPORT_DIR_FID = 0x400 FAN_REPORT_FID = 0x200 FAN_REPORT_NAME = 0x800 + FAN_REPORT_PIDFD = 0x80 FAN_REPORT_TID = 0x100 FAN_UNLIMITED_MARKS = 0x20 FAN_UNLIMITED_QUEUE = 0x10 @@ -1997,6 +2019,7 @@ const ( PR_SPEC_ENABLE = 0x2 PR_SPEC_FORCE_DISABLE = 0x8 PR_SPEC_INDIRECT_BRANCH = 0x1 + PR_SPEC_L1D_FLUSH = 0x2 PR_SPEC_NOT_AFFECTED = 0x0 PR_SPEC_PRCTL = 0x1 PR_SPEC_STORE_BYPASS = 0x0 @@ -2432,12 +2455,15 @@ const ( SMART_WRITE_THRESHOLDS = 0xd7 SMB_SUPER_MAGIC = 0x517b SOCKFS_MAGIC = 0x534f434b + SOCK_BUF_LOCK_MASK = 0x3 SOCK_DCCP = 0x6 SOCK_IOC_TYPE = 0x89 SOCK_PACKET = 0xa SOCK_RAW = 0x3 + SOCK_RCVBUF_LOCK = 0x2 SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 + SOCK_SNDBUF_LOCK = 0x1 SOL_AAL = 0x109 SOL_ALG = 0x117 SOL_ATM = 0x108 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 697811a460..80c790840c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 7d8d93bfc4..da55638a44 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -294,6 +294,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index f707d50894..c3da063c70 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -300,6 +300,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 3a67a9c852..fd9f0d1dbf 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -290,6 +290,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index a7ccef56c5..c358ada0d3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index f7b7cec910..1dc1ee16b9 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 4fcacf9584..3ae187dd93 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 6f6c223a2c..39895f0dd1 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 59e522bcf4..a98a45537b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -348,6 +348,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index d4264a0f73..0a8fbbffaa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -352,6 +352,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 21cbec1dd3..cb835a1442 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -352,6 +352,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 9b05bf12fc..73cf6554b0 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -281,6 +281,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index bd82ace09a..04b6dfaf5f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -356,6 +356,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 1f8bded56b..8c87d979d4 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -347,6 +347,7 @@ const ( SO_BPF_EXTENSIONS = 0x32 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0x400 + SO_BUF_LOCK = 0x51 SO_BUSY_POLL = 0x30 SO_BUSY_POLL_BUDGET = 0x49 SO_CNX_ADVICE = 0x37 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index 91a23cc728..85e0cc3866 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -17,6 +17,7 @@ int getdirent(int, uintptr_t, size_t); int wait4(int, uintptr_t, int, uintptr_t); int ioctl(int, int, uintptr_t); int fcntl(uintptr_t, int, uintptr_t); +int fsync_range(int, int, long long, long long); int acct(uintptr_t); int chdir(uintptr_t); int chroot(uintptr_t); @@ -29,7 +30,6 @@ int fchmod(int, unsigned int); int fchmodat(int, uintptr_t, unsigned int, int); int fchownat(int, uintptr_t, int, int, int); int fdatasync(int); -int fsync(int); int getpgid(int); int getpgrp(); int getpid(); @@ -255,6 +255,16 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func fsyncRange(fd int, how int, start int64, length int64) (err error) { + r0, er := C.fsync_range(C.int(fd), C.int(how), C.longlong(start), C.longlong(length)) + if r0 == -1 && er != nil { + err = er + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Acct(path string) (err error) { _p0 := uintptr(unsafe.Pointer(C.CString(path))) r0, er := C.acct(C.uintptr_t(_p0)) @@ -379,16 +389,6 @@ func Fdatasync(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Fsync(fd int) (err error) { - r0, er := C.fsync(C.int(fd)) - if r0 == -1 && er != nil { - err = er - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpgid(pid int) (pgid int, err error) { r0, er := C.getpgid(C.int(pid)) pgid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index 33c2609b8b..f1d4a73b08 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -135,6 +135,16 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func fsyncRange(fd int, how int, start int64, length int64) (err error) { + _, e1 := callfsync_range(fd, how, start, length) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Acct(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -283,16 +293,6 @@ func Fdatasync(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Fsync(fd int) (err error) { - _, e1 := callfsync(fd) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpgid(pid int) (pgid int, err error) { r0, e1 := callgetpgid(pid) pgid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go index 8b737fa971..2caa5adf95 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go @@ -18,6 +18,7 @@ import ( //go:cgo_import_dynamic libc_wait4 wait4 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fcntl fcntl "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_fsync_range fsync_range "libc.a/shr_64.o" //go:cgo_import_dynamic libc_acct acct "libc.a/shr_64.o" //go:cgo_import_dynamic libc_chdir chdir "libc.a/shr_64.o" //go:cgo_import_dynamic libc_chroot chroot "libc.a/shr_64.o" @@ -30,7 +31,6 @@ import ( //go:cgo_import_dynamic libc_fchmodat fchmodat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchownat fchownat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fdatasync fdatasync "libc.a/shr_64.o" -//go:cgo_import_dynamic libc_fsync fsync "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpgid getpgid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpgrp getpgrp "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpid getpid "libc.a/shr_64.o" @@ -136,6 +136,7 @@ import ( //go:linkname libc_wait4 libc_wait4 //go:linkname libc_ioctl libc_ioctl //go:linkname libc_fcntl libc_fcntl +//go:linkname libc_fsync_range libc_fsync_range //go:linkname libc_acct libc_acct //go:linkname libc_chdir libc_chdir //go:linkname libc_chroot libc_chroot @@ -148,7 +149,6 @@ import ( //go:linkname libc_fchmodat libc_fchmodat //go:linkname libc_fchownat libc_fchownat //go:linkname libc_fdatasync libc_fdatasync -//go:linkname libc_fsync libc_fsync //go:linkname libc_getpgid libc_getpgid //go:linkname libc_getpgrp libc_getpgrp //go:linkname libc_getpid libc_getpid @@ -257,6 +257,7 @@ var ( libc_wait4, libc_ioctl, libc_fcntl, + libc_fsync_range, libc_acct, libc_chdir, libc_chroot, @@ -269,7 +270,6 @@ var ( libc_fchmodat, libc_fchownat, libc_fdatasync, - libc_fsync, libc_getpgid, libc_getpgrp, libc_getpid, @@ -430,6 +430,13 @@ func callfcntl(fd uintptr, cmd int, arg uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func callfsync_range(fd int, how int, start int64, length int64) (r1 uintptr, e1 Errno) { + r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fsync_range)), 4, uintptr(fd), uintptr(how), uintptr(start), uintptr(length), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func callacct(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_acct)), 1, _p0, 0, 0, 0, 0, 0) return @@ -514,13 +521,6 @@ func callfdatasync(fd int) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func callfsync(fd int) (r1 uintptr, e1 Errno) { - r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func callgetpgid(pid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) return diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go index 3c260917ed..944a714b1a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go @@ -16,6 +16,7 @@ int getdirent(int, uintptr_t, size_t); int wait4(int, uintptr_t, int, uintptr_t); int ioctl(int, int, uintptr_t); int fcntl(uintptr_t, int, uintptr_t); +int fsync_range(int, int, long long, long long); int acct(uintptr_t); int chdir(uintptr_t); int chroot(uintptr_t); @@ -28,7 +29,6 @@ int fchmod(int, unsigned int); int fchmodat(int, uintptr_t, unsigned int, int); int fchownat(int, uintptr_t, int, int, int); int fdatasync(int); -int fsync(int); int getpgid(int); int getpgrp(); int getpid(); @@ -199,6 +199,14 @@ func callfcntl(fd uintptr, cmd int, arg uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func callfsync_range(fd int, how int, start int64, length int64) (r1 uintptr, e1 Errno) { + r1 = uintptr(C.fsync_range(C.int(fd), C.int(how), C.longlong(start), C.longlong(length))) + e1 = syscall.GetErrno() + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func callacct(_p0 uintptr) (r1 uintptr, e1 Errno) { r1 = uintptr(C.acct(C.uintptr_t(_p0))) e1 = syscall.GetErrno() @@ -295,14 +303,6 @@ func callfdatasync(fd int) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func callfsync(fd int) (r1 uintptr, e1 Errno) { - r1 = uintptr(C.fsync(C.int(fd))) - e1 = syscall.GetErrno() - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func callgetpgid(pid int) (r1 uintptr, e1 Errno) { r1 = uintptr(C.getpgid(C.int(pid))) e1 = syscall.GetErrno() diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index aa7ce85d15..31847d2305 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -444,4 +444,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index b830326386..3503cbbde3 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -366,4 +366,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index d75f65a0aa..5ecd24bf68 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -7,6 +7,7 @@ package unix const ( + SYS_SYSCALL_MASK = 0 SYS_RESTART_SYSCALL = 0 SYS_EXIT = 1 SYS_FORK = 2 @@ -407,4 +408,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index 8b02f09e9b..7e5c94cc7f 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -311,4 +311,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index 026695abb1..e1e2a2bf59 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -428,4 +428,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 4444 SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_RESTRICT_SELF = 4446 + SYS_PROCESS_MRELEASE = 4448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 7320ba9583..7651915a3a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -358,4 +358,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 5444 SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_RESTRICT_SELF = 5446 + SYS_PROCESS_MRELEASE = 5448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index 45082dd67f..a26a2c050b 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -358,4 +358,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 5444 SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_RESTRICT_SELF = 5446 + SYS_PROCESS_MRELEASE = 5448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index 570a857a56..fda9a6a991 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -428,4 +428,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 4444 SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_RESTRICT_SELF = 4446 + SYS_PROCESS_MRELEASE = 4448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 638498d62e..e8496150d4 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -435,4 +435,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index 702beebfef..5ee0678a36 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -407,4 +407,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index bfc87ea444..29c0f9a39e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -407,4 +407,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index a390e147d3..5c9a9a3b61 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -309,4 +309,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 3e791e6cd2..913f50f98b 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -372,4 +372,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 78802a5cf7..0de03a7227 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -386,4 +386,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 7efe5ccba3..885842c0eb 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -641,13 +641,13 @@ type Eproc struct { Tdev int32 Tpgid int32 Tsess uintptr - Wmesg [8]int8 + Wmesg [8]byte Xsize int32 Xrssize int16 Xccount int16 Xswrss int16 Flag int32 - Login [12]int8 + Login [12]byte Spare [4]int32 _ [4]byte } @@ -688,7 +688,7 @@ type ExternProc struct { P_priority uint8 P_usrpri uint8 P_nice int8 - P_comm [17]int8 + P_comm [17]byte P_pgrp uintptr P_addr uintptr P_xstat uint16 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index b23a2efe81..b23c02337d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -641,13 +641,13 @@ type Eproc struct { Tdev int32 Tpgid int32 Tsess uintptr - Wmesg [8]int8 + Wmesg [8]byte Xsize int32 Xrssize int16 Xccount int16 Xswrss int16 Flag int32 - Login [12]int8 + Login [12]byte Spare [4]int32 _ [4]byte } @@ -688,7 +688,7 @@ type ExternProc struct { P_priority uint8 P_usrpri uint8 P_nice int8 - P_comm [17]int8 + P_comm [17]byte P_pgrp uintptr P_addr uintptr P_xstat uint16 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 249ecfcd4c..620a6702fe 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -3264,7 +3264,8 @@ const ( LWTUNNEL_ENCAP_BPF = 0x6 LWTUNNEL_ENCAP_SEG6_LOCAL = 0x7 LWTUNNEL_ENCAP_RPL = 0x8 - LWTUNNEL_ENCAP_MAX = 0x8 + LWTUNNEL_ENCAP_IOAM6 = 0x9 + LWTUNNEL_ENCAP_MAX = 0x9 MPLS_IPTUNNEL_UNSPEC = 0x0 MPLS_IPTUNNEL_DST = 0x1 @@ -3617,7 +3618,9 @@ const ( ETHTOOL_A_COALESCE_TX_USECS_HIGH = 0x15 ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH = 0x16 ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 - ETHTOOL_A_COALESCE_MAX = 0x17 + ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18 + ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19 + ETHTOOL_A_COALESCE_MAX = 0x19 ETHTOOL_A_PAUSE_UNSPEC = 0x0 ETHTOOL_A_PAUSE_HEADER = 0x1 ETHTOOL_A_PAUSE_AUTONEG = 0x2 diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 2a8b1e6f73..baf5fe6504 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -564,12 +564,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index b1759cf705..e21ae8ecfa 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -564,12 +564,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index e807de2065..f190651cd9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -565,12 +565,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go index ff3aecaee4..84747c582c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go @@ -558,12 +558,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go index 9ecda69174..ac5c8b6370 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go @@ -558,12 +558,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/windows/aliases.go b/vendor/golang.org/x/sys/windows/aliases.go index af3af60db9..a20ebea633 100644 --- a/vendor/golang.org/x/sys/windows/aliases.go +++ b/vendor/golang.org/x/sys/windows/aliases.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build windows -// +build go1.9 +//go:build windows && go1.9 +// +build windows,go1.9 package windows diff --git a/vendor/golang.org/x/sys/windows/eventlog.go b/vendor/golang.org/x/sys/windows/eventlog.go index 40af946e16..2cd60645ee 100644 --- a/vendor/golang.org/x/sys/windows/eventlog.go +++ b/vendor/golang.org/x/sys/windows/eventlog.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows // +build windows package windows diff --git a/vendor/golang.org/x/sys/windows/mksyscall.go b/vendor/golang.org/x/sys/windows/mksyscall.go index 328e3b2ace..6102910989 100644 --- a/vendor/golang.org/x/sys/windows/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/mksyscall.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build generate // +build generate package windows diff --git a/vendor/golang.org/x/sys/windows/race.go b/vendor/golang.org/x/sys/windows/race.go index a74e3e24b5..9196b089ca 100644 --- a/vendor/golang.org/x/sys/windows/race.go +++ b/vendor/golang.org/x/sys/windows/race.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows && race // +build windows,race package windows diff --git a/vendor/golang.org/x/sys/windows/race0.go b/vendor/golang.org/x/sys/windows/race0.go index e44a3cbf67..7bae4817a0 100644 --- a/vendor/golang.org/x/sys/windows/race0.go +++ b/vendor/golang.org/x/sys/windows/race0.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows && !race // +build windows,!race package windows diff --git a/vendor/golang.org/x/sys/windows/service.go b/vendor/golang.org/x/sys/windows/service.go index b269850d06..f8deca8397 100644 --- a/vendor/golang.org/x/sys/windows/service.go +++ b/vendor/golang.org/x/sys/windows/service.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows // +build windows package windows @@ -16,8 +17,6 @@ const ( SC_MANAGER_ALL_ACCESS = 0xf003f ) -//sys OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenSCManagerW - const ( SERVICE_KERNEL_DRIVER = 1 SERVICE_FILE_SYSTEM_DRIVER = 2 @@ -132,6 +131,14 @@ const ( SC_EVENT_DATABASE_CHANGE = 0 SC_EVENT_PROPERTY_CHANGE = 1 SC_EVENT_STATUS_CHANGE = 2 + + SERVICE_START_REASON_DEMAND = 0x00000001 + SERVICE_START_REASON_AUTO = 0x00000002 + SERVICE_START_REASON_TRIGGER = 0x00000004 + SERVICE_START_REASON_RESTART_ON_FAILURE = 0x00000008 + SERVICE_START_REASON_DELAYEDAUTO = 0x00000010 + + SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON = 1 ) type SERVICE_STATUS struct { @@ -216,6 +223,7 @@ type QUERY_SERVICE_LOCK_STATUS struct { LockDuration uint32 } +//sys OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenSCManagerW //sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle //sys CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) [failretval==0] = advapi32.CreateServiceW //sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW @@ -235,3 +243,5 @@ type QUERY_SERVICE_LOCK_STATUS struct { //sys NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) = advapi32.NotifyServiceStatusChangeW //sys SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) = sechost.SubscribeServiceChangeNotifications? //sys UnsubscribeServiceChangeNotifications(subscription uintptr) = sechost.UnsubscribeServiceChangeNotifications? +//sys RegisterServiceCtrlHandlerEx(serviceName *uint16, handlerProc uintptr, context uintptr) (handle Handle, err error) = advapi32.RegisterServiceCtrlHandlerExW +//sys QueryServiceDynamicInformation(service Handle, infoLevel uint32, dynamicInfo unsafe.Pointer) (err error) = advapi32.QueryServiceDynamicInformation? diff --git a/vendor/golang.org/x/sys/windows/str.go b/vendor/golang.org/x/sys/windows/str.go index 917cc2aae4..4fc01434e4 100644 --- a/vendor/golang.org/x/sys/windows/str.go +++ b/vendor/golang.org/x/sys/windows/str.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows // +build windows package windows diff --git a/vendor/golang.org/x/sys/windows/syscall.go b/vendor/golang.org/x/sys/windows/syscall.go index 6122f557a0..72074d582f 100644 --- a/vendor/golang.org/x/sys/windows/syscall.go +++ b/vendor/golang.org/x/sys/windows/syscall.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows // +build windows // Package windows contains an interface to the low-level operating system diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index d3b59ae69c..2ff6aa0470 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -401,6 +401,11 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys LoadResource(module Handle, resInfo Handle) (resData Handle, err error) = kernel32.LoadResource //sys LockResource(resData Handle) (addr uintptr, err error) = kernel32.LockResource +// Version APIs +//sys GetFileVersionInfoSize(filename string, zeroHandle *Handle) (bufSize uint32, err error) = version.GetFileVersionInfoSizeW +//sys GetFileVersionInfo(filename string, handle uint32, bufSize uint32, buffer unsafe.Pointer) (err error) = version.GetFileVersionInfoW +//sys VerQueryValue(block unsafe.Pointer, subBlock string, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) = version.VerQueryValueW + // Process Status API (PSAPI) //sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses //sys EnumProcessModules(process Handle, module *Handle, cb uint32, cbNeeded *uint32) (err error) = psapi.EnumProcessModules @@ -418,11 +423,16 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys RtlInitString(destinationString *NTString, sourceString *byte) = ntdll.RtlInitString //sys NtCreateFile(handle *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer uintptr, ealength uint32) (ntstatus error) = ntdll.NtCreateFile //sys NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (ntstatus error) = ntdll.NtCreateNamedPipeFile +//sys NtSetInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32, class uint32) (ntstatus error) = ntdll.NtSetInformationFile //sys RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToNtPathName_U_WithStatus //sys RtlDosPathNameToRelativeNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToRelativeNtPathName_U_WithStatus //sys RtlDefaultNpAcl(acl **ACL) (ntstatus error) = ntdll.RtlDefaultNpAcl //sys NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) = ntdll.NtQueryInformationProcess //sys NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) = ntdll.NtSetInformationProcess +//sys NtQuerySystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32, retLen *uint32) (ntstatus error) = ntdll.NtQuerySystemInformation +//sys NtSetSystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32) (ntstatus error) = ntdll.NtSetSystemInformation +//sys RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) = ntdll.RtlAddFunctionTable +//sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable // syscall interface implementation for other packages @@ -883,9 +893,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, int32, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil } @@ -905,9 +913,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, int32, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil } @@ -980,9 +986,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -991,9 +995,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, syscall.EAFNOSUPPORT diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index 88e0ce5d0d..286dd1eab9 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -66,9 +66,21 @@ var signals = [...]string{ } const ( - FILE_LIST_DIRECTORY = 0x00000001 - FILE_APPEND_DATA = 0x00000004 + FILE_READ_DATA = 0x00000001 + FILE_READ_ATTRIBUTES = 0x00000080 + FILE_READ_EA = 0x00000008 + FILE_WRITE_DATA = 0x00000002 FILE_WRITE_ATTRIBUTES = 0x00000100 + FILE_WRITE_EA = 0x00000010 + FILE_APPEND_DATA = 0x00000004 + FILE_EXECUTE = 0x00000020 + + FILE_GENERIC_READ = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE + FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE + FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE + + FILE_LIST_DIRECTORY = 0x00000001 + FILE_TRAVERSE = 0x00000020 FILE_SHARE_READ = 0x00000001 FILE_SHARE_WRITE = 0x00000002 @@ -1789,7 +1801,53 @@ type reparseDataBuffer struct { } const ( - FSCTL_GET_REPARSE_POINT = 0x900A8 + FSCTL_CREATE_OR_GET_OBJECT_ID = 0x0900C0 + FSCTL_DELETE_OBJECT_ID = 0x0900A0 + FSCTL_DELETE_REPARSE_POINT = 0x0900AC + FSCTL_DUPLICATE_EXTENTS_TO_FILE = 0x098344 + FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX = 0x0983E8 + FSCTL_FILESYSTEM_GET_STATISTICS = 0x090060 + FSCTL_FILE_LEVEL_TRIM = 0x098208 + FSCTL_FIND_FILES_BY_SID = 0x09008F + FSCTL_GET_COMPRESSION = 0x09003C + FSCTL_GET_INTEGRITY_INFORMATION = 0x09027C + FSCTL_GET_NTFS_VOLUME_DATA = 0x090064 + FSCTL_GET_REFS_VOLUME_DATA = 0x0902D8 + FSCTL_GET_OBJECT_ID = 0x09009C + FSCTL_GET_REPARSE_POINT = 0x0900A8 + FSCTL_GET_RETRIEVAL_POINTER_COUNT = 0x09042B + FSCTL_GET_RETRIEVAL_POINTERS = 0x090073 + FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT = 0x0903D3 + FSCTL_IS_PATHNAME_VALID = 0x09002C + FSCTL_LMR_SET_LINK_TRACKING_INFORMATION = 0x1400EC + FSCTL_MARK_HANDLE = 0x0900FC + FSCTL_OFFLOAD_READ = 0x094264 + FSCTL_OFFLOAD_WRITE = 0x098268 + FSCTL_PIPE_PEEK = 0x11400C + FSCTL_PIPE_TRANSCEIVE = 0x11C017 + FSCTL_PIPE_WAIT = 0x110018 + FSCTL_QUERY_ALLOCATED_RANGES = 0x0940CF + FSCTL_QUERY_FAT_BPB = 0x090058 + FSCTL_QUERY_FILE_REGIONS = 0x090284 + FSCTL_QUERY_ON_DISK_VOLUME_INFO = 0x09013C + FSCTL_QUERY_SPARING_INFO = 0x090138 + FSCTL_READ_FILE_USN_DATA = 0x0900EB + FSCTL_RECALL_FILE = 0x090117 + FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT = 0x090440 + FSCTL_SET_COMPRESSION = 0x09C040 + FSCTL_SET_DEFECT_MANAGEMENT = 0x098134 + FSCTL_SET_ENCRYPTION = 0x0900D7 + FSCTL_SET_INTEGRITY_INFORMATION = 0x09C280 + FSCTL_SET_INTEGRITY_INFORMATION_EX = 0x090380 + FSCTL_SET_OBJECT_ID = 0x090098 + FSCTL_SET_OBJECT_ID_EXTENDED = 0x0900BC + FSCTL_SET_REPARSE_POINT = 0x0900A4 + FSCTL_SET_SPARSE = 0x0900C4 + FSCTL_SET_ZERO_DATA = 0x0980C8 + FSCTL_SET_ZERO_ON_DEALLOCATION = 0x090194 + FSCTL_SIS_COPYFILE = 0x090100 + FSCTL_WRITE_USN_CLOSE_RECORD = 0x0900EF + MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024 IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 IO_REPARSE_TAG_SYMLINK = 0xA000000C @@ -2308,6 +2366,12 @@ type LIST_ENTRY struct { Blink *LIST_ENTRY } +type RUNTIME_FUNCTION struct { + BeginAddress uint32 + EndAddress uint32 + UnwindData uint32 +} + type LDR_DATA_TABLE_ENTRY struct { reserved1 [2]uintptr InMemoryOrderLinks LIST_ENTRY @@ -2498,6 +2562,60 @@ const ( FILE_PIPE_SERVER_END = 0x00000001 ) +const ( + // FileInformationClass for NtSetInformationFile + FileBasicInformation = 4 + FileRenameInformation = 10 + FileDispositionInformation = 13 + FilePositionInformation = 14 + FileEndOfFileInformation = 20 + FileValidDataLengthInformation = 39 + FileShortNameInformation = 40 + FileIoPriorityHintInformation = 43 + FileReplaceCompletionInformation = 61 + FileDispositionInformationEx = 64 + FileCaseSensitiveInformation = 71 + FileLinkInformation = 72 + FileCaseSensitiveInformationForceAccessCheck = 75 + FileKnownFolderInformation = 76 + + // Flags for FILE_RENAME_INFORMATION + FILE_RENAME_REPLACE_IF_EXISTS = 0x00000001 + FILE_RENAME_POSIX_SEMANTICS = 0x00000002 + FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE = 0x00000004 + FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008 + FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE = 0x00000010 + FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE = 0x00000020 + FILE_RENAME_PRESERVE_AVAILABLE_SPACE = 0x00000030 + FILE_RENAME_IGNORE_READONLY_ATTRIBUTE = 0x00000040 + FILE_RENAME_FORCE_RESIZE_TARGET_SR = 0x00000080 + FILE_RENAME_FORCE_RESIZE_SOURCE_SR = 0x00000100 + FILE_RENAME_FORCE_RESIZE_SR = 0x00000180 + + // Flags for FILE_DISPOSITION_INFORMATION_EX + FILE_DISPOSITION_DO_NOT_DELETE = 0x00000000 + FILE_DISPOSITION_DELETE = 0x00000001 + FILE_DISPOSITION_POSIX_SEMANTICS = 0x00000002 + FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x00000004 + FILE_DISPOSITION_ON_CLOSE = 0x00000008 + FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x00000010 + + // Flags for FILE_CASE_SENSITIVE_INFORMATION + FILE_CS_FLAG_CASE_SENSITIVE_DIR = 0x00000001 + + // Flags for FILE_LINK_INFORMATION + FILE_LINK_REPLACE_IF_EXISTS = 0x00000001 + FILE_LINK_POSIX_SEMANTICS = 0x00000002 + FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008 + FILE_LINK_NO_INCREASE_AVAILABLE_SPACE = 0x00000010 + FILE_LINK_NO_DECREASE_AVAILABLE_SPACE = 0x00000020 + FILE_LINK_PRESERVE_AVAILABLE_SPACE = 0x00000030 + FILE_LINK_IGNORE_READONLY_ATTRIBUTE = 0x00000040 + FILE_LINK_FORCE_RESIZE_TARGET_SR = 0x00000080 + FILE_LINK_FORCE_RESIZE_SOURCE_SR = 0x00000100 + FILE_LINK_FORCE_RESIZE_SR = 0x00000180 +) + // ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess. const ( ProcessBasicInformation = iota @@ -2614,6 +2732,203 @@ type PROCESS_BASIC_INFORMATION struct { InheritedFromUniqueProcessId uintptr } +// SystemInformationClasses for NtQuerySystemInformation and NtSetSystemInformation +const ( + SystemBasicInformation = iota + SystemProcessorInformation + SystemPerformanceInformation + SystemTimeOfDayInformation + SystemPathInformation + SystemProcessInformation + SystemCallCountInformation + SystemDeviceInformation + SystemProcessorPerformanceInformation + SystemFlagsInformation + SystemCallTimeInformation + SystemModuleInformation + SystemLocksInformation + SystemStackTraceInformation + SystemPagedPoolInformation + SystemNonPagedPoolInformation + SystemHandleInformation + SystemObjectInformation + SystemPageFileInformation + SystemVdmInstemulInformation + SystemVdmBopInformation + SystemFileCacheInformation + SystemPoolTagInformation + SystemInterruptInformation + SystemDpcBehaviorInformation + SystemFullMemoryInformation + SystemLoadGdiDriverInformation + SystemUnloadGdiDriverInformation + SystemTimeAdjustmentInformation + SystemSummaryMemoryInformation + SystemMirrorMemoryInformation + SystemPerformanceTraceInformation + systemObsolete0 + SystemExceptionInformation + SystemCrashDumpStateInformation + SystemKernelDebuggerInformation + SystemContextSwitchInformation + SystemRegistryQuotaInformation + SystemExtendServiceTableInformation + SystemPrioritySeperation + SystemVerifierAddDriverInformation + SystemVerifierRemoveDriverInformation + SystemProcessorIdleInformation + SystemLegacyDriverInformation + SystemCurrentTimeZoneInformation + SystemLookasideInformation + SystemTimeSlipNotification + SystemSessionCreate + SystemSessionDetach + SystemSessionInformation + SystemRangeStartInformation + SystemVerifierInformation + SystemVerifierThunkExtend + SystemSessionProcessInformation + SystemLoadGdiDriverInSystemSpace + SystemNumaProcessorMap + SystemPrefetcherInformation + SystemExtendedProcessInformation + SystemRecommendedSharedDataAlignment + SystemComPlusPackage + SystemNumaAvailableMemory + SystemProcessorPowerInformation + SystemEmulationBasicInformation + SystemEmulationProcessorInformation + SystemExtendedHandleInformation + SystemLostDelayedWriteInformation + SystemBigPoolInformation + SystemSessionPoolTagInformation + SystemSessionMappedViewInformation + SystemHotpatchInformation + SystemObjectSecurityMode + SystemWatchdogTimerHandler + SystemWatchdogTimerInformation + SystemLogicalProcessorInformation + SystemWow64SharedInformationObsolete + SystemRegisterFirmwareTableInformationHandler + SystemFirmwareTableInformation + SystemModuleInformationEx + SystemVerifierTriageInformation + SystemSuperfetchInformation + SystemMemoryListInformation + SystemFileCacheInformationEx + SystemThreadPriorityClientIdInformation + SystemProcessorIdleCycleTimeInformation + SystemVerifierCancellationInformation + SystemProcessorPowerInformationEx + SystemRefTraceInformation + SystemSpecialPoolInformation + SystemProcessIdInformation + SystemErrorPortInformation + SystemBootEnvironmentInformation + SystemHypervisorInformation + SystemVerifierInformationEx + SystemTimeZoneInformation + SystemImageFileExecutionOptionsInformation + SystemCoverageInformation + SystemPrefetchPatchInformation + SystemVerifierFaultsInformation + SystemSystemPartitionInformation + SystemSystemDiskInformation + SystemProcessorPerformanceDistribution + SystemNumaProximityNodeInformation + SystemDynamicTimeZoneInformation + SystemCodeIntegrityInformation + SystemProcessorMicrocodeUpdateInformation + SystemProcessorBrandString + SystemVirtualAddressInformation + SystemLogicalProcessorAndGroupInformation + SystemProcessorCycleTimeInformation + SystemStoreInformation + SystemRegistryAppendString + SystemAitSamplingValue + SystemVhdBootInformation + SystemCpuQuotaInformation + SystemNativeBasicInformation + systemSpare1 + SystemLowPriorityIoInformation + SystemTpmBootEntropyInformation + SystemVerifierCountersInformation + SystemPagedPoolInformationEx + SystemSystemPtesInformationEx + SystemNodeDistanceInformation + SystemAcpiAuditInformation + SystemBasicPerformanceInformation + SystemQueryPerformanceCounterInformation + SystemSessionBigPoolInformation + SystemBootGraphicsInformation + SystemScrubPhysicalMemoryInformation + SystemBadPageInformation + SystemProcessorProfileControlArea + SystemCombinePhysicalMemoryInformation + SystemEntropyInterruptTimingCallback + SystemConsoleInformation + SystemPlatformBinaryInformation + SystemThrottleNotificationInformation + SystemHypervisorProcessorCountInformation + SystemDeviceDataInformation + SystemDeviceDataEnumerationInformation + SystemMemoryTopologyInformation + SystemMemoryChannelInformation + SystemBootLogoInformation + SystemProcessorPerformanceInformationEx + systemSpare0 + SystemSecureBootPolicyInformation + SystemPageFileInformationEx + SystemSecureBootInformation + SystemEntropyInterruptTimingRawInformation + SystemPortableWorkspaceEfiLauncherInformation + SystemFullProcessInformation + SystemKernelDebuggerInformationEx + SystemBootMetadataInformation + SystemSoftRebootInformation + SystemElamCertificateInformation + SystemOfflineDumpConfigInformation + SystemProcessorFeaturesInformation + SystemRegistryReconciliationInformation + SystemEdidInformation + SystemManufacturingInformation + SystemEnergyEstimationConfigInformation + SystemHypervisorDetailInformation + SystemProcessorCycleStatsInformation + SystemVmGenerationCountInformation + SystemTrustedPlatformModuleInformation + SystemKernelDebuggerFlags + SystemCodeIntegrityPolicyInformation + SystemIsolatedUserModeInformation + SystemHardwareSecurityTestInterfaceResultsInformation + SystemSingleModuleInformation + SystemAllowedCpuSetsInformation + SystemDmaProtectionInformation + SystemInterruptCpuSetsInformation + SystemSecureBootPolicyFullInformation + SystemCodeIntegrityPolicyFullInformation + SystemAffinitizedInterruptProcessorInformation + SystemRootSiloInformation +) + +type RTL_PROCESS_MODULE_INFORMATION struct { + Section Handle + MappedBase uintptr + ImageBase uintptr + ImageSize uint32 + Flags uint32 + LoadOrderIndex uint16 + InitOrderIndex uint16 + LoadCount uint16 + OffsetToFileName uint16 + FullPathName [256]byte +} + +type RTL_PROCESS_MODULES struct { + NumberOfModules uint32 + Modules [1]RTL_PROCESS_MODULE_INFORMATION +} + // Constants for LocalAlloc flags. const ( LMEM_FIXED = 0x0 @@ -2708,6 +3023,22 @@ var ( RT_MANIFEST ResourceID = 24 ) +type VS_FIXEDFILEINFO struct { + Signature uint32 + StrucVersion uint32 + FileVersionMS uint32 + FileVersionLS uint32 + ProductVersionMS uint32 + ProductVersionLS uint32 + FileFlagsMask uint32 + FileFlags uint32 + FileOS uint32 + FileType uint32 + FileSubtype uint32 + FileDateMS uint32 + FileDateLS uint32 +} + type COAUTHIDENTITY struct { User *uint16 UserLength uint32 diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 4ea788e4c4..91817d6dcb 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -51,6 +51,7 @@ var ( modshell32 = NewLazySystemDLL("shell32.dll") moduser32 = NewLazySystemDLL("user32.dll") moduserenv = NewLazySystemDLL("userenv.dll") + modversion = NewLazySystemDLL("version.dll") modwintrust = NewLazySystemDLL("wintrust.dll") modws2_32 = NewLazySystemDLL("ws2_32.dll") modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") @@ -114,6 +115,7 @@ var ( procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") + procQueryServiceDynamicInformation = modadvapi32.NewProc("QueryServiceDynamicInformation") procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW") procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx") @@ -124,6 +126,7 @@ var ( procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") + procRegisterServiceCtrlHandlerExW = modadvapi32.NewProc("RegisterServiceCtrlHandlerExW") procReportEventW = modadvapi32.NewProc("ReportEventW") procRevertToSelf = modadvapi32.NewProc("RevertToSelf") procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW") @@ -365,8 +368,13 @@ var ( procNtCreateFile = modntdll.NewProc("NtCreateFile") procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile") procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess") + procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation") + procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile") procNtSetInformationProcess = modntdll.NewProc("NtSetInformationProcess") + procNtSetSystemInformation = modntdll.NewProc("NtSetSystemInformation") + procRtlAddFunctionTable = modntdll.NewProc("RtlAddFunctionTable") procRtlDefaultNpAcl = modntdll.NewProc("RtlDefaultNpAcl") + procRtlDeleteFunctionTable = modntdll.NewProc("RtlDeleteFunctionTable") procRtlDosPathNameToNtPathName_U_WithStatus = modntdll.NewProc("RtlDosPathNameToNtPathName_U_WithStatus") procRtlDosPathNameToRelativeNtPathName_U_WithStatus = modntdll.NewProc("RtlDosPathNameToRelativeNtPathName_U_WithStatus") procRtlGetCurrentPeb = modntdll.NewProc("RtlGetCurrentPeb") @@ -402,6 +410,9 @@ var ( procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") + procGetFileVersionInfoSizeW = modversion.NewProc("GetFileVersionInfoSizeW") + procGetFileVersionInfoW = modversion.NewProc("GetFileVersionInfoW") + procVerQueryValueW = modversion.NewProc("VerQueryValueW") procWinVerifyTrustEx = modwintrust.NewProc("WinVerifyTrustEx") procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") @@ -966,6 +977,18 @@ func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, buf return } +func QueryServiceDynamicInformation(service Handle, infoLevel uint32, dynamicInfo unsafe.Pointer) (err error) { + err = procQueryServiceDynamicInformation.Find() + if err != nil { + return + } + r1, _, e1 := syscall.Syscall(procQueryServiceDynamicInformation.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(dynamicInfo)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) { r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0) if r1 == 0 { @@ -1055,6 +1078,15 @@ func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Hand return } +func RegisterServiceCtrlHandlerEx(serviceName *uint16, handlerProc uintptr, context uintptr) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall(procRegisterServiceCtrlHandlerExW.Addr(), 3, uintptr(unsafe.Pointer(serviceName)), uintptr(handlerProc), uintptr(context)) + handle = Handle(r0) + if handle == 0 { + err = errnoErr(e1) + } + return +} + func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) { r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData))) if r1 == 0 { @@ -3160,6 +3192,22 @@ func NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe return } +func NtQuerySystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32, retLen *uint32) (ntstatus error) { + r0, _, _ := syscall.Syscall6(procNtQuerySystemInformation.Addr(), 4, uintptr(sysInfoClass), uintptr(sysInfo), uintptr(sysInfoLen), uintptr(unsafe.Pointer(retLen)), 0, 0) + if r0 != 0 { + ntstatus = NTStatus(r0) + } + return +} + +func NtSetInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32, class uint32) (ntstatus error) { + r0, _, _ := syscall.Syscall6(procNtSetInformationFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen), uintptr(class), 0) + if r0 != 0 { + ntstatus = NTStatus(r0) + } + return +} + func NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) { r0, _, _ := syscall.Syscall6(procNtSetInformationProcess.Addr(), 4, uintptr(proc), uintptr(procInfoClass), uintptr(procInfo), uintptr(procInfoLen), 0, 0) if r0 != 0 { @@ -3168,6 +3216,20 @@ func NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.P return } +func NtSetSystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32) (ntstatus error) { + r0, _, _ := syscall.Syscall(procNtSetSystemInformation.Addr(), 3, uintptr(sysInfoClass), uintptr(sysInfo), uintptr(sysInfoLen)) + if r0 != 0 { + ntstatus = NTStatus(r0) + } + return +} + +func RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) { + r0, _, _ := syscall.Syscall(procRtlAddFunctionTable.Addr(), 3, uintptr(unsafe.Pointer(functionTable)), uintptr(entryCount), uintptr(baseAddress)) + ret = r0 != 0 + return +} + func RtlDefaultNpAcl(acl **ACL) (ntstatus error) { r0, _, _ := syscall.Syscall(procRtlDefaultNpAcl.Addr(), 1, uintptr(unsafe.Pointer(acl)), 0, 0) if r0 != 0 { @@ -3176,6 +3238,12 @@ func RtlDefaultNpAcl(acl **ACL) (ntstatus error) { return } +func RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) { + r0, _, _ := syscall.Syscall(procRtlDeleteFunctionTable.Addr(), 1, uintptr(unsafe.Pointer(functionTable)), 0, 0) + ret = r0 != 0 + return +} + func RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) { r0, _, _ := syscall.Syscall6(procRtlDosPathNameToNtPathName_U_WithStatus.Addr(), 4, uintptr(unsafe.Pointer(dosName)), uintptr(unsafe.Pointer(ntName)), uintptr(unsafe.Pointer(ntFileNamePart)), uintptr(unsafe.Pointer(relativeName)), 0, 0) if r0 != 0 { @@ -3449,6 +3517,58 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { return } +func GetFileVersionInfoSize(filename string, zeroHandle *Handle) (bufSize uint32, err error) { + var _p0 *uint16 + _p0, err = syscall.UTF16PtrFromString(filename) + if err != nil { + return + } + return _GetFileVersionInfoSize(_p0, zeroHandle) +} + +func _GetFileVersionInfoSize(filename *uint16, zeroHandle *Handle) (bufSize uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetFileVersionInfoSizeW.Addr(), 2, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(zeroHandle)), 0) + bufSize = uint32(r0) + if bufSize == 0 { + err = errnoErr(e1) + } + return +} + +func GetFileVersionInfo(filename string, handle uint32, bufSize uint32, buffer unsafe.Pointer) (err error) { + var _p0 *uint16 + _p0, err = syscall.UTF16PtrFromString(filename) + if err != nil { + return + } + return _GetFileVersionInfo(_p0, handle, bufSize, buffer) +} + +func _GetFileVersionInfo(filename *uint16, handle uint32, bufSize uint32, buffer unsafe.Pointer) (err error) { + r1, _, e1 := syscall.Syscall6(procGetFileVersionInfoW.Addr(), 4, uintptr(unsafe.Pointer(filename)), uintptr(handle), uintptr(bufSize), uintptr(buffer), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func VerQueryValue(block unsafe.Pointer, subBlock string, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) { + var _p0 *uint16 + _p0, err = syscall.UTF16PtrFromString(subBlock) + if err != nil { + return + } + return _VerQueryValue(block, _p0, pointerToBufferPointer, bufSize) +} + +func _VerQueryValue(block unsafe.Pointer, subBlock *uint16, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procVerQueryValueW.Addr(), 4, uintptr(block), uintptr(unsafe.Pointer(subBlock)), uintptr(pointerToBufferPointer), uintptr(unsafe.Pointer(bufSize)), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) { r0, _, _ := syscall.Syscall(procWinVerifyTrustEx.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data))) if r0 != 0 { diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go index 54d187186b..af2cffe985 100644 --- a/vendor/google.golang.org/grpc/status/status.go +++ b/vendor/google.golang.org/grpc/status/status.go @@ -73,11 +73,16 @@ func FromProto(s *spb.Status) *Status { return status.FromProto(s) } -// FromError returns a Status representing err if it was produced by this -// package or has a method `GRPCStatus() *Status`. -// If err is nil, a Status is returned with codes.OK and no message. -// Otherwise, ok is false and a Status is returned with codes.Unknown and -// the original error message. +// FromError returns a Status representation of err. +// +// - If err was produced by this package or implements the method `GRPCStatus() +// *Status`, the appropriate Status is returned. +// +// - If err is nil, a Status is returned with codes.OK and no message. +// +// - Otherwise, err is an error not compatible with this package. In this +// case, a Status is returned with codes.Unknown and err's Error() message, +// and ok is false. func FromError(err error) (s *Status, ok bool) { if err == nil { return nil, true diff --git a/vendor/modules.txt b/vendor/modules.txt index 4214b655d0..0061eec8ff 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,23 +1,21 @@ # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml -# github.com/Microsoft/go-winio v0.5.0 +# github.com/Microsoft/go-winio v0.5.1 github.com/Microsoft/go-winio github.com/Microsoft/go-winio/pkg/guid # github.com/alessio/shellescape v1.4.1 github.com/alessio/shellescape # github.com/containerd/containerd v1.5.7 -## explicit github.com/containerd/containerd/errdefs github.com/containerd/containerd/log github.com/containerd/containerd/platforms -# github.com/containerd/stargz-snapshotter/estargz v0.9.0 +# github.com/containerd/stargz-snapshotter/estargz v0.10.0 ## explicit github.com/containerd/stargz-snapshotter/estargz github.com/containerd/stargz-snapshotter/estargz/errorutil # github.com/cpuguy83/go-md2man/v2 v2.0.1 -## explicit github.com/cpuguy83/go-md2man/v2/md2man -# github.com/docker/cli v20.10.7+incompatible +# github.com/docker/cli v20.10.10+incompatible github.com/docker/cli/cli/config github.com/docker/cli/cli/config/configfile github.com/docker/cli/cli/config/credentials @@ -48,7 +46,7 @@ github.com/docker/docker/api/types/volume github.com/docker/docker/client github.com/docker/docker/errdefs github.com/docker/docker/pkg/homedir -# github.com/docker/docker-credential-helpers v0.6.3 +# github.com/docker/docker-credential-helpers v0.6.4 github.com/docker/docker-credential-helpers/client github.com/docker/docker-credential-helpers/credentials # github.com/docker/go-connections v0.4.0 @@ -87,7 +85,7 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/go-containerregistry v0.6.0 +# github.com/google/go-containerregistry v0.7.0 ## explicit github.com/google/go-containerregistry/cmd/crane/cmd github.com/google/go-containerregistry/internal/and @@ -193,16 +191,14 @@ github.com/subosito/gotenv github.com/vbatts/tar-split/archive/tar # golang.org/x/mod v0.4.2 golang.org/x/mod/semver -# golang.org/x/net v0.0.0-20211007125505-59d4e928ea9d -## explicit +# golang.org/x/net v0.0.0-20211111160137-58aab5ef257a golang.org/x/net/internal/socks golang.org/x/net/proxy # golang.org/x/sync v0.0.0-20210220032951-036812b2e83c ## explicit golang.org/x/sync/errgroup golang.org/x/sync/semaphore -# golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac -## explicit +# golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 golang.org/x/sys/execabs golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix @@ -230,11 +226,9 @@ golang.org/x/tools/internal/typesinternal # golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 golang.org/x/xerrors golang.org/x/xerrors/internal -# google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e -## explicit +# google.golang.org/genproto v0.0.0-20211111162719-482062a4217b google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.41.0 -## explicit +# google.golang.org/grpc v1.42.0 google.golang.org/grpc/codes google.golang.org/grpc/internal/status google.golang.org/grpc/status @@ -269,8 +263,6 @@ google.golang.org/protobuf/types/descriptorpb google.golang.org/protobuf/types/known/anypb google.golang.org/protobuf/types/known/durationpb google.golang.org/protobuf/types/known/timestamppb -# gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b -## explicit # gopkg.in/ini.v1 v1.63.2 gopkg.in/ini.v1 # gopkg.in/yaml.v2 v2.4.0