vendor: bump go.podman.io/{common,image,storage} to main
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
This commit is contained in:
parent
fb473e4d53
commit
e3f55fec61
31
go.mod
31
go.mod
|
@ -2,7 +2,7 @@ module github.com/containers/buildah
|
|||
|
||||
// Warning: Ensure the "go" and "toolchain" versions match exactly to prevent unwanted auto-updates
|
||||
|
||||
go 1.24.0
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
github.com/containerd/platforms v1.0.0-rc.1
|
||||
|
@ -34,9 +34,9 @@ require (
|
|||
github.com/spf13/pflag v1.0.10
|
||||
github.com/stretchr/testify v1.11.1
|
||||
go.etcd.io/bbolt v1.4.3
|
||||
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118
|
||||
go.podman.io/image/v5 v5.36.1-0.20250820085751-a13b38f45723
|
||||
go.podman.io/storage v1.59.1-0.20250820085751-a13b38f45723
|
||||
go.podman.io/common v0.65.1-0.20250916163606-92222dcd3da4
|
||||
go.podman.io/image/v5 v5.37.1-0.20250916163606-92222dcd3da4
|
||||
go.podman.io/storage v1.60.1-0.20250916163606-92222dcd3da4
|
||||
golang.org/x/crypto v0.42.0
|
||||
golang.org/x/sync v0.17.0
|
||||
golang.org/x/sys v0.36.0
|
||||
|
@ -58,7 +58,7 @@ require (
|
|||
github.com/containerd/log v0.1.0 // indirect
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.17.0 // indirect
|
||||
github.com/containerd/typeurl/v2 v2.2.3 // indirect
|
||||
github.com/containernetworking/plugins v1.7.1 // indirect
|
||||
github.com/containernetworking/plugins v1.8.0 // indirect
|
||||
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.6.0 // indirect
|
||||
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 // indirect
|
||||
|
@ -74,7 +74,7 @@ require (
|
|||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/go-containerregistry v0.20.3 // indirect
|
||||
github.com/google/go-containerregistry v0.20.6 // indirect
|
||||
github.com/google/go-intervals v0.0.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
|
@ -106,12 +106,12 @@ require (
|
|||
github.com/proglottis/gpgme v0.1.5 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.9.1 // indirect
|
||||
github.com/sigstore/fulcio v1.6.6 // indirect
|
||||
github.com/sigstore/fulcio v1.7.1 // indirect
|
||||
github.com/sigstore/protobuf-specs v0.4.1 // indirect
|
||||
github.com/sigstore/sigstore v1.9.5 // indirect
|
||||
github.com/smallstep/pkcs7 v0.1.1 // indirect
|
||||
github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 // indirect
|
||||
github.com/sylabs/sif/v2 v2.21.1 // indirect
|
||||
github.com/sylabs/sif/v2 v2.22.0 // indirect
|
||||
github.com/tchap/go-patricia/v2 v2.3.3 // indirect
|
||||
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
|
||||
github.com/ulikunitz/xz v0.5.15 // indirect
|
||||
|
@ -119,20 +119,19 @@ require (
|
|||
github.com/vbauerster/mpb/v8 v8.10.2 // indirect
|
||||
github.com/vishvananda/netlink v1.3.1 // indirect
|
||||
github.com/vishvananda/netns v0.0.5 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
|
||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
|
||||
go.opentelemetry.io/otel v1.36.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.36.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.36.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
||||
golang.org/x/mod v0.27.0 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
|
||||
google.golang.org/grpc v1.72.2 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
google.golang.org/protobuf v1.36.8 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/klog v1.0.0 // indirect
|
||||
sigs.k8s.io/yaml v1.6.0 // indirect
|
||||
|
|
104
go.sum
104
go.sum
|
@ -6,8 +6,8 @@ github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEK
|
|||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
|
||||
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
||||
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
|
||||
|
@ -47,8 +47,8 @@ github.com/containerd/typeurl/v2 v2.2.3 h1:yNA/94zxWdvYACdYO8zofhrTVuQY73fFU1y++
|
|||
github.com/containerd/typeurl/v2 v2.2.3/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk=
|
||||
github.com/containernetworking/cni v1.3.0 h1:v6EpN8RznAZj9765HhXQrtXgX+ECGebEYEmnuFjskwo=
|
||||
github.com/containernetworking/cni v1.3.0/go.mod h1:Bs8glZjjFfGPHMw6hQu82RUgEPNGEaBb9KS5KtNMnJ4=
|
||||
github.com/containernetworking/plugins v1.7.1 h1:CNAR0jviDj6FS5Vg85NTgKWLDzZPfi/lj+VJfhMDTIs=
|
||||
github.com/containernetworking/plugins v1.7.1/go.mod h1:xuMdjuio+a1oVQsHKjr/mgzuZ24leAsqUYRnzGoXHy0=
|
||||
github.com/containernetworking/plugins v1.8.0 h1:WjGbV/0UQyo8A4qBsAh6GaDAtu1hevxVxsEuqtBqUFk=
|
||||
github.com/containernetworking/plugins v1.8.0/go.mod h1:JG3BxoJifxxHBhG3hFyxyhid7JgRVBu/wtooGEvWf1c=
|
||||
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
|
||||
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
|
||||
github.com/containers/luksy v0.0.0-20250714213221-8fccf784694e h1:nrNp2M6tTNGvLVrJpgqge9GwHgsWBGp2HBKg84BdVd8=
|
||||
|
@ -72,8 +72,8 @@ github.com/disiqueira/gotree/v3 v3.0.2 h1:ik5iuLQQoufZBNPY518dXhiO5056hyNBIK9lWh
|
|||
github.com/disiqueira/gotree/v3 v3.0.2/go.mod h1:ZuyjE4+mUQZlbpkI24AmruZKhg3VHEgPLDY8Qk+uUu8=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/docker/cli v28.3.3+incompatible h1:fp9ZHAr1WWPGdIWBM1b3zLtgCF+83gRdVMTJsUeiyAo=
|
||||
github.com/docker/cli v28.3.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/cli v28.4.0+incompatible h1:RBcf3Kjw2pMtwui5V0DIMdyeab8glEw5QY0UUU4C9kY=
|
||||
github.com/docker/cli v28.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v28.4.0+incompatible h1:KVC7bz5zJY/4AZe/78BIvCnPsLaC9T/zh72xnlrTTOk=
|
||||
|
@ -113,20 +113,20 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6
|
|||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/go-containerregistry v0.20.3 h1:oNx7IdTI936V8CQRveCjaxOiegWwvM7kqkbXTpyiovI=
|
||||
github.com/google/go-containerregistry v0.20.3/go.mod h1:w00pIgBRDVUDFM6bq+Qx8lwNWK+cxgCuX1vd3PIBDNI=
|
||||
github.com/google/go-containerregistry v0.20.6 h1:cvWX87UxxLgaH76b4hIvya6Dzz9qHB31qAwjAohdSTU=
|
||||
github.com/google/go-containerregistry v0.20.6/go.mod h1:T0x8MuoAoKX/873bkeSfLD2FAkwCDf9/HZgsFJ02E2Y=
|
||||
github.com/google/go-intervals v0.0.2 h1:FGrVEiUnTRKR8yE04qzXYaJMtnIYqobR5QbblK3ixcM=
|
||||
github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 h1:EEHtgt9IwisQ2AZ4pIsMjahcegHh6rmhqxzIRQIyepY=
|
||||
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6/go.mod h1:I6V7YzU0XDpsHqbsyrghnFZLO1gwK6NPTNvmetQIk9U=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
|
@ -195,10 +195,10 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
|||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/onsi/ginkgo/v2 v2.25.1 h1:Fwp6crTREKM+oA6Cz4MsO8RhKQzs2/gOIVOUscMAfZY=
|
||||
github.com/onsi/ginkgo/v2 v2.25.1/go.mod h1:ppTWQ1dh9KM/F1XgpeRqelR+zHVwV81DGRSDnFxK7Sk=
|
||||
github.com/onsi/gomega v1.38.0 h1:c/WX+w8SLAinvuKKQFh77WEucCnPk4j2OTUr7lt7BeY=
|
||||
github.com/onsi/gomega v1.38.0/go.mod h1:OcXcwId0b9QsE7Y49u+BTrL4IdKOBOKnD6VQNTJEB6o=
|
||||
github.com/onsi/ginkgo/v2 v2.25.3 h1:Ty8+Yi/ayDAGtk4XxmmfUy4GabvM+MegeB4cDLRi6nw=
|
||||
github.com/onsi/ginkgo/v2 v2.25.3/go.mod h1:43uiyQC4Ed2tkOzLsEYm7hnrb7UJTWHYNsuy3bG/snE=
|
||||
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
|
||||
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
|
||||
github.com/opencontainers/cgroups v0.0.5 h1:DRITAqcOnY0uSBzIpt1RYWLjh5DPDiqUs4fY6Y0ktls=
|
||||
github.com/opencontainers/cgroups v0.0.5/go.mod h1:oWVzJsKK0gG9SCRBfTpnn16WcGEqDI8PAcpMGbqWxcs=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
|
@ -228,8 +228,8 @@ github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/
|
|||
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
|
||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
|
||||
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
|
@ -240,16 +240,16 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN
|
|||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
|
||||
github.com/sebdah/goldie/v2 v2.5.5 h1:rx1mwF95RxZ3/83sdS4Yp7t2C5TCokvWP4TBRbAyEWY=
|
||||
github.com/sebdah/goldie/v2 v2.5.5/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
|
||||
github.com/sebdah/goldie/v2 v2.7.1 h1:PkBHymaYdtvEkZV7TmyqKxdmn5/Vcj+8TpATWZjnG5E=
|
||||
github.com/sebdah/goldie/v2 v2.7.1/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
|
||||
github.com/seccomp/libseccomp-golang v0.11.1 h1:wuk4ZjSx6kyQII4rj6G6fvVzRHQaSiPvccJazDagu4g=
|
||||
github.com/seccomp/libseccomp-golang v0.11.1/go.mod h1:5m1Lk8E9OwgZTTVz4bBOer7JuazaBa+xTkM895tDiWc=
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.9.1 h1:nZZaNz4DiERIQguNy0cL5qTdn9lR8XKHf4RUyG1Sx3g=
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.9.1/go.mod h1:np53YzT0zXGMv6x4iEWc9Z59uR+x+ndLwCLqPYpLXVU=
|
||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/sigstore/fulcio v1.6.6 h1:XaMYX6TNT+8n7Npe8D94nyZ7/ERjEsNGFC+REdi/wzw=
|
||||
github.com/sigstore/fulcio v1.6.6/go.mod h1:BhQ22lwaebDgIxVBEYOOqLRcN5+xOV+C9bh/GUXRhOk=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/sigstore/fulcio v1.7.1 h1:RcoW20Nz49IGeZyu3y9QYhyyV3ZKQ85T+FXPKkvE+aQ=
|
||||
github.com/sigstore/fulcio v1.7.1/go.mod h1:7lYY+hsd8Dt+IvKQRC+KEhWpCZ/GlmNvwIa5JhypMS8=
|
||||
github.com/sigstore/protobuf-specs v0.4.1 h1:5SsMqZbdkcO/DNHudaxuCUEjj6x29tS2Xby1BxGU7Zc=
|
||||
github.com/sigstore/protobuf-specs v0.4.1/go.mod h1:+gXR+38nIa2oEupqDdzg4qSBT0Os+sP7oYv6alWewWc=
|
||||
github.com/sigstore/sigstore v1.9.5 h1:Wm1LT9yF4LhQdEMy5A2JeGRHTrAWGjT3ubE5JUSrGVU=
|
||||
|
@ -270,8 +270,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/sylabs/sif/v2 v2.21.1 h1:GZ0b5//AFAqJEChd8wHV/uSKx/l1iuGYwjR8nx+4wPI=
|
||||
github.com/sylabs/sif/v2 v2.21.1/go.mod h1:YoqEGQnb5x/ItV653bawXHZJOXQaEWpGwHsSD3YePJI=
|
||||
github.com/sylabs/sif/v2 v2.22.0 h1:Y+xXufp4RdgZe02SR3nWEg7S6q4tPWN237WHYzkDSKA=
|
||||
github.com/sylabs/sif/v2 v2.22.0/go.mod h1:W1XhWTmG1KcG7j5a3KSYdMcUIFvbs240w/MMVW627hs=
|
||||
github.com/tchap/go-patricia/v2 v2.3.3 h1:xfNEsODumaEcCcY3gI0hYPZ/PcpVv5ju6RMAhgwZDDc=
|
||||
github.com/tchap/go-patricia/v2 v2.3.3/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
|
||||
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0=
|
||||
|
@ -299,36 +299,36 @@ go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
|
|||
go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
|
||||
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
|
||||
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 h1:1fTNlAIJZGWLP5FVu0fikVry1IsiUnXjf7QFvoNN3Xw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0/go.mod h1:zjPK58DtkqQFn+YUMbx0M2XV3QgKU0gS9LeGohREyK4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0 h1:xJ2qHD0C1BeYVTLLR9sX12+Qb95kfeD/byKj6Ky1pXg=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0/go.mod h1:u5BF1xyjstDowA1R5QAO9JHzqK+ublenEW/dyqTjBVk=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
|
||||
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
|
||||
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
|
||||
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
|
||||
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
|
||||
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
|
||||
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118 h1:irrh47HeVh6YzKd/sDQPxeu4Tr1Cp3HfQt2l9icrDsg=
|
||||
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118/go.mod h1:h7a5Zne6vSHzdYC8m4w+AOtuPGTne1852qc6YgLAwMU=
|
||||
go.podman.io/image/v5 v5.36.1-0.20250820085751-a13b38f45723 h1:FMz5EojZwmYiWQuEs5fu7Iw870k293OPLmBxOsVBzDk=
|
||||
go.podman.io/image/v5 v5.36.1-0.20250820085751-a13b38f45723/go.mod h1:IHbL4OPh79ir/Au4i3Z/U1Vcumvw3Lu0dgZjwLaydL0=
|
||||
go.podman.io/storage v1.59.1-0.20250820085751-a13b38f45723 h1:Yvy8mEjlmlocJETNBKr1PV3BuwhNEKiRj8mFUPjsHWA=
|
||||
go.podman.io/storage v1.59.1-0.20250820085751-a13b38f45723/go.mod h1:NFVh1MHgSeRrphOpLEeJsWV9F5AqT7ZxbYBFRLe0uJM=
|
||||
go.podman.io/common v0.65.1-0.20250916163606-92222dcd3da4 h1:YjBqTOxz4cqfpifcd71VoBl1FTQL2U2La5NgMqmRRqU=
|
||||
go.podman.io/common v0.65.1-0.20250916163606-92222dcd3da4/go.mod h1:DyOdwtkwzYA8lE0TueJnxRju4Lmsrx6ZAC/ATAkYYck=
|
||||
go.podman.io/image/v5 v5.37.1-0.20250916163606-92222dcd3da4 h1:hfc3lZaxi6KGnWN3IusIaCkcMPR4rTR+vWZzakeD1EA=
|
||||
go.podman.io/image/v5 v5.37.1-0.20250916163606-92222dcd3da4/go.mod h1:cGWb3IyBziJGxhFikTOlt9Ap+zo6s3rz9Qd1rbzqs4s=
|
||||
go.podman.io/storage v1.60.1-0.20250916163606-92222dcd3da4 h1:jo0PSKh6muU7rmhXXqOV9aK+HrA8koqs47KhBsZf6LY=
|
||||
go.podman.io/storage v1.60.1-0.20250916163606-92222dcd3da4/go.mod h1:AeZXAN8Qu1gTlAEHIc6mVhxk+61oMSM3K3iLx5UAQWE=
|
||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
|
||||
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
|
||||
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
|
||||
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
|
@ -431,14 +431,14 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:jbe3Bkdp+Dh2IrslsFCklNhweNTBgSYanP1UXhJDhKg=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 h1:iK2jbkWL86DXjEx0qiHcRE9dE4/Ahua5k6V8OWFb//c=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e h1:UdXH7Kzbj+Vzastr5nVfccbmFsmYNygVLSPk1pEfDoY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e/go.mod h1:085qFyf2+XaZlRdCgKNCIZ3afY2p4HHZdoIRpId8F4A=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8=
|
||||
google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
|
||||
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/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=
|
||||
|
|
|
@ -17,6 +17,7 @@ package name
|
|||
import (
|
||||
// nolint: depguard
|
||||
_ "crypto/sha256" // Recommended by go-digest.
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
|
@ -32,8 +33,11 @@ type Digest struct {
|
|||
original string
|
||||
}
|
||||
|
||||
// Ensure Digest implements Reference
|
||||
var _ Reference = (*Digest)(nil)
|
||||
var _ encoding.TextMarshaler = (*Digest)(nil)
|
||||
var _ encoding.TextUnmarshaler = (*Digest)(nil)
|
||||
var _ json.Marshaler = (*Digest)(nil)
|
||||
var _ json.Unmarshaler = (*Digest)(nil)
|
||||
|
||||
// Context implements Reference.
|
||||
func (d Digest) Context() Repository {
|
||||
|
@ -79,6 +83,21 @@ func (d *Digest) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalText formats the digest into a string for text serialization.
|
||||
func (d Digest) MarshalText() ([]byte, error) {
|
||||
return []byte(d.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText parses a text string into a Digest.
|
||||
func (d *Digest) UnmarshalText(data []byte) error {
|
||||
n, err := NewDigest(string(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*d = n
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDigest returns a new Digest representing the given name.
|
||||
func NewDigest(name string, opts ...Option) (Digest, error) {
|
||||
// Split on "@"
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
package name
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"net/url"
|
||||
"path"
|
||||
|
@ -37,6 +39,11 @@ type Registry struct {
|
|||
registry string
|
||||
}
|
||||
|
||||
var _ encoding.TextMarshaler = (*Registry)(nil)
|
||||
var _ encoding.TextUnmarshaler = (*Registry)(nil)
|
||||
var _ json.Marshaler = (*Registry)(nil)
|
||||
var _ json.Unmarshaler = (*Registry)(nil)
|
||||
|
||||
// RegistryStr returns the registry component of the Registry.
|
||||
func (r Registry) RegistryStr() string {
|
||||
return r.registry
|
||||
|
@ -140,3 +147,33 @@ func NewInsecureRegistry(name string, opts ...Option) (Registry, error) {
|
|||
opts = append(opts, Insecure)
|
||||
return NewRegistry(name, opts...)
|
||||
}
|
||||
|
||||
// MarshalJSON formats the Registry into a string for JSON serialization.
|
||||
func (r Registry) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) }
|
||||
|
||||
// UnmarshalJSON parses a JSON string into a Registry.
|
||||
func (r *Registry) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := NewRegistry(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*r = n
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText formats the registry into a string for text serialization.
|
||||
func (r Registry) MarshalText() ([]byte, error) { return []byte(r.String()), nil }
|
||||
|
||||
// UnmarshalText parses a text string into a Registry.
|
||||
func (r *Registry) UnmarshalText(data []byte) error {
|
||||
n, err := NewRegistry(string(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*r = n
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
package name
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
@ -31,6 +33,11 @@ type Repository struct {
|
|||
repository string
|
||||
}
|
||||
|
||||
var _ encoding.TextMarshaler = (*Repository)(nil)
|
||||
var _ encoding.TextUnmarshaler = (*Repository)(nil)
|
||||
var _ json.Marshaler = (*Repository)(nil)
|
||||
var _ json.Unmarshaler = (*Repository)(nil)
|
||||
|
||||
// See https://docs.docker.com/docker-hub/official_repos
|
||||
func hasImplicitNamespace(repo string, reg Registry) bool {
|
||||
return !strings.ContainsRune(repo, '/') && reg.RegistryStr() == DefaultRegistry
|
||||
|
@ -119,3 +126,33 @@ func (r Repository) Digest(identifier string) Digest {
|
|||
d.original = d.Name()
|
||||
return d
|
||||
}
|
||||
|
||||
// MarshalJSON formats the Repository into a string for JSON serialization.
|
||||
func (r Repository) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) }
|
||||
|
||||
// UnmarshalJSON parses a JSON string into a Repository.
|
||||
func (r *Repository) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := NewRepository(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*r = n
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText formats the repository name into a string for text serialization.
|
||||
func (r Repository) MarshalText() ([]byte, error) { return []byte(r.String()), nil }
|
||||
|
||||
// UnmarshalText parses a text string into a Repository.
|
||||
func (r *Repository) UnmarshalText(data []byte) error {
|
||||
n, err := NewRepository(string(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*r = n
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
package name
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -31,8 +33,11 @@ type Tag struct {
|
|||
original string
|
||||
}
|
||||
|
||||
// Ensure Tag implements Reference
|
||||
var _ Reference = (*Tag)(nil)
|
||||
var _ encoding.TextMarshaler = (*Tag)(nil)
|
||||
var _ encoding.TextUnmarshaler = (*Tag)(nil)
|
||||
var _ json.Marshaler = (*Tag)(nil)
|
||||
var _ json.Unmarshaler = (*Tag)(nil)
|
||||
|
||||
// Context implements Reference.
|
||||
func (t Tag) Context() Repository {
|
||||
|
@ -80,6 +85,9 @@ func NewTag(name string, opts ...Option) (Tag, error) {
|
|||
if len(parts) > 1 && !strings.Contains(parts[len(parts)-1], regRepoDelimiter) {
|
||||
base = strings.Join(parts[:len(parts)-1], tagDelim)
|
||||
tag = parts[len(parts)-1]
|
||||
if tag == "" {
|
||||
return Tag{}, newErrBadName("%s must specify a tag name after the colon", name)
|
||||
}
|
||||
}
|
||||
|
||||
// We don't require a tag, but if we get one check it's valid,
|
||||
|
@ -106,3 +114,33 @@ func NewTag(name string, opts ...Option) (Tag, error) {
|
|||
original: name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// MarshalJSON formats the Tag into a string for JSON serialization.
|
||||
func (t Tag) MarshalJSON() ([]byte, error) { return json.Marshal(t.String()) }
|
||||
|
||||
// UnmarshalJSON parses a JSON string into a Tag.
|
||||
func (t *Tag) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := NewTag(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = n
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText formats the tag into a string for text serialization.
|
||||
func (t Tag) MarshalText() ([]byte, error) { return []byte(t.String()), nil }
|
||||
|
||||
// UnmarshalText parses a text string into a Tag.
|
||||
func (t *Tag) UnmarshalText(data []byte) error {
|
||||
n, err := NewTag(string(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = n
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ package v1
|
|||
|
||||
import (
|
||||
"crypto"
|
||||
"encoding"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -34,6 +34,11 @@ type Hash struct {
|
|||
Hex string
|
||||
}
|
||||
|
||||
var _ encoding.TextMarshaler = (*Hash)(nil)
|
||||
var _ encoding.TextUnmarshaler = (*Hash)(nil)
|
||||
var _ json.Marshaler = (*Hash)(nil)
|
||||
var _ json.Unmarshaler = (*Hash)(nil)
|
||||
|
||||
// String reverses NewHash returning the string-form of the hash.
|
||||
func (h Hash) String() string {
|
||||
return fmt.Sprintf("%s:%s", h.Algorithm, h.Hex)
|
||||
|
@ -49,14 +54,12 @@ func NewHash(s string) (Hash, error) {
|
|||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler
|
||||
func (h Hash) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(h.String())
|
||||
}
|
||||
func (h Hash) MarshalJSON() ([]byte, error) { return json.Marshal(h.String()) }
|
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler
|
||||
func (h *Hash) UnmarshalJSON(data []byte) error {
|
||||
s, err := strconv.Unquote(string(data))
|
||||
if err != nil {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
return h.parse(s)
|
||||
|
@ -64,15 +67,11 @@ func (h *Hash) UnmarshalJSON(data []byte) error {
|
|||
|
||||
// MarshalText implements encoding.TextMarshaler. This is required to use
|
||||
// v1.Hash as a key in a map when marshalling JSON.
|
||||
func (h Hash) MarshalText() (text []byte, err error) {
|
||||
return []byte(h.String()), nil
|
||||
}
|
||||
func (h Hash) MarshalText() ([]byte, error) { return []byte(h.String()), nil }
|
||||
|
||||
// UnmarshalText implements encoding.TextUnmarshaler. This is required to use
|
||||
// v1.Hash as a key in a map when unmarshalling JSON.
|
||||
func (h *Hash) UnmarshalText(text []byte) error {
|
||||
return h.parse(string(text))
|
||||
}
|
||||
func (h *Hash) UnmarshalText(text []byte) error { return h.parse(string(text)) }
|
||||
|
||||
// Hasher returns a hash.Hash for the named algorithm (e.g. "sha256")
|
||||
func Hasher(name string) (hash.Hash, error) {
|
||||
|
|
|
@ -176,6 +176,10 @@ func WithMessageEvents(events ...event) Option {
|
|||
|
||||
// WithSpanNameFormatter takes a function that will be called on every
|
||||
// request and the returned string will become the Span Name.
|
||||
//
|
||||
// When using [http.ServeMux] (or any middleware that sets the Pattern of [http.Request]),
|
||||
// the span name formatter will run twice. Once when the span is created, and
|
||||
// second time after the middleware, so the pattern can be used.
|
||||
func WithSpanNameFormatter(f func(operation string, r *http.Request) string) Option {
|
||||
return optionFunc(func(c *config) {
|
||||
c.SpanNameFormatter = f
|
||||
|
|
9
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go
generated
vendored
9
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go
generated
vendored
|
@ -98,7 +98,7 @@ func (h *middleware) serveHTTP(w http.ResponseWriter, r *http.Request, next http
|
|||
|
||||
ctx := h.propagators.Extract(r.Context(), propagation.HeaderCarrier(r.Header))
|
||||
opts := []trace.SpanStartOption{
|
||||
trace.WithAttributes(h.semconv.RequestTraceAttrs(h.server, r)...),
|
||||
trace.WithAttributes(h.semconv.RequestTraceAttrs(h.server, r, semconv.RequestTraceAttrsOpts{})...),
|
||||
}
|
||||
|
||||
opts = append(opts, h.spanStartOptions...)
|
||||
|
@ -176,7 +176,12 @@ func (h *middleware) serveHTTP(w http.ResponseWriter, r *http.Request, next http
|
|||
ctx = ContextWithLabeler(ctx, labeler)
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
r = r.WithContext(ctx)
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
if r.Pattern != "" {
|
||||
span.SetName(h.spanNameFormatter(h.operation, r))
|
||||
}
|
||||
|
||||
statusCode := rww.StatusCode()
|
||||
bytesWritten := rww.BytesWritten()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/request/body_wrapper.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package request provides types and functionality to handle HTTP request
|
||||
// handling.
|
||||
package request // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request"
|
||||
|
||||
import (
|
||||
|
@ -56,7 +58,7 @@ func (w *BodyWrapper) updateReadData(n int64, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Closes closes the io.ReadCloser.
|
||||
// Close closes the io.ReadCloser.
|
||||
func (w *BodyWrapper) Close() error {
|
||||
return w.ReadCloser.Close()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/request/resp_writer_wrapper.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
|
@ -105,7 +105,7 @@ func (w *RespWriterWrapper) BytesWritten() int64 {
|
|||
return w.written
|
||||
}
|
||||
|
||||
// BytesWritten returns the HTTP status code that was sent.
|
||||
// StatusCode returns the HTTP status code that was sent.
|
||||
func (w *RespWriterWrapper) StatusCode() int {
|
||||
w.mu.RLock()
|
||||
defer w.mu.RUnlock()
|
||||
|
|
112
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv/env.go
generated
vendored
112
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv/env.go
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/semconv/env.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
// OTelSemConvStabilityOptIn is an environment variable.
|
||||
// That can be set to "old" or "http/dup" to opt into the new HTTP semantic conventions.
|
||||
// That can be set to "http/dup" to keep getting the old HTTP semantic conventions.
|
||||
const OTelSemConvStabilityOptIn = "OTEL_SEMCONV_STABILITY_OPT_IN"
|
||||
|
||||
type ResponseTelemetry struct {
|
||||
|
@ -61,19 +61,23 @@ type HTTPServer struct {
|
|||
//
|
||||
// If the primary server name is not known, server should be an empty string.
|
||||
// The req Host will be used to determine the server instead.
|
||||
func (s HTTPServer) RequestTraceAttrs(server string, req *http.Request) []attribute.KeyValue {
|
||||
func (s HTTPServer) RequestTraceAttrs(server string, req *http.Request, opts RequestTraceAttrsOpts) []attribute.KeyValue {
|
||||
attrs := CurrentHTTPServer{}.RequestTraceAttrs(server, req, opts)
|
||||
if s.duplicate {
|
||||
return append(OldHTTPServer{}.RequestTraceAttrs(server, req), CurrentHTTPServer{}.RequestTraceAttrs(server, req)...)
|
||||
return OldHTTPServer{}.RequestTraceAttrs(server, req, attrs)
|
||||
}
|
||||
return OldHTTPServer{}.RequestTraceAttrs(server, req)
|
||||
return attrs
|
||||
}
|
||||
|
||||
func (s HTTPServer) NetworkTransportAttr(network string) []attribute.KeyValue {
|
||||
if s.duplicate {
|
||||
return append([]attribute.KeyValue{OldHTTPServer{}.NetworkTransportAttr(network)}, CurrentHTTPServer{}.NetworkTransportAttr(network))
|
||||
return []attribute.KeyValue{
|
||||
OldHTTPServer{}.NetworkTransportAttr(network),
|
||||
CurrentHTTPServer{}.NetworkTransportAttr(network),
|
||||
}
|
||||
}
|
||||
return []attribute.KeyValue{
|
||||
OldHTTPServer{}.NetworkTransportAttr(network),
|
||||
CurrentHTTPServer{}.NetworkTransportAttr(network),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,15 +85,16 @@ func (s HTTPServer) NetworkTransportAttr(network string) []attribute.KeyValue {
|
|||
//
|
||||
// If any of the fields in the ResponseTelemetry are not set the attribute will be omitted.
|
||||
func (s HTTPServer) ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue {
|
||||
attrs := CurrentHTTPServer{}.ResponseTraceAttrs(resp)
|
||||
if s.duplicate {
|
||||
return append(OldHTTPServer{}.ResponseTraceAttrs(resp), CurrentHTTPServer{}.ResponseTraceAttrs(resp)...)
|
||||
return OldHTTPServer{}.ResponseTraceAttrs(resp, attrs)
|
||||
}
|
||||
return OldHTTPServer{}.ResponseTraceAttrs(resp)
|
||||
return attrs
|
||||
}
|
||||
|
||||
// Route returns the attribute for the route.
|
||||
func (s HTTPServer) Route(route string) attribute.KeyValue {
|
||||
return OldHTTPServer{}.Route(route)
|
||||
return CurrentHTTPServer{}.Route(route)
|
||||
}
|
||||
|
||||
// Status returns a span status code and message for an HTTP status code
|
||||
|
@ -121,6 +126,8 @@ type MetricAttributes struct {
|
|||
|
||||
type MetricData struct {
|
||||
RequestSize int64
|
||||
|
||||
// The request duration, in milliseconds
|
||||
ElapsedTime float64
|
||||
}
|
||||
|
||||
|
@ -139,7 +146,19 @@ var (
|
|||
)
|
||||
|
||||
func (s HTTPServer) RecordMetrics(ctx context.Context, md ServerMetricData) {
|
||||
if s.requestBytesCounter != nil && s.responseBytesCounter != nil && s.serverLatencyMeasure != nil {
|
||||
if s.requestDurationHistogram != nil && s.requestBodySizeHistogram != nil && s.responseBodySizeHistogram != nil {
|
||||
attributes := CurrentHTTPServer{}.MetricAttributes(md.ServerName, md.Req, md.StatusCode, md.AdditionalAttributes)
|
||||
o := metric.WithAttributeSet(attribute.NewSet(attributes...))
|
||||
recordOpts := metricRecordOptionPool.Get().(*[]metric.RecordOption)
|
||||
*recordOpts = append(*recordOpts, o)
|
||||
s.requestBodySizeHistogram.Record(ctx, md.RequestSize, *recordOpts...)
|
||||
s.responseBodySizeHistogram.Record(ctx, md.ResponseSize, *recordOpts...)
|
||||
s.requestDurationHistogram.Record(ctx, md.ElapsedTime/1000.0, o)
|
||||
*recordOpts = (*recordOpts)[:0]
|
||||
metricRecordOptionPool.Put(recordOpts)
|
||||
}
|
||||
|
||||
if s.duplicate && s.requestBytesCounter != nil && s.responseBytesCounter != nil && s.serverLatencyMeasure != nil {
|
||||
attributes := OldHTTPServer{}.MetricAttributes(md.ServerName, md.Req, md.StatusCode, md.AdditionalAttributes)
|
||||
o := metric.WithAttributeSet(attribute.NewSet(attributes...))
|
||||
addOpts := metricAddOptionPool.Get().(*[]metric.AddOption)
|
||||
|
@ -150,29 +169,28 @@ func (s HTTPServer) RecordMetrics(ctx context.Context, md ServerMetricData) {
|
|||
*addOpts = (*addOpts)[:0]
|
||||
metricAddOptionPool.Put(addOpts)
|
||||
}
|
||||
}
|
||||
|
||||
if s.duplicate && s.requestDurationHistogram != nil && s.requestBodySizeHistogram != nil && s.responseBodySizeHistogram != nil {
|
||||
attributes := CurrentHTTPServer{}.MetricAttributes(md.ServerName, md.Req, md.StatusCode, md.AdditionalAttributes)
|
||||
o := metric.WithAttributeSet(attribute.NewSet(attributes...))
|
||||
recordOpts := metricRecordOptionPool.Get().(*[]metric.RecordOption)
|
||||
*recordOpts = append(*recordOpts, o)
|
||||
s.requestBodySizeHistogram.Record(ctx, md.RequestSize, *recordOpts...)
|
||||
s.responseBodySizeHistogram.Record(ctx, md.ResponseSize, *recordOpts...)
|
||||
s.requestDurationHistogram.Record(ctx, md.ElapsedTime, o)
|
||||
*recordOpts = (*recordOpts)[:0]
|
||||
metricRecordOptionPool.Put(recordOpts)
|
||||
// hasOptIn returns true if the comma-separated version string contains the
|
||||
// exact optIn value.
|
||||
func hasOptIn(version, optIn string) bool {
|
||||
for _, v := range strings.Split(version, ",") {
|
||||
if strings.TrimSpace(v) == optIn {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewHTTPServer(meter metric.Meter) HTTPServer {
|
||||
env := strings.ToLower(os.Getenv(OTelSemConvStabilityOptIn))
|
||||
duplicate := env == "http/dup"
|
||||
duplicate := hasOptIn(env, "http/dup")
|
||||
server := HTTPServer{
|
||||
duplicate: duplicate,
|
||||
}
|
||||
server.requestBytesCounter, server.responseBytesCounter, server.serverLatencyMeasure = OldHTTPServer{}.createMeasures(meter)
|
||||
server.requestBodySizeHistogram, server.responseBodySizeHistogram, server.requestDurationHistogram = CurrentHTTPServer{}.createMeasures(meter)
|
||||
if duplicate {
|
||||
server.requestBodySizeHistogram, server.responseBodySizeHistogram, server.requestDurationHistogram = CurrentHTTPServer{}.createMeasures(meter)
|
||||
server.requestBytesCounter, server.responseBytesCounter, server.serverLatencyMeasure = OldHTTPServer{}.createMeasures(meter)
|
||||
}
|
||||
return server
|
||||
}
|
||||
|
@ -192,13 +210,13 @@ type HTTPClient struct {
|
|||
|
||||
func NewHTTPClient(meter metric.Meter) HTTPClient {
|
||||
env := strings.ToLower(os.Getenv(OTelSemConvStabilityOptIn))
|
||||
duplicate := env == "http/dup"
|
||||
duplicate := hasOptIn(env, "http/dup")
|
||||
client := HTTPClient{
|
||||
duplicate: duplicate,
|
||||
}
|
||||
client.requestBytesCounter, client.responseBytesCounter, client.latencyMeasure = OldHTTPClient{}.createMeasures(meter)
|
||||
client.requestBodySize, client.requestDuration = CurrentHTTPClient{}.createMeasures(meter)
|
||||
if duplicate {
|
||||
client.requestBodySize, client.requestDuration = CurrentHTTPClient{}.createMeasures(meter)
|
||||
client.requestBytesCounter, client.responseBytesCounter, client.latencyMeasure = OldHTTPClient{}.createMeasures(meter)
|
||||
}
|
||||
|
||||
return client
|
||||
|
@ -206,19 +224,20 @@ func NewHTTPClient(meter metric.Meter) HTTPClient {
|
|||
|
||||
// RequestTraceAttrs returns attributes for an HTTP request made by a client.
|
||||
func (c HTTPClient) RequestTraceAttrs(req *http.Request) []attribute.KeyValue {
|
||||
attrs := CurrentHTTPClient{}.RequestTraceAttrs(req)
|
||||
if c.duplicate {
|
||||
return append(OldHTTPClient{}.RequestTraceAttrs(req), CurrentHTTPClient{}.RequestTraceAttrs(req)...)
|
||||
return OldHTTPClient{}.RequestTraceAttrs(req, attrs)
|
||||
}
|
||||
return OldHTTPClient{}.RequestTraceAttrs(req)
|
||||
return attrs
|
||||
}
|
||||
|
||||
// ResponseTraceAttrs returns metric attributes for an HTTP request made by a client.
|
||||
func (c HTTPClient) ResponseTraceAttrs(resp *http.Response) []attribute.KeyValue {
|
||||
attrs := CurrentHTTPClient{}.ResponseTraceAttrs(resp)
|
||||
if c.duplicate {
|
||||
return append(OldHTTPClient{}.ResponseTraceAttrs(resp), CurrentHTTPClient{}.ResponseTraceAttrs(resp)...)
|
||||
return OldHTTPClient{}.ResponseTraceAttrs(resp, attrs)
|
||||
}
|
||||
|
||||
return OldHTTPClient{}.ResponseTraceAttrs(resp)
|
||||
return attrs
|
||||
}
|
||||
|
||||
func (c HTTPClient) Status(code int) (codes.Code, string) {
|
||||
|
@ -232,11 +251,7 @@ func (c HTTPClient) Status(code int) (codes.Code, string) {
|
|||
}
|
||||
|
||||
func (c HTTPClient) ErrorType(err error) attribute.KeyValue {
|
||||
if c.duplicate {
|
||||
return CurrentHTTPClient{}.ErrorType(err)
|
||||
}
|
||||
|
||||
return attribute.KeyValue{}
|
||||
return CurrentHTTPClient{}.ErrorType(err)
|
||||
}
|
||||
|
||||
type MetricOpts struct {
|
||||
|
@ -255,17 +270,17 @@ func (o MetricOpts) AddOptions() metric.AddOption {
|
|||
func (c HTTPClient) MetricOptions(ma MetricAttributes) map[string]MetricOpts {
|
||||
opts := map[string]MetricOpts{}
|
||||
|
||||
attributes := OldHTTPClient{}.MetricAttributes(ma.Req, ma.StatusCode, ma.AdditionalAttributes)
|
||||
attributes := CurrentHTTPClient{}.MetricAttributes(ma.Req, ma.StatusCode, ma.AdditionalAttributes)
|
||||
set := metric.WithAttributeSet(attribute.NewSet(attributes...))
|
||||
opts["old"] = MetricOpts{
|
||||
opts["new"] = MetricOpts{
|
||||
measurement: set,
|
||||
addOptions: set,
|
||||
}
|
||||
|
||||
if c.duplicate {
|
||||
attributes := CurrentHTTPClient{}.MetricAttributes(ma.Req, ma.StatusCode, ma.AdditionalAttributes)
|
||||
attributes := OldHTTPClient{}.MetricAttributes(ma.Req, ma.StatusCode, ma.AdditionalAttributes)
|
||||
set := metric.WithAttributeSet(attribute.NewSet(attributes...))
|
||||
opts["new"] = MetricOpts{
|
||||
opts["old"] = MetricOpts{
|
||||
measurement: set,
|
||||
addOptions: set,
|
||||
}
|
||||
|
@ -275,17 +290,17 @@ func (c HTTPClient) MetricOptions(ma MetricAttributes) map[string]MetricOpts {
|
|||
}
|
||||
|
||||
func (s HTTPClient) RecordMetrics(ctx context.Context, md MetricData, opts map[string]MetricOpts) {
|
||||
if s.requestBytesCounter == nil || s.latencyMeasure == nil {
|
||||
if s.requestBodySize == nil || s.requestDuration == nil {
|
||||
// This will happen if an HTTPClient{} is used instead of NewHTTPClient().
|
||||
return
|
||||
}
|
||||
|
||||
s.requestBytesCounter.Add(ctx, md.RequestSize, opts["old"].AddOptions())
|
||||
s.latencyMeasure.Record(ctx, md.ElapsedTime, opts["old"].MeasurementOption())
|
||||
s.requestBodySize.Record(ctx, md.RequestSize, opts["new"].MeasurementOption())
|
||||
s.requestDuration.Record(ctx, md.ElapsedTime/1000, opts["new"].MeasurementOption())
|
||||
|
||||
if s.duplicate {
|
||||
s.requestBodySize.Record(ctx, md.RequestSize, opts["new"].MeasurementOption())
|
||||
s.requestDuration.Record(ctx, md.ElapsedTime, opts["new"].MeasurementOption())
|
||||
s.requestBytesCounter.Add(ctx, md.RequestSize, opts["old"].AddOptions())
|
||||
s.latencyMeasure.Record(ctx, md.ElapsedTime, opts["old"].MeasurementOption())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,9 +314,10 @@ func (s HTTPClient) RecordResponseSize(ctx context.Context, responseData int64,
|
|||
}
|
||||
|
||||
func (s HTTPClient) TraceAttributes(host string) []attribute.KeyValue {
|
||||
attrs := CurrentHTTPClient{}.TraceAttributes(host)
|
||||
if s.duplicate {
|
||||
return append(OldHTTPClient{}.TraceAttributes(host), CurrentHTTPClient{}.TraceAttributes(host)...)
|
||||
return OldHTTPClient{}.TraceAttributes(host, attrs)
|
||||
}
|
||||
|
||||
return OldHTTPClient{}.TraceAttributes(host)
|
||||
return attrs
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/semconv/httpconv.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package semconv provides OpenTelemetry semantic convention types and
|
||||
// functionality.
|
||||
package semconv // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv"
|
||||
|
||||
import (
|
||||
|
@ -20,9 +22,14 @@ import (
|
|||
semconvNew "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
)
|
||||
|
||||
type RequestTraceAttrsOpts struct {
|
||||
// If set, this is used as value for the "http.client_ip" attribute.
|
||||
HTTPClientIP string
|
||||
}
|
||||
|
||||
type CurrentHTTPServer struct{}
|
||||
|
||||
// TraceRequest returns trace attributes for an HTTP request received by a
|
||||
// RequestTraceAttrs returns trace attributes for an HTTP request received by a
|
||||
// server.
|
||||
//
|
||||
// The server must be the primary server name if it is known. For example this
|
||||
|
@ -38,7 +45,7 @@ type CurrentHTTPServer struct{}
|
|||
//
|
||||
// If the primary server name is not known, server should be an empty string.
|
||||
// The req Host will be used to determine the server instead.
|
||||
func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) []attribute.KeyValue {
|
||||
func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request, opts RequestTraceAttrsOpts) []attribute.KeyValue {
|
||||
count := 3 // ServerAddress, Method, Scheme
|
||||
|
||||
var host string
|
||||
|
@ -65,7 +72,8 @@ func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) [
|
|||
|
||||
scheme := n.scheme(req.TLS != nil)
|
||||
|
||||
if peer, peerPort := SplitHostPort(req.RemoteAddr); peer != "" {
|
||||
peer, peerPort := SplitHostPort(req.RemoteAddr)
|
||||
if peer != "" {
|
||||
// The Go HTTP server sets RemoteAddr to "IP:port", this will not be a
|
||||
// file-path that would be interpreted with a sock family.
|
||||
count++
|
||||
|
@ -79,7 +87,17 @@ func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) [
|
|||
count++
|
||||
}
|
||||
|
||||
clientIP := serverClientIP(req.Header.Get("X-Forwarded-For"))
|
||||
// For client IP, use, in order:
|
||||
// 1. The value passed in the options
|
||||
// 2. The value in the X-Forwarded-For header
|
||||
// 3. The peer address
|
||||
clientIP := opts.HTTPClientIP
|
||||
if clientIP == "" {
|
||||
clientIP = serverClientIP(req.Header.Get("X-Forwarded-For"))
|
||||
if clientIP == "" {
|
||||
clientIP = peer
|
||||
}
|
||||
}
|
||||
if clientIP != "" {
|
||||
count++
|
||||
}
|
||||
|
@ -96,6 +114,11 @@ func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) [
|
|||
count++
|
||||
}
|
||||
|
||||
route := httpRoute(req.Pattern)
|
||||
if route != "" {
|
||||
count++
|
||||
}
|
||||
|
||||
attrs := make([]attribute.KeyValue, 0, count)
|
||||
attrs = append(attrs,
|
||||
semconvNew.ServerAddress(host),
|
||||
|
@ -119,7 +142,7 @@ func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) [
|
|||
}
|
||||
}
|
||||
|
||||
if useragent := req.UserAgent(); useragent != "" {
|
||||
if useragent != "" {
|
||||
attrs = append(attrs, semconvNew.UserAgentOriginal(useragent))
|
||||
}
|
||||
|
||||
|
@ -138,10 +161,14 @@ func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) [
|
|||
attrs = append(attrs, semconvNew.NetworkProtocolVersion(protoVersion))
|
||||
}
|
||||
|
||||
if route != "" {
|
||||
attrs = append(attrs, n.Route(route))
|
||||
}
|
||||
|
||||
return attrs
|
||||
}
|
||||
|
||||
func (o CurrentHTTPServer) NetworkTransportAttr(network string) attribute.KeyValue {
|
||||
func (n CurrentHTTPServer) NetworkTransportAttr(network string) attribute.KeyValue {
|
||||
switch network {
|
||||
case "tcp", "tcp4", "tcp6":
|
||||
return semconvNew.NetworkTransportTCP
|
||||
|
@ -176,9 +203,11 @@ func (n CurrentHTTPServer) scheme(https bool) attribute.KeyValue { // nolint:rev
|
|||
return semconvNew.URLScheme("http")
|
||||
}
|
||||
|
||||
// TraceResponse returns trace attributes for telemetry from an HTTP response.
|
||||
// ResponseTraceAttrs returns trace attributes for telemetry from an HTTP
|
||||
// response.
|
||||
//
|
||||
// If any of the fields in the ResponseTelemetry are not set the attribute will be omitted.
|
||||
// If any of the fields in the ResponseTelemetry are not set the attribute will
|
||||
// be omitted.
|
||||
func (n CurrentHTTPServer) ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue {
|
||||
var count int
|
||||
|
||||
|
@ -241,6 +270,7 @@ func (n CurrentHTTPServer) createMeasures(meter metric.Meter) (metric.Int64Histo
|
|||
semconvNew.HTTPServerRequestDurationName,
|
||||
metric.WithUnit(semconvNew.HTTPServerRequestDurationUnit),
|
||||
metric.WithDescription(semconvNew.HTTPServerRequestDurationDescription),
|
||||
metric.WithExplicitBucketBoundaries(0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10),
|
||||
)
|
||||
handleErr(err)
|
||||
|
||||
|
@ -459,6 +489,7 @@ func (n CurrentHTTPClient) createMeasures(meter metric.Meter) (metric.Int64Histo
|
|||
semconvNew.HTTPClientRequestDurationName,
|
||||
metric.WithUnit(semconvNew.HTTPClientRequestDurationUnit),
|
||||
metric.WithDescription(semconvNew.HTTPClientRequestDurationDescription),
|
||||
metric.WithExplicitBucketBoundaries(0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10),
|
||||
)
|
||||
handleErr(err)
|
||||
|
||||
|
@ -501,7 +532,7 @@ func (n CurrentHTTPClient) MetricAttributes(req *http.Request, statusCode int, a
|
|||
attributes = append(attributes,
|
||||
semconvNew.HTTPRequestMethodKey.String(standardizeHTTPMethod(req.Method)),
|
||||
semconvNew.ServerAddress(requestHost),
|
||||
n.scheme(req.TLS != nil),
|
||||
n.scheme(req),
|
||||
)
|
||||
|
||||
if port > 0 {
|
||||
|
@ -520,15 +551,18 @@ func (n CurrentHTTPClient) MetricAttributes(req *http.Request, statusCode int, a
|
|||
return attributes
|
||||
}
|
||||
|
||||
// Attributes for httptrace.
|
||||
// TraceAttributes returns attributes for httptrace.
|
||||
func (n CurrentHTTPClient) TraceAttributes(host string) []attribute.KeyValue {
|
||||
return []attribute.KeyValue{
|
||||
semconvNew.ServerAddress(host),
|
||||
}
|
||||
}
|
||||
|
||||
func (n CurrentHTTPClient) scheme(https bool) attribute.KeyValue { // nolint:revive
|
||||
if https {
|
||||
func (n CurrentHTTPClient) scheme(req *http.Request) attribute.KeyValue {
|
||||
if req.URL != nil && req.URL.Scheme != "" {
|
||||
return semconvNew.URLScheme(req.URL.Scheme)
|
||||
}
|
||||
if req.TLS != nil {
|
||||
return semconvNew.URLScheme("https")
|
||||
}
|
||||
return semconvNew.URLScheme("http")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/semconv/util.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
|
@ -28,17 +28,17 @@ func SplitHostPort(hostport string) (host string, port int) {
|
|||
port = -1
|
||||
|
||||
if strings.HasPrefix(hostport, "[") {
|
||||
addrEnd := strings.LastIndex(hostport, "]")
|
||||
addrEnd := strings.LastIndexByte(hostport, ']')
|
||||
if addrEnd < 0 {
|
||||
// Invalid hostport.
|
||||
return
|
||||
}
|
||||
if i := strings.LastIndex(hostport[addrEnd:], ":"); i < 0 {
|
||||
if i := strings.LastIndexByte(hostport[addrEnd:], ':'); i < 0 {
|
||||
host = hostport[1:addrEnd]
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if i := strings.LastIndex(hostport, ":"); i < 0 {
|
||||
if i := strings.LastIndexByte(hostport, ':'); i < 0 {
|
||||
host = hostport
|
||||
return
|
||||
}
|
||||
|
@ -70,12 +70,19 @@ func requiredHTTPPort(https bool, port int) int { // nolint:revive
|
|||
}
|
||||
|
||||
func serverClientIP(xForwardedFor string) string {
|
||||
if idx := strings.Index(xForwardedFor, ","); idx >= 0 {
|
||||
if idx := strings.IndexByte(xForwardedFor, ','); idx >= 0 {
|
||||
xForwardedFor = xForwardedFor[:idx]
|
||||
}
|
||||
return xForwardedFor
|
||||
}
|
||||
|
||||
func httpRoute(pattern string) string {
|
||||
if idx := strings.IndexByte(pattern, '/'); idx >= 0 {
|
||||
return pattern[idx:]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func netProtocol(proto string) (name string, version string) {
|
||||
name, version, _ = strings.Cut(proto, "/")
|
||||
switch name {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/semconv/v120.0.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
|
@ -37,8 +37,8 @@ type OldHTTPServer struct{}
|
|||
//
|
||||
// If the primary server name is not known, server should be an empty string.
|
||||
// The req Host will be used to determine the server instead.
|
||||
func (o OldHTTPServer) RequestTraceAttrs(server string, req *http.Request) []attribute.KeyValue {
|
||||
return semconvutil.HTTPServerRequest(server, req)
|
||||
func (o OldHTTPServer) RequestTraceAttrs(server string, req *http.Request, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return semconvutil.HTTPServerRequest(server, req, semconvutil.HTTPServerRequestOptions{}, attrs)
|
||||
}
|
||||
|
||||
func (o OldHTTPServer) NetworkTransportAttr(network string) attribute.KeyValue {
|
||||
|
@ -48,9 +48,7 @@ func (o OldHTTPServer) NetworkTransportAttr(network string) attribute.KeyValue {
|
|||
// ResponseTraceAttrs returns trace attributes for telemetry from an HTTP response.
|
||||
//
|
||||
// If any of the fields in the ResponseTelemetry are not set the attribute will be omitted.
|
||||
func (o OldHTTPServer) ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue {
|
||||
attributes := []attribute.KeyValue{}
|
||||
|
||||
func (o OldHTTPServer) ResponseTraceAttrs(resp ResponseTelemetry, attributes []attribute.KeyValue) []attribute.KeyValue {
|
||||
if resp.ReadBytes > 0 {
|
||||
attributes = append(attributes, semconv.HTTPRequestContentLength(int(resp.ReadBytes)))
|
||||
}
|
||||
|
@ -179,12 +177,12 @@ func (o OldHTTPServer) scheme(https bool) attribute.KeyValue { // nolint:revive
|
|||
|
||||
type OldHTTPClient struct{}
|
||||
|
||||
func (o OldHTTPClient) RequestTraceAttrs(req *http.Request) []attribute.KeyValue {
|
||||
return semconvutil.HTTPClientRequest(req)
|
||||
func (o OldHTTPClient) RequestTraceAttrs(req *http.Request, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return semconvutil.HTTPClientRequest(req, attrs)
|
||||
}
|
||||
|
||||
func (o OldHTTPClient) ResponseTraceAttrs(resp *http.Response) []attribute.KeyValue {
|
||||
return semconvutil.HTTPClientResponse(resp)
|
||||
func (o OldHTTPClient) ResponseTraceAttrs(resp *http.Response, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return semconvutil.HTTPClientResponse(resp, attrs)
|
||||
}
|
||||
|
||||
func (o OldHTTPClient) MetricAttributes(req *http.Request, statusCode int, additionalAttributes []attribute.KeyValue) []attribute.KeyValue {
|
||||
|
@ -269,9 +267,7 @@ func (o OldHTTPClient) createMeasures(meter metric.Meter) (metric.Int64Counter,
|
|||
return requestBytesCounter, responseBytesCounter, latencyMeasure
|
||||
}
|
||||
|
||||
// Attributes for httptrace.
|
||||
func (c OldHTTPClient) TraceAttributes(host string) []attribute.KeyValue {
|
||||
return []attribute.KeyValue{
|
||||
semconv.NetHostName(host),
|
||||
}
|
||||
// TraceAttributes returns attributes for httptrace.
|
||||
func (c OldHTTPClient) TraceAttributes(host string, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return append(attrs, semconv.NetHostName(host))
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/semconvutil/httpconv.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package semconvutil provides OpenTelemetry semantic convention utilities.
|
||||
package semconvutil // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconvutil"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
|
@ -16,6 +18,11 @@ import (
|
|||
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
|
||||
)
|
||||
|
||||
type HTTPServerRequestOptions struct {
|
||||
// If set, this is used as value for the "http.client_ip" attribute.
|
||||
HTTPClientIP string
|
||||
}
|
||||
|
||||
// HTTPClientResponse returns trace attributes for an HTTP response received by a
|
||||
// client from a server. It will return the following attributes if the related
|
||||
// values are defined in resp: "http.status.code",
|
||||
|
@ -26,9 +33,9 @@ import (
|
|||
// attributes. If a complete set of attributes can be generated using the
|
||||
// request contained in resp. For example:
|
||||
//
|
||||
// append(HTTPClientResponse(resp), ClientRequest(resp.Request)...)
|
||||
func HTTPClientResponse(resp *http.Response) []attribute.KeyValue {
|
||||
return hc.ClientResponse(resp)
|
||||
// HTTPClientResponse(resp, ClientRequest(resp.Request)))
|
||||
func HTTPClientResponse(resp *http.Response, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return hc.ClientResponse(resp, attrs)
|
||||
}
|
||||
|
||||
// HTTPClientRequest returns trace attributes for an HTTP request made by a client.
|
||||
|
@ -36,8 +43,8 @@ func HTTPClientResponse(resp *http.Response) []attribute.KeyValue {
|
|||
// "net.peer.name". The following attributes are returned if the related values
|
||||
// are defined in req: "net.peer.port", "user_agent.original",
|
||||
// "http.request_content_length".
|
||||
func HTTPClientRequest(req *http.Request) []attribute.KeyValue {
|
||||
return hc.ClientRequest(req)
|
||||
func HTTPClientRequest(req *http.Request, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return hc.ClientRequest(req, attrs)
|
||||
}
|
||||
|
||||
// HTTPClientRequestMetrics returns metric attributes for an HTTP request made by a client.
|
||||
|
@ -75,8 +82,8 @@ func HTTPClientStatus(code int) (codes.Code, string) {
|
|||
// "http.target", "net.host.name". The following attributes are returned if
|
||||
// they related values are defined in req: "net.host.port", "net.sock.peer.addr",
|
||||
// "net.sock.peer.port", "user_agent.original", "http.client_ip".
|
||||
func HTTPServerRequest(server string, req *http.Request) []attribute.KeyValue {
|
||||
return hc.ServerRequest(server, req)
|
||||
func HTTPServerRequest(server string, req *http.Request, opts HTTPServerRequestOptions, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
return hc.ServerRequest(server, req, opts, attrs)
|
||||
}
|
||||
|
||||
// HTTPServerRequestMetrics returns metric attributes for an HTTP request received by a
|
||||
|
@ -153,8 +160,8 @@ var hc = &httpConv{
|
|||
// attributes. If a complete set of attributes can be generated using the
|
||||
// request contained in resp. For example:
|
||||
//
|
||||
// append(ClientResponse(resp), ClientRequest(resp.Request)...)
|
||||
func (c *httpConv) ClientResponse(resp *http.Response) []attribute.KeyValue {
|
||||
// ClientResponse(resp, ClientRequest(resp.Request))
|
||||
func (c *httpConv) ClientResponse(resp *http.Response, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
/* The following semantic conventions are returned if present:
|
||||
http.status_code int
|
||||
http.response_content_length int
|
||||
|
@ -166,8 +173,11 @@ func (c *httpConv) ClientResponse(resp *http.Response) []attribute.KeyValue {
|
|||
if resp.ContentLength > 0 {
|
||||
n++
|
||||
}
|
||||
if n == 0 {
|
||||
return attrs
|
||||
}
|
||||
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = slices.Grow(attrs, n)
|
||||
if resp.StatusCode > 0 {
|
||||
attrs = append(attrs, c.HTTPStatusCodeKey.Int(resp.StatusCode))
|
||||
}
|
||||
|
@ -182,7 +192,7 @@ func (c *httpConv) ClientResponse(resp *http.Response) []attribute.KeyValue {
|
|||
// "net.peer.name". The following attributes are returned if the related values
|
||||
// are defined in req: "net.peer.port", "user_agent.original",
|
||||
// "http.request_content_length", "user_agent.original".
|
||||
func (c *httpConv) ClientRequest(req *http.Request) []attribute.KeyValue {
|
||||
func (c *httpConv) ClientRequest(req *http.Request, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
/* The following semantic conventions are returned if present:
|
||||
http.method string
|
||||
user_agent.original string
|
||||
|
@ -221,8 +231,7 @@ func (c *httpConv) ClientRequest(req *http.Request) []attribute.KeyValue {
|
|||
n++
|
||||
}
|
||||
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
|
||||
attrs = slices.Grow(attrs, n)
|
||||
attrs = append(attrs, c.method(req.Method))
|
||||
|
||||
var u string
|
||||
|
@ -305,7 +314,7 @@ func (c *httpConv) ClientRequestMetrics(req *http.Request) []attribute.KeyValue
|
|||
// related values are defined in req: "net.host.port", "net.sock.peer.addr",
|
||||
// "net.sock.peer.port", "user_agent.original", "http.client_ip",
|
||||
// "net.protocol.name", "net.protocol.version".
|
||||
func (c *httpConv) ServerRequest(server string, req *http.Request) []attribute.KeyValue {
|
||||
func (c *httpConv) ServerRequest(server string, req *http.Request, opts HTTPServerRequestOptions, attrs []attribute.KeyValue) []attribute.KeyValue {
|
||||
/* The following semantic conventions are returned if present:
|
||||
http.method string
|
||||
http.scheme string
|
||||
|
@ -358,7 +367,17 @@ func (c *httpConv) ServerRequest(server string, req *http.Request) []attribute.K
|
|||
n++
|
||||
}
|
||||
|
||||
clientIP := serverClientIP(req.Header.Get("X-Forwarded-For"))
|
||||
// For client IP, use, in order:
|
||||
// 1. The value passed in the options
|
||||
// 2. The value in the X-Forwarded-For header
|
||||
// 3. The peer address
|
||||
clientIP := opts.HTTPClientIP
|
||||
if clientIP == "" {
|
||||
clientIP = serverClientIP(req.Header.Get("X-Forwarded-For"))
|
||||
if clientIP == "" {
|
||||
clientIP = peer
|
||||
}
|
||||
}
|
||||
if clientIP != "" {
|
||||
n++
|
||||
}
|
||||
|
@ -378,7 +397,7 @@ func (c *httpConv) ServerRequest(server string, req *http.Request) []attribute.K
|
|||
n++
|
||||
}
|
||||
|
||||
attrs := make([]attribute.KeyValue, 0, n)
|
||||
attrs = slices.Grow(attrs, n)
|
||||
|
||||
attrs = append(attrs, c.method(req.Method))
|
||||
attrs = append(attrs, c.scheme(req.TLS != nil))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// Code generated by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/semconvutil/netconv.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
|
|
6
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/labeler.go
generated
vendored
6
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/labeler.go
generated
vendored
|
@ -35,14 +35,14 @@ func (l *Labeler) Get() []attribute.KeyValue {
|
|||
|
||||
type labelerContextKeyType int
|
||||
|
||||
const lablelerContextKey labelerContextKeyType = 0
|
||||
const labelerContextKey labelerContextKeyType = 0
|
||||
|
||||
// ContextWithLabeler returns a new context with the provided Labeler instance.
|
||||
// Attributes added to the specified labeler will be injected into metrics
|
||||
// emitted by the instrumentation. Only one labeller can be injected into the
|
||||
// context. Injecting it multiple times will override the previous calls.
|
||||
func ContextWithLabeler(parent context.Context, l *Labeler) context.Context {
|
||||
return context.WithValue(parent, lablelerContextKey, l)
|
||||
return context.WithValue(parent, labelerContextKey, l)
|
||||
}
|
||||
|
||||
// LabelerFromContext retrieves a Labeler instance from the provided context if
|
||||
|
@ -50,7 +50,7 @@ func ContextWithLabeler(parent context.Context, l *Labeler) context.Context {
|
|||
// Labeler is returned and the second return value is false. In this case it is
|
||||
// safe to use the Labeler but any attributes added to it will not be used.
|
||||
func LabelerFromContext(ctx context.Context) (*Labeler, bool) {
|
||||
l, ok := ctx.Value(lablelerContextKey).(*Labeler)
|
||||
l, ok := ctx.Value(labelerContextKey).(*Labeler)
|
||||
if !ok {
|
||||
l = &Labeler{}
|
||||
}
|
||||
|
|
9
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go
generated
vendored
9
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go
generated
vendored
|
@ -5,13 +5,6 @@ package otelhttp // import "go.opentelemetry.io/contrib/instrumentation/net/http
|
|||
|
||||
// Version is the current release version of the otelhttp instrumentation.
|
||||
func Version() string {
|
||||
return "0.60.0"
|
||||
return "0.61.0"
|
||||
// This string is updated by the pre_release.sh script during release
|
||||
}
|
||||
|
||||
// SemVersion is the semantic version to be supplied to tracer/meter creation.
|
||||
//
|
||||
// Deprecated: Use [Version] instead.
|
||||
func SemVersion() string {
|
||||
return Version()
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
# See https://github.com/golangci/golangci-lint#config-file
|
||||
version: "2"
|
||||
run:
|
||||
issues-exit-code: 1 #Default
|
||||
tests: true #Default
|
||||
|
||||
issues-exit-code: 1
|
||||
tests: true
|
||||
linters:
|
||||
# Disable everything by default so upgrades to not include new "default
|
||||
# enabled" linters.
|
||||
disable-all: true
|
||||
# Specifically enable linters we want to use.
|
||||
default: none
|
||||
enable:
|
||||
- asasalint
|
||||
- bodyclose
|
||||
|
@ -15,10 +11,7 @@ linters:
|
|||
- errcheck
|
||||
- errorlint
|
||||
- godot
|
||||
- gofumpt
|
||||
- goimports
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
|
@ -26,227 +19,230 @@ linters:
|
|||
- revive
|
||||
- staticcheck
|
||||
- testifylint
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- unparam
|
||||
- unused
|
||||
- usestdlibvars
|
||||
- usetesting
|
||||
|
||||
settings:
|
||||
depguard:
|
||||
rules:
|
||||
auto/sdk:
|
||||
files:
|
||||
- '!internal/global/trace.go'
|
||||
- ~internal/global/trace_test.go
|
||||
deny:
|
||||
- pkg: go.opentelemetry.io/auto/sdk
|
||||
desc: Do not use SDK from automatic instrumentation.
|
||||
non-tests:
|
||||
files:
|
||||
- '!$test'
|
||||
- '!**/*test/*.go'
|
||||
- '!**/internal/matchers/*.go'
|
||||
deny:
|
||||
- pkg: testing
|
||||
- pkg: github.com/stretchr/testify
|
||||
- pkg: crypto/md5
|
||||
- pkg: crypto/sha1
|
||||
- pkg: crypto/**/pkix
|
||||
otel-internal:
|
||||
files:
|
||||
- '**/sdk/*.go'
|
||||
- '**/sdk/**/*.go'
|
||||
- '**/exporters/*.go'
|
||||
- '**/exporters/**/*.go'
|
||||
- '**/schema/*.go'
|
||||
- '**/schema/**/*.go'
|
||||
- '**/metric/*.go'
|
||||
- '**/metric/**/*.go'
|
||||
- '**/bridge/*.go'
|
||||
- '**/bridge/**/*.go'
|
||||
- '**/trace/*.go'
|
||||
- '**/trace/**/*.go'
|
||||
- '**/log/*.go'
|
||||
- '**/log/**/*.go'
|
||||
deny:
|
||||
- pkg: go.opentelemetry.io/otel/internal$
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: go.opentelemetry.io/otel/internal/internaltest
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: go.opentelemetry.io/otel/internal/matchers
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlp-internal:
|
||||
files:
|
||||
- '!**/exporters/otlp/internal/**/*.go'
|
||||
deny:
|
||||
- pkg: go.opentelemetry.io/otel/exporters/otlp/internal
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlpmetric-internal:
|
||||
files:
|
||||
- '!**/exporters/otlp/otlpmetric/internal/*.go'
|
||||
- '!**/exporters/otlp/otlpmetric/internal/**/*.go'
|
||||
deny:
|
||||
- pkg: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlptrace-internal:
|
||||
files:
|
||||
- '!**/exporters/otlp/otlptrace/*.go'
|
||||
- '!**/exporters/otlp/otlptrace/internal/**.go'
|
||||
deny:
|
||||
- pkg: go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal
|
||||
desc: Do not use cross-module internal packages.
|
||||
godot:
|
||||
exclude:
|
||||
# Exclude links.
|
||||
- '^ *\[[^]]+\]:'
|
||||
# Exclude sentence fragments for lists.
|
||||
- ^[ ]*[-•]
|
||||
# Exclude sentences prefixing a list.
|
||||
- :$
|
||||
misspell:
|
||||
locale: US
|
||||
ignore-rules:
|
||||
- cancelled
|
||||
perfsprint:
|
||||
int-conversion: true
|
||||
err-error: true
|
||||
errorf: true
|
||||
sprintf1: true
|
||||
strconcat: true
|
||||
revive:
|
||||
confidence: 0.01
|
||||
rules:
|
||||
- name: blank-imports
|
||||
- name: bool-literal-in-expr
|
||||
- name: constant-logical-expr
|
||||
- name: context-as-argument
|
||||
arguments:
|
||||
- allowTypesBefore: '*testing.T'
|
||||
disabled: true
|
||||
- name: context-keys-type
|
||||
- name: deep-exit
|
||||
- name: defer
|
||||
arguments:
|
||||
- - call-chain
|
||||
- loop
|
||||
- name: dot-imports
|
||||
- name: duplicated-imports
|
||||
- name: early-return
|
||||
arguments:
|
||||
- preserveScope
|
||||
- name: empty-block
|
||||
- name: empty-lines
|
||||
- name: error-naming
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
- name: errorf
|
||||
- name: exported
|
||||
arguments:
|
||||
- sayRepetitiveInsteadOfStutters
|
||||
- name: flag-parameter
|
||||
- name: identical-branches
|
||||
- name: if-return
|
||||
- name: import-shadowing
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
arguments:
|
||||
- preserveScope
|
||||
- name: package-comments
|
||||
- name: range
|
||||
- name: range-val-in-closure
|
||||
- name: range-val-address
|
||||
- name: redefines-builtin-id
|
||||
- name: string-format
|
||||
arguments:
|
||||
- - panic
|
||||
- /^[^\n]*$/
|
||||
- must not contain line breaks
|
||||
- name: struct-tag
|
||||
- name: superfluous-else
|
||||
arguments:
|
||||
- preserveScope
|
||||
- name: time-equal
|
||||
- name: unconditional-recursion
|
||||
- name: unexported-return
|
||||
- name: unhandled-error
|
||||
arguments:
|
||||
- fmt.Fprint
|
||||
- fmt.Fprintf
|
||||
- fmt.Fprintln
|
||||
- fmt.Print
|
||||
- fmt.Printf
|
||||
- fmt.Println
|
||||
- name: unnecessary-stmt
|
||||
- name: useless-break
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
- ["Otel", "Aws", "Gcp"] # DenyList
|
||||
- name: waitgroup-by-value
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
- float-compare
|
||||
- go-require
|
||||
- require-error
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
# TODO: Having appropriate comments for exported objects helps development,
|
||||
# even for objects in internal packages. Appropriate comments for all
|
||||
# exported objects should be added and this exclusion removed.
|
||||
- linters:
|
||||
- revive
|
||||
path: .*internal/.*
|
||||
text: exported (method|function|type|const) (.+) should have comment or be unexported
|
||||
# Yes, they are, but it's okay in a test.
|
||||
- linters:
|
||||
- revive
|
||||
path: _test\.go
|
||||
text: exported func.*returns unexported type.*which can be annoying to use
|
||||
# Example test functions should be treated like main.
|
||||
- linters:
|
||||
- revive
|
||||
path: example.*_test\.go
|
||||
text: calls to (.+) only in main[(][)] or init[(][)] functions
|
||||
# It's okay to not run gosec and perfsprint in a test.
|
||||
- linters:
|
||||
- gosec
|
||||
- perfsprint
|
||||
path: _test\.go
|
||||
# Ignoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||
# as we commonly use it in tests and examples.
|
||||
- linters:
|
||||
- gosec
|
||||
text: 'G404:'
|
||||
# Ignoring gosec G402: TLS MinVersion too low
|
||||
# as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
|
||||
- linters:
|
||||
- gosec
|
||||
text: 'G402: TLS MinVersion too low.'
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
issues:
|
||||
# Maximum issues count per one linter.
|
||||
# Set to 0 to disable.
|
||||
# Default: 50
|
||||
# Setting to unlimited so the linter only is run once to debug all issues.
|
||||
max-issues-per-linter: 0
|
||||
# Maximum count of issues with the same text.
|
||||
# Set to 0 to disable.
|
||||
# Default: 3
|
||||
# Setting to unlimited so the linter only is run once to debug all issues.
|
||||
max-same-issues: 0
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source.
|
||||
exclude-rules:
|
||||
# TODO: Having appropriate comments for exported objects helps development,
|
||||
# even for objects in internal packages. Appropriate comments for all
|
||||
# exported objects should be added and this exclusion removed.
|
||||
- path: '.*internal/.*'
|
||||
text: "exported (method|function|type|const) (.+) should have comment or be unexported"
|
||||
linters:
|
||||
- revive
|
||||
# Yes, they are, but it's okay in a test.
|
||||
- path: _test\.go
|
||||
text: "exported func.*returns unexported type.*which can be annoying to use"
|
||||
linters:
|
||||
- revive
|
||||
# Example test functions should be treated like main.
|
||||
- path: example.*_test\.go
|
||||
text: "calls to (.+) only in main[(][)] or init[(][)] functions"
|
||||
linters:
|
||||
- revive
|
||||
# It's okay to not run gosec and perfsprint in a test.
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gosec
|
||||
- perfsprint
|
||||
# Ignoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||
# as we commonly use it in tests and examples.
|
||||
- text: "G404:"
|
||||
linters:
|
||||
- gosec
|
||||
# Ignoring gosec G402: TLS MinVersion too low
|
||||
# as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
|
||||
- text: "G402: TLS MinVersion too low."
|
||||
linters:
|
||||
- gosec
|
||||
include:
|
||||
# revive exported should have comment or be unexported.
|
||||
- EXC0012
|
||||
# revive package comment should be of the form ...
|
||||
- EXC0013
|
||||
|
||||
linters-settings:
|
||||
depguard:
|
||||
rules:
|
||||
non-tests:
|
||||
files:
|
||||
- "!$test"
|
||||
- "!**/*test/*.go"
|
||||
- "!**/internal/matchers/*.go"
|
||||
deny:
|
||||
- pkg: "testing"
|
||||
- pkg: "github.com/stretchr/testify"
|
||||
- pkg: "crypto/md5"
|
||||
- pkg: "crypto/sha1"
|
||||
- pkg: "crypto/**/pkix"
|
||||
auto/sdk:
|
||||
files:
|
||||
- "!internal/global/trace.go"
|
||||
- "~internal/global/trace_test.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/auto/sdk"
|
||||
desc: Do not use SDK from automatic instrumentation.
|
||||
otlp-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/internal/**/*.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlptrace-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/otlptrace/*.go"
|
||||
- "!**/exporters/otlp/otlptrace/internal/**.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal"
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlpmetric-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/otlpmetric/internal/*.go"
|
||||
- "!**/exporters/otlp/otlpmetric/internal/**/*.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
|
||||
desc: Do not use cross-module internal packages.
|
||||
otel-internal:
|
||||
files:
|
||||
- "**/sdk/*.go"
|
||||
- "**/sdk/**/*.go"
|
||||
- "**/exporters/*.go"
|
||||
- "**/exporters/**/*.go"
|
||||
- "**/schema/*.go"
|
||||
- "**/schema/**/*.go"
|
||||
- "**/metric/*.go"
|
||||
- "**/metric/**/*.go"
|
||||
- "**/bridge/*.go"
|
||||
- "**/bridge/**/*.go"
|
||||
- "**/trace/*.go"
|
||||
- "**/trace/**/*.go"
|
||||
- "**/log/*.go"
|
||||
- "**/log/**/*.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/internal$"
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: "go.opentelemetry.io/otel/internal/attribute"
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: "go.opentelemetry.io/otel/internal/internaltest"
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: "go.opentelemetry.io/otel/internal/matchers"
|
||||
desc: Do not use cross-module internal packages.
|
||||
godot:
|
||||
exclude:
|
||||
# Exclude links.
|
||||
- '^ *\[[^]]+\]:'
|
||||
# Exclude sentence fragments for lists.
|
||||
- '^[ ]*[-•]'
|
||||
# Exclude sentences prefixing a list.
|
||||
- ':$'
|
||||
goimports:
|
||||
local-prefixes: go.opentelemetry.io
|
||||
misspell:
|
||||
locale: US
|
||||
ignore-words:
|
||||
- cancelled
|
||||
perfsprint:
|
||||
err-error: true
|
||||
errorf: true
|
||||
int-conversion: true
|
||||
sprintf1: true
|
||||
strconcat: true
|
||||
revive:
|
||||
# Sets the default failure confidence.
|
||||
# This means that linting errors with less than 0.8 confidence will be ignored.
|
||||
# Default: 0.8
|
||||
confidence: 0.01
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
||||
rules:
|
||||
- name: blank-imports
|
||||
- name: bool-literal-in-expr
|
||||
- name: constant-logical-expr
|
||||
- name: context-as-argument
|
||||
disabled: true
|
||||
arguments:
|
||||
- allowTypesBefore: "*testing.T"
|
||||
- name: context-keys-type
|
||||
- name: deep-exit
|
||||
- name: defer
|
||||
arguments:
|
||||
- ["call-chain", "loop"]
|
||||
- name: dot-imports
|
||||
- name: duplicated-imports
|
||||
- name: early-return
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: empty-block
|
||||
- name: empty-lines
|
||||
- name: error-naming
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
- name: errorf
|
||||
- name: exported
|
||||
arguments:
|
||||
- "sayRepetitiveInsteadOfStutters"
|
||||
- name: flag-parameter
|
||||
- name: identical-branches
|
||||
- name: if-return
|
||||
- name: import-shadowing
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: package-comments
|
||||
- name: range
|
||||
- name: range-val-in-closure
|
||||
- name: range-val-address
|
||||
- name: redefines-builtin-id
|
||||
- name: string-format
|
||||
arguments:
|
||||
- - panic
|
||||
- '/^[^\n]*$/'
|
||||
- must not contain line breaks
|
||||
- name: struct-tag
|
||||
- name: superfluous-else
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: time-equal
|
||||
- name: unconditional-recursion
|
||||
- name: unexported-return
|
||||
- name: unhandled-error
|
||||
arguments:
|
||||
- "fmt.Fprint"
|
||||
- "fmt.Fprintf"
|
||||
- "fmt.Fprintln"
|
||||
- "fmt.Print"
|
||||
- "fmt.Printf"
|
||||
- "fmt.Println"
|
||||
- name: unnecessary-stmt
|
||||
- name: useless-break
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
- ["Otel", "Aws", "Gcp"] # DenyList
|
||||
- name: waitgroup-by-value
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
- float-compare
|
||||
- go-require
|
||||
- require-error
|
||||
formatters:
|
||||
enable:
|
||||
- gofumpt
|
||||
- goimports
|
||||
- golines
|
||||
settings:
|
||||
goimports:
|
||||
local-prefixes:
|
||||
- go.opentelemetry.io
|
||||
golines:
|
||||
max-len: 120
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
|
|
@ -11,6 +11,57 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
<!-- Released section -->
|
||||
<!-- Don't change this section unless doing release -->
|
||||
|
||||
## [1.36.0/0.58.0/0.12.0] 2025-05-20
|
||||
|
||||
### Added
|
||||
|
||||
- Add exponential histogram support in `go.opentelemetry.io/otel/exporters/prometheus`. (#6421)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.31.0` package.
|
||||
The package contains semantic conventions from the `v1.31.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.31.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.30.0`. (#6479)
|
||||
- Add `Recording`, `Scope`, and `Record` types in `go.opentelemetry.io/otel/log/logtest`. (#6507)
|
||||
- Add `WithHTTPClient` option to configure the `http.Client` used by `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#6751)
|
||||
- Add `WithHTTPClient` option to configure the `http.Client` used by `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#6752)
|
||||
- Add `WithHTTPClient` option to configure the `http.Client` used by `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6688)
|
||||
- Add `ValuesGetter` in `go.opentelemetry.io/otel/propagation`, a `TextMapCarrier` that supports retrieving multiple values for a single key. (#5973)
|
||||
- Add `Values` method to `HeaderCarrier` to implement the new `ValuesGetter` interface in `go.opentelemetry.io/otel/propagation`. (#5973)
|
||||
- Update `Baggage` in `go.opentelemetry.io/otel/propagation` to retrieve multiple values for a key when the carrier implements `ValuesGetter`. (#5973)
|
||||
- Add `AssertEqual` function in `go.opentelemetry.io/otel/log/logtest`. (#6662)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.32.0` package.
|
||||
The package contains semantic conventions from the `v1.32.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.32.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.31.0`(#6782)
|
||||
- Add `Transform` option in `go.opentelemetry.io/otel/log/logtest`. (#6794)
|
||||
- Add `Desc` option in `go.opentelemetry.io/otel/log/logtest`. (#6796)
|
||||
|
||||
### Removed
|
||||
|
||||
- Drop support for [Go 1.22]. (#6381, #6418)
|
||||
- Remove `Resource` field from `EnabledParameters` in `go.opentelemetry.io/otel/sdk/log`. (#6494)
|
||||
- Remove `RecordFactory` type from `go.opentelemetry.io/otel/log/logtest`. (#6492)
|
||||
- Remove `ScopeRecords`, `EmittedRecord`, and `RecordFactory` types from `go.opentelemetry.io/otel/log/logtest`. (#6507)
|
||||
- Remove `AssertRecordEqual` function in `go.opentelemetry.io/otel/log/logtest`, use `AssertEqual` instead. (#6662)
|
||||
|
||||
### Changed
|
||||
|
||||
- ⚠️ Update `github.com/prometheus/client_golang` to `v1.21.1`, which changes the `NameValidationScheme` to `UTF8Validation`.
|
||||
This allows metrics names to keep original delimiters (e.g. `.`), rather than replacing with underscores.
|
||||
This can be reverted by setting `github.com/prometheus/common/model.NameValidationScheme` to `LegacyValidation` in `github.com/prometheus/common/model`. (#6433)
|
||||
- Initialize map with `len(keys)` in `NewAllowKeysFilter` and `NewDenyKeysFilter` to avoid unnecessary allocations in `go.opentelemetry.io/otel/attribute`. (#6455)
|
||||
- `go.opentelemetry.io/otel/log/logtest` is now a separate Go module. (#6465)
|
||||
- `go.opentelemetry.io/otel/sdk/log/logtest` is now a separate Go module. (#6466)
|
||||
- `Recorder` in `go.opentelemetry.io/otel/log/logtest` no longer separately stores records emitted by loggers with the same instrumentation scope. (#6507)
|
||||
- Improve performance of `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot accept more. (#6569, #6641)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Deprecate support for `model.LegacyValidation` for `go.opentelemetry.io/otel/exporters/prometheus`. (#6449)
|
||||
|
||||
### Fixes
|
||||
|
||||
- Stop percent encoding header environment variables in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6392)
|
||||
- Ensure the `noopSpan.tracerProvider` method is not inlined in `go.opentelemetry.io/otel/trace` so the `go.opentelemetry.io/auto` instrumentation can instrument non-recording spans. (#6456)
|
||||
- Use a `sync.Pool` instead of allocating `metricdata.ResourceMetrics` in `go.opentelemetry.io/otel/exporters/prometheus`. (#6472)
|
||||
|
||||
## [1.35.0/0.57.0/0.11.0] 2025-03-05
|
||||
|
||||
This release is the last to support [Go 1.22].
|
||||
|
@ -3237,7 +3288,8 @@ It contains api and sdk for trace and meter.
|
|||
- CircleCI build CI manifest files.
|
||||
- CODEOWNERS file to track owners of this project.
|
||||
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...HEAD
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.36.0...HEAD
|
||||
[1.36.0/0.58.0/0.12.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.36.0
|
||||
[1.35.0/0.57.0/0.11.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.35.0
|
||||
[1.34.0/0.56.0/0.10.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.34.0
|
||||
[1.33.0/0.55.0/0.9.0/0.0.12]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.33.0
|
||||
|
|
|
@ -643,6 +643,7 @@ should be canceled.
|
|||
|
||||
### Triagers
|
||||
|
||||
- [Alex Kats](https://github.com/akats7), Capital One
|
||||
- [Cheng-Zhen Yang](https://github.com/scorpionknifes), Independent
|
||||
|
||||
### Approvers
|
||||
|
|
|
@ -43,8 +43,11 @@ $(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/build-tools/crosslink
|
|||
SEMCONVKIT = $(TOOLS)/semconvkit
|
||||
$(TOOLS)/semconvkit: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/semconvkit
|
||||
|
||||
VERIFYREADMES = $(TOOLS)/verifyreadmes
|
||||
$(TOOLS)/verifyreadmes: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/verifyreadmes
|
||||
|
||||
GOLANGCI_LINT = $(TOOLS)/golangci-lint
|
||||
$(TOOLS)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
$(TOOLS)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/v2/cmd/golangci-lint
|
||||
|
||||
MISSPELL = $(TOOLS)/misspell
|
||||
$(TOOLS)/misspell: PACKAGE=github.com/client9/misspell/cmd/misspell
|
||||
|
@ -68,7 +71,7 @@ GOVULNCHECK = $(TOOLS)/govulncheck
|
|||
$(TOOLS)/govulncheck: PACKAGE=golang.org/x/vuln/cmd/govulncheck
|
||||
|
||||
.PHONY: tools
|
||||
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE)
|
||||
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(SEMCONVGEN) $(VERIFYREADMES) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE)
|
||||
|
||||
# Virtualized python tools via docker
|
||||
|
||||
|
@ -213,11 +216,8 @@ go-mod-tidy/%: crosslink
|
|||
&& cd $(DIR) \
|
||||
&& $(GO) mod tidy -compat=1.21
|
||||
|
||||
.PHONY: lint-modules
|
||||
lint-modules: go-mod-tidy
|
||||
|
||||
.PHONY: lint
|
||||
lint: misspell lint-modules golangci-lint govulncheck
|
||||
lint: misspell go-mod-tidy golangci-lint govulncheck
|
||||
|
||||
.PHONY: vanity-import-check
|
||||
vanity-import-check: $(PORTO)
|
||||
|
@ -319,10 +319,11 @@ add-tags: verify-mods
|
|||
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
|
||||
$(MULTIMOD) tag -m ${MODSET} -c ${COMMIT}
|
||||
|
||||
MARKDOWNIMAGE := $(shell awk '$$4=="markdown" {print $$2}' $(DEPENDENCIES_DOCKERFILE))
|
||||
.PHONY: lint-markdown
|
||||
lint-markdown:
|
||||
docker run -v "$(CURDIR):$(WORKDIR)" avtodev/markdown-lint:v1 -c $(WORKDIR)/.markdownlint.yaml $(WORKDIR)/**/*.md
|
||||
docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" $(MARKDOWNIMAGE) -c $(WORKDIR)/.markdownlint.yaml $(WORKDIR)/**/*.md
|
||||
|
||||
.PHONY: verify-readmes
|
||||
verify-readmes:
|
||||
./verify_readmes.sh
|
||||
verify-readmes: $(VERIFYREADMES)
|
||||
$(VERIFYREADMES)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[](https://goreportcard.com/report/go.opentelemetry.io/otel)
|
||||
[](https://scorecard.dev/viewer/?uri=github.com/open-telemetry/opentelemetry-go)
|
||||
[](https://www.bestpractices.dev/projects/9996)
|
||||
[](https://issues.oss-fuzz.com/issues?q=project:opentelemetry-go)
|
||||
[](https://cloud-native.slack.com/archives/C01NPAXACKT)
|
||||
|
||||
OpenTelemetry-Go is the [Go](https://golang.org/) implementation of [OpenTelemetry](https://opentelemetry.io/).
|
||||
|
@ -53,25 +54,18 @@ Currently, this project supports the following environments.
|
|||
|----------|------------|--------------|
|
||||
| Ubuntu | 1.24 | amd64 |
|
||||
| Ubuntu | 1.23 | amd64 |
|
||||
| Ubuntu | 1.22 | amd64 |
|
||||
| Ubuntu | 1.24 | 386 |
|
||||
| Ubuntu | 1.23 | 386 |
|
||||
| Ubuntu | 1.22 | 386 |
|
||||
| Ubuntu | 1.24 | arm64 |
|
||||
| Ubuntu | 1.23 | arm64 |
|
||||
| Ubuntu | 1.22 | arm64 |
|
||||
| macOS 13 | 1.24 | amd64 |
|
||||
| macOS 13 | 1.23 | amd64 |
|
||||
| macOS 13 | 1.22 | amd64 |
|
||||
| macOS | 1.24 | arm64 |
|
||||
| macOS | 1.23 | arm64 |
|
||||
| macOS | 1.22 | arm64 |
|
||||
| Windows | 1.24 | amd64 |
|
||||
| Windows | 1.23 | amd64 |
|
||||
| Windows | 1.22 | amd64 |
|
||||
| Windows | 1.24 | 386 |
|
||||
| Windows | 1.23 | 386 |
|
||||
| Windows | 1.22 | 386 |
|
||||
|
||||
While this project should work for other systems, no compatibility guarantees
|
||||
are made for those systems currently.
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Release Process
|
||||
|
||||
## Create a `Version Release` issue
|
||||
|
||||
Create a `Version Release` issue to track the release process.
|
||||
|
||||
## Semantic Convention Generation
|
||||
|
||||
New versions of the [OpenTelemetry Semantic Conventions] mean new versions of the `semconv` package need to be generated.
|
||||
|
@ -123,6 +127,16 @@ Importantly, bump any package versions referenced to be the latest one you just
|
|||
[Go instrumentation documentation]: https://opentelemetry.io/docs/languages/go/
|
||||
[content/en/docs/languages/go]: https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/languages/go
|
||||
|
||||
### Close the milestone
|
||||
|
||||
Once a release is made, ensure all issues that were fixed and PRs that were merged as part of this release are added to the corresponding milestone.
|
||||
This helps track what changes were included in each release.
|
||||
|
||||
- To find issues that haven't been included in a milestone, use this [GitHub search query](https://github.com/open-telemetry/opentelemetry-go/issues?q=is%3Aissue%20no%3Amilestone%20is%3Aclosed%20sort%3Aupdated-desc%20reason%3Acompleted%20-label%3AStale%20linked%3Apr)
|
||||
- To find merged PRs that haven't been included in a milestone, use this [GitHub search query](https://github.com/open-telemetry/opentelemetry-go/pulls?q=is%3Apr+no%3Amilestone+is%3Amerged).
|
||||
|
||||
Once all related issues and PRs have been added to the milestone, close the milestone.
|
||||
|
||||
### Demo Repository
|
||||
|
||||
Bump the dependencies in the following Go services:
|
||||
|
@ -130,3 +144,7 @@ Bump the dependencies in the following Go services:
|
|||
- [`accounting`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/accounting)
|
||||
- [`checkoutservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/checkout)
|
||||
- [`productcatalogservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/product-catalog)
|
||||
|
||||
### Close the `Version Release` issue
|
||||
|
||||
Once the todo list in the `Version Release` issue is complete, close the issue.
|
||||
|
|
|
@ -19,7 +19,7 @@ func NewAllowKeysFilter(keys ...Key) Filter {
|
|||
return func(kv KeyValue) bool { return false }
|
||||
}
|
||||
|
||||
allowed := make(map[Key]struct{})
|
||||
allowed := make(map[Key]struct{}, len(keys))
|
||||
for _, k := range keys {
|
||||
allowed[k] = struct{}{}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func NewDenyKeysFilter(keys ...Key) Filter {
|
|||
return func(kv KeyValue) bool { return true }
|
||||
}
|
||||
|
||||
forbid := make(map[Key]struct{})
|
||||
forbid := make(map[Key]struct{}, len(keys))
|
||||
for _, k := range keys {
|
||||
forbid[k] = struct{}{}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
Package attribute provide several helper functions for some commonly used
|
||||
logic of processing attributes.
|
||||
*/
|
||||
package attribute // import "go.opentelemetry.io/otel/internal/attribute"
|
||||
package attribute // import "go.opentelemetry.io/otel/attribute/internal"
|
||||
|
||||
import (
|
||||
"reflect"
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package attribute // import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
func boolToRaw(b bool) uint64 { // nolint:revive // b is not a control flag.
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func rawToBool(r uint64) bool {
|
||||
return r != 0
|
||||
}
|
||||
|
||||
func int64ToRaw(i int64) uint64 {
|
||||
// Assumes original was a valid int64 (overflow not checked).
|
||||
return uint64(i) // nolint: gosec
|
||||
}
|
||||
|
||||
func rawToInt64(r uint64) int64 {
|
||||
// Assumes original was a valid int64 (overflow not checked).
|
||||
return int64(r) // nolint: gosec
|
||||
}
|
||||
|
||||
func float64ToRaw(f float64) uint64 {
|
||||
return math.Float64bits(f)
|
||||
}
|
||||
|
||||
func rawToFloat64(r uint64) float64 {
|
||||
return math.Float64frombits(r)
|
||||
}
|
|
@ -9,8 +9,7 @@ import (
|
|||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"go.opentelemetry.io/otel/internal"
|
||||
"go.opentelemetry.io/otel/internal/attribute"
|
||||
attribute "go.opentelemetry.io/otel/attribute/internal"
|
||||
)
|
||||
|
||||
//go:generate stringer -type=Type
|
||||
|
@ -51,7 +50,7 @@ const (
|
|||
func BoolValue(v bool) Value {
|
||||
return Value{
|
||||
vtype: BOOL,
|
||||
numeric: internal.BoolToRaw(v),
|
||||
numeric: boolToRaw(v),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +81,7 @@ func IntSliceValue(v []int) Value {
|
|||
func Int64Value(v int64) Value {
|
||||
return Value{
|
||||
vtype: INT64,
|
||||
numeric: internal.Int64ToRaw(v),
|
||||
numeric: int64ToRaw(v),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +94,7 @@ func Int64SliceValue(v []int64) Value {
|
|||
func Float64Value(v float64) Value {
|
||||
return Value{
|
||||
vtype: FLOAT64,
|
||||
numeric: internal.Float64ToRaw(v),
|
||||
numeric: float64ToRaw(v),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +124,7 @@ func (v Value) Type() Type {
|
|||
// AsBool returns the bool value. Make sure that the Value's type is
|
||||
// BOOL.
|
||||
func (v Value) AsBool() bool {
|
||||
return internal.RawToBool(v.numeric)
|
||||
return rawToBool(v.numeric)
|
||||
}
|
||||
|
||||
// AsBoolSlice returns the []bool value. Make sure that the Value's type is
|
||||
|
@ -144,7 +143,7 @@ func (v Value) asBoolSlice() []bool {
|
|||
// AsInt64 returns the int64 value. Make sure that the Value's type is
|
||||
// INT64.
|
||||
func (v Value) AsInt64() int64 {
|
||||
return internal.RawToInt64(v.numeric)
|
||||
return rawToInt64(v.numeric)
|
||||
}
|
||||
|
||||
// AsInt64Slice returns the []int64 value. Make sure that the Value's type is
|
||||
|
@ -163,7 +162,7 @@ func (v Value) asInt64Slice() []int64 {
|
|||
// AsFloat64 returns the float64 value. Make sure that the Value's
|
||||
// type is FLOAT64.
|
||||
func (v Value) AsFloat64() float64 {
|
||||
return internal.RawToFloat64(v.numeric)
|
||||
return rawToFloat64(v.numeric)
|
||||
}
|
||||
|
||||
// AsFloat64Slice returns the []float64 value. Make sure that the Value's type is
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# This is a renovate-friendly source of Docker images.
|
||||
FROM python:3.13.2-slim-bullseye@sha256:31b581c8218e1f3c58672481b3b7dba8e898852866b408c6a984c22832523935 AS python
|
||||
FROM otel/weaver:v0.13.2@sha256:ae7346b992e477f629ea327e0979e8a416a97f7956ab1f7e95ac1f44edf1a893 AS weaver
|
||||
FROM python:3.13.3-slim-bullseye@sha256:9e3f9243e06fd68eb9519074b49878eda20ad39a855fac51aaffb741de20726e AS python
|
||||
FROM otel/weaver:v0.15.0@sha256:1cf1c72eaed57dad813c2e359133b8a15bd4facf305aae5b13bdca6d3eccff56 AS weaver
|
||||
FROM avtodev/markdown-lint:v1@sha256:6aeedc2f49138ce7a1cd0adffc1b1c0321b841dc2102408967d9301c031949ee AS markdown
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
top_dir='.'
|
||||
if [[ $# -gt 0 ]]; then
|
||||
top_dir="${1}"
|
||||
fi
|
||||
|
||||
p=$(pwd)
|
||||
mod_dirs=()
|
||||
|
||||
# Note `mapfile` does not exist in older bash versions:
|
||||
# https://stackoverflow.com/questions/41475261/need-alternative-to-readarray-mapfile-for-script-on-older-version-of-bash
|
||||
|
||||
while IFS= read -r line; do
|
||||
mod_dirs+=("$line")
|
||||
done < <(find "${top_dir}" -type f -name 'go.mod' -exec dirname {} \; | sort)
|
||||
|
||||
for mod_dir in "${mod_dirs[@]}"; do
|
||||
cd "${mod_dir}"
|
||||
|
||||
while IFS= read -r line; do
|
||||
echo ".${line#${p}}"
|
||||
done < <(go list --find -f '{{.Name}}|{{.Dir}}' ./... | grep '^main|' | cut -f 2- -d '|')
|
||||
cd "${p}"
|
||||
done
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package internal // import "go.opentelemetry.io/otel/internal"
|
||||
|
||||
//go:generate gotmpl --body=./shared/matchers/expectation.go.tmpl "--data={}" --out=matchers/expectation.go
|
||||
//go:generate gotmpl --body=./shared/matchers/expecter.go.tmpl "--data={}" --out=matchers/expecter.go
|
||||
//go:generate gotmpl --body=./shared/matchers/temporal_matcher.go.tmpl "--data={}" --out=matchers/temporal_matcher.go
|
||||
|
||||
//go:generate gotmpl --body=./shared/internaltest/alignment.go.tmpl "--data={}" --out=internaltest/alignment.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/env.go.tmpl "--data={}" --out=internaltest/env.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/env_test.go.tmpl "--data={}" --out=internaltest/env_test.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/errors.go.tmpl "--data={}" --out=internaltest/errors.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/harness.go.tmpl "--data={\"matchersImportPath\": \"go.opentelemetry.io/otel/internal/matchers\"}" --out=internaltest/harness.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_carrier.go.tmpl "--data={}" --out=internaltest/text_map_carrier.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_carrier_test.go.tmpl "--data={}" --out=internaltest/text_map_carrier_test.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_propagator.go.tmpl "--data={}" --out=internaltest/text_map_propagator.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_propagator_test.go.tmpl "--data={}" --out=internaltest/text_map_propagator_test.go
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package global provides the OpenTelemetry global API.
|
||||
package global // import "go.opentelemetry.io/otel/internal/global"
|
||||
|
||||
import (
|
||||
|
|
|
@ -169,7 +169,10 @@ func (m *meter) Int64Counter(name string, options ...metric.Int64CounterOption)
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
func (m *meter) Int64UpDownCounter(
|
||||
name string,
|
||||
options ...metric.Int64UpDownCounterOption,
|
||||
) (metric.Int64UpDownCounter, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -238,7 +241,10 @@ func (m *meter) Int64Gauge(name string, options ...metric.Int64GaugeOption) (met
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
func (m *meter) Int64ObservableCounter(
|
||||
name string,
|
||||
options ...metric.Int64ObservableCounterOption,
|
||||
) (metric.Int64ObservableCounter, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -261,7 +267,10 @@ func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64Obser
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Int64ObservableUpDownCounter(
|
||||
name string,
|
||||
options ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (metric.Int64ObservableUpDownCounter, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -284,7 +293,10 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int6
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
func (m *meter) Int64ObservableGauge(
|
||||
name string,
|
||||
options ...metric.Int64ObservableGaugeOption,
|
||||
) (metric.Int64ObservableGauge, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -330,7 +342,10 @@ func (m *meter) Float64Counter(name string, options ...metric.Float64CounterOpti
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
func (m *meter) Float64UpDownCounter(
|
||||
name string,
|
||||
options ...metric.Float64UpDownCounterOption,
|
||||
) (metric.Float64UpDownCounter, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -353,7 +368,10 @@ func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDow
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
func (m *meter) Float64Histogram(
|
||||
name string,
|
||||
options ...metric.Float64HistogramOption,
|
||||
) (metric.Float64Histogram, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -399,7 +417,10 @@ func (m *meter) Float64Gauge(name string, options ...metric.Float64GaugeOption)
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
func (m *meter) Float64ObservableCounter(
|
||||
name string,
|
||||
options ...metric.Float64ObservableCounterOption,
|
||||
) (metric.Float64ObservableCounter, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -422,7 +443,10 @@ func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64O
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Float64ObservableUpDownCounter(
|
||||
name string,
|
||||
options ...metric.Float64ObservableUpDownCounterOption,
|
||||
) (metric.Float64ObservableUpDownCounter, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
@ -445,7 +469,10 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Fl
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
func (m *meter) Float64ObservableGauge(
|
||||
name string,
|
||||
options ...metric.Float64ObservableGaugeOption,
|
||||
) (metric.Float64ObservableGauge, error) {
|
||||
m.mtx.Lock()
|
||||
defer m.mtx.Unlock()
|
||||
|
||||
|
|
|
@ -158,7 +158,18 @@ func (t *tracer) Start(ctx context.Context, name string, opts ...trace.SpanStart
|
|||
// a nonRecordingSpan by default.
|
||||
var autoInstEnabled = new(bool)
|
||||
|
||||
func (t *tracer) newSpan(ctx context.Context, autoSpan *bool, name string, opts []trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
// newSpan is called by tracer.Start so auto-instrumentation can attach an eBPF
|
||||
// uprobe to this code.
|
||||
//
|
||||
// "noinline" pragma prevents the method from ever being inlined.
|
||||
//
|
||||
//go:noinline
|
||||
func (t *tracer) newSpan(
|
||||
ctx context.Context,
|
||||
autoSpan *bool,
|
||||
name string,
|
||||
opts []trace.SpanStartOption,
|
||||
) (context.Context, trace.Span) {
|
||||
// autoInstEnabled is passed to newSpan via the autoSpan parameter. This is
|
||||
// so the auto-instrumentation can define a uprobe for (*t).newSpan and be
|
||||
// provided with the address of the bool autoInstEnabled points to. It
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package internal // import "go.opentelemetry.io/otel/internal"
|
||||
|
||||
import (
|
||||
"math"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func BoolToRaw(b bool) uint64 { // nolint:revive // b is not a control flag.
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func RawToBool(r uint64) bool {
|
||||
return r != 0
|
||||
}
|
||||
|
||||
func Int64ToRaw(i int64) uint64 {
|
||||
// Assumes original was a valid int64 (overflow not checked).
|
||||
return uint64(i) // nolint: gosec
|
||||
}
|
||||
|
||||
func RawToInt64(r uint64) int64 {
|
||||
// Assumes original was a valid int64 (overflow not checked).
|
||||
return int64(r) // nolint: gosec
|
||||
}
|
||||
|
||||
func Float64ToRaw(f float64) uint64 {
|
||||
return math.Float64bits(f)
|
||||
}
|
||||
|
||||
func RawToFloat64(r uint64) float64 {
|
||||
return math.Float64frombits(r)
|
||||
}
|
||||
|
||||
func RawPtrToFloat64Ptr(r *uint64) *float64 {
|
||||
// Assumes original was a valid *float64 (overflow not checked).
|
||||
return (*float64)(unsafe.Pointer(r)) // nolint: gosec
|
||||
}
|
||||
|
||||
func RawPtrToInt64Ptr(r *uint64) *int64 {
|
||||
// Assumes original was a valid *int64 (overflow not checked).
|
||||
return (*int64)(unsafe.Pointer(r)) // nolint: gosec
|
||||
}
|
|
@ -106,7 +106,9 @@ type Float64ObservableUpDownCounterConfig struct {
|
|||
|
||||
// NewFloat64ObservableUpDownCounterConfig returns a new
|
||||
// [Float64ObservableUpDownCounterConfig] with all opts applied.
|
||||
func NewFloat64ObservableUpDownCounterConfig(opts ...Float64ObservableUpDownCounterOption) Float64ObservableUpDownCounterConfig {
|
||||
func NewFloat64ObservableUpDownCounterConfig(
|
||||
opts ...Float64ObservableUpDownCounterOption,
|
||||
) Float64ObservableUpDownCounterConfig {
|
||||
var config Float64ObservableUpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableUpDownCounter(config)
|
||||
|
@ -239,12 +241,16 @@ type float64CallbackOpt struct {
|
|||
cback Float64Callback
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableCounter(cfg Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
func (o float64CallbackOpt) applyFloat64ObservableCounter(
|
||||
cfg Float64ObservableCounterConfig,
|
||||
) Float64ObservableCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableUpDownCounter(cfg Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
func (o float64CallbackOpt) applyFloat64ObservableUpDownCounter(
|
||||
cfg Float64ObservableUpDownCounterConfig,
|
||||
) Float64ObservableUpDownCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
|
|
@ -105,7 +105,9 @@ type Int64ObservableUpDownCounterConfig struct {
|
|||
|
||||
// NewInt64ObservableUpDownCounterConfig returns a new
|
||||
// [Int64ObservableUpDownCounterConfig] with all opts applied.
|
||||
func NewInt64ObservableUpDownCounterConfig(opts ...Int64ObservableUpDownCounterOption) Int64ObservableUpDownCounterConfig {
|
||||
func NewInt64ObservableUpDownCounterConfig(
|
||||
opts ...Int64ObservableUpDownCounterOption,
|
||||
) Int64ObservableUpDownCounterConfig {
|
||||
var config Int64ObservableUpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableUpDownCounter(config)
|
||||
|
@ -242,7 +244,9 @@ func (o int64CallbackOpt) applyInt64ObservableCounter(cfg Int64ObservableCounter
|
|||
return cfg
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableUpDownCounter(cfg Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
func (o int64CallbackOpt) applyInt64ObservableUpDownCounter(
|
||||
cfg Int64ObservableUpDownCounterConfig,
|
||||
) Int64ObservableUpDownCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ func (o descOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig)
|
|||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
func (o descOpt) applyFloat64ObservableUpDownCounter(
|
||||
c Float64ObservableUpDownCounterConfig,
|
||||
) Float64ObservableUpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
@ -98,7 +100,9 @@ func (o descOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int
|
|||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
func (o descOpt) applyInt64ObservableUpDownCounter(
|
||||
c Int64ObservableUpDownCounterConfig,
|
||||
) Int64ObservableUpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
@ -138,7 +142,9 @@ func (o unitOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig)
|
|||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
func (o unitOpt) applyFloat64ObservableUpDownCounter(
|
||||
c Float64ObservableUpDownCounterConfig,
|
||||
) Float64ObservableUpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
@ -173,7 +179,9 @@ func (o unitOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int
|
|||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
func (o unitOpt) applyInt64ObservableUpDownCounter(
|
||||
c Int64ObservableUpDownCounterConfig,
|
||||
) Int64ObservableUpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
|
|
@ -110,7 +110,10 @@ type Meter interface {
|
|||
// The name needs to conform to the OpenTelemetry instrument name syntax.
|
||||
// See the Instrument Name section of the package documentation for more
|
||||
// information.
|
||||
Int64ObservableUpDownCounter(name string, options ...Int64ObservableUpDownCounterOption) (Int64ObservableUpDownCounter, error)
|
||||
Int64ObservableUpDownCounter(
|
||||
name string,
|
||||
options ...Int64ObservableUpDownCounterOption,
|
||||
) (Int64ObservableUpDownCounter, error)
|
||||
|
||||
// Int64ObservableGauge returns a new Int64ObservableGauge instrument
|
||||
// identified by name and configured with options. The instrument is used
|
||||
|
@ -194,7 +197,10 @@ type Meter interface {
|
|||
// The name needs to conform to the OpenTelemetry instrument name syntax.
|
||||
// See the Instrument Name section of the package documentation for more
|
||||
// information.
|
||||
Float64ObservableUpDownCounter(name string, options ...Float64ObservableUpDownCounterOption) (Float64ObservableUpDownCounter, error)
|
||||
Float64ObservableUpDownCounter(
|
||||
name string,
|
||||
options ...Float64ObservableUpDownCounterOption,
|
||||
) (Float64ObservableUpDownCounter, error)
|
||||
|
||||
// Float64ObservableGauge returns a new Float64ObservableGauge instrument
|
||||
// identified by name and configured with options. The instrument is used
|
||||
|
|
|
@ -86,13 +86,19 @@ func (Meter) Int64Gauge(string, ...metric.Int64GaugeOption) (metric.Int64Gauge,
|
|||
|
||||
// Int64ObservableCounter returns an ObservableCounter used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Int64ObservableCounter(string, ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
func (Meter) Int64ObservableCounter(
|
||||
string,
|
||||
...metric.Int64ObservableCounterOption,
|
||||
) (metric.Int64ObservableCounter, error) {
|
||||
return Int64ObservableCounter{}, nil
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounter returns an ObservableUpDownCounter used to
|
||||
// record int64 measurements that produces no telemetry.
|
||||
func (Meter) Int64ObservableUpDownCounter(string, ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
func (Meter) Int64ObservableUpDownCounter(
|
||||
string,
|
||||
...metric.Int64ObservableUpDownCounterOption,
|
||||
) (metric.Int64ObservableUpDownCounter, error) {
|
||||
return Int64ObservableUpDownCounter{}, nil
|
||||
}
|
||||
|
||||
|
@ -128,19 +134,28 @@ func (Meter) Float64Gauge(string, ...metric.Float64GaugeOption) (metric.Float64G
|
|||
|
||||
// Float64ObservableCounter returns an ObservableCounter used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Float64ObservableCounter(string, ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
func (Meter) Float64ObservableCounter(
|
||||
string,
|
||||
...metric.Float64ObservableCounterOption,
|
||||
) (metric.Float64ObservableCounter, error) {
|
||||
return Float64ObservableCounter{}, nil
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounter returns an ObservableUpDownCounter used to
|
||||
// record int64 measurements that produces no telemetry.
|
||||
func (Meter) Float64ObservableUpDownCounter(string, ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
func (Meter) Float64ObservableUpDownCounter(
|
||||
string,
|
||||
...metric.Float64ObservableUpDownCounterOption,
|
||||
) (metric.Float64ObservableUpDownCounter, error) {
|
||||
return Float64ObservableUpDownCounter{}, nil
|
||||
}
|
||||
|
||||
// Float64ObservableGauge returns an ObservableGauge used to record int64
|
||||
// measurements that produces no telemetry.
|
||||
func (Meter) Float64ObservableGauge(string, ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
func (Meter) Float64ObservableGauge(
|
||||
string,
|
||||
...metric.Float64ObservableGaugeOption,
|
||||
) (metric.Float64ObservableGauge, error) {
|
||||
return Float64ObservableGauge{}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,21 @@ func (b Baggage) Inject(ctx context.Context, carrier TextMapCarrier) {
|
|||
}
|
||||
|
||||
// Extract returns a copy of parent with the baggage from the carrier added.
|
||||
// If carrier implements [ValuesGetter] (e.g. [HeaderCarrier]), Values is invoked
|
||||
// for multiple values extraction. Otherwise, Get is called.
|
||||
func (b Baggage) Extract(parent context.Context, carrier TextMapCarrier) context.Context {
|
||||
if multiCarrier, ok := carrier.(ValuesGetter); ok {
|
||||
return extractMultiBaggage(parent, multiCarrier)
|
||||
}
|
||||
return extractSingleBaggage(parent, carrier)
|
||||
}
|
||||
|
||||
// Fields returns the keys who's values are set with Inject.
|
||||
func (b Baggage) Fields() []string {
|
||||
return []string{baggageHeader}
|
||||
}
|
||||
|
||||
func extractSingleBaggage(parent context.Context, carrier TextMapCarrier) context.Context {
|
||||
bStr := carrier.Get(baggageHeader)
|
||||
if bStr == "" {
|
||||
return parent
|
||||
|
@ -41,7 +55,23 @@ func (b Baggage) Extract(parent context.Context, carrier TextMapCarrier) context
|
|||
return baggage.ContextWithBaggage(parent, bag)
|
||||
}
|
||||
|
||||
// Fields returns the keys who's values are set with Inject.
|
||||
func (b Baggage) Fields() []string {
|
||||
return []string{baggageHeader}
|
||||
func extractMultiBaggage(parent context.Context, carrier ValuesGetter) context.Context {
|
||||
bVals := carrier.Values(baggageHeader)
|
||||
if len(bVals) == 0 {
|
||||
return parent
|
||||
}
|
||||
var members []baggage.Member
|
||||
for _, bStr := range bVals {
|
||||
currBag, err := baggage.Parse(bStr)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
members = append(members, currBag.Members()...)
|
||||
}
|
||||
|
||||
b, err := baggage.New(members...)
|
||||
if err != nil || b.Len() == 0 {
|
||||
return parent
|
||||
}
|
||||
return baggage.ContextWithBaggage(parent, b)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
)
|
||||
|
||||
// TextMapCarrier is the storage medium used by a TextMapPropagator.
|
||||
// See ValuesGetter for how a TextMapCarrier can get multiple values for a key.
|
||||
type TextMapCarrier interface {
|
||||
// DO NOT CHANGE: any modification will not be backwards compatible and
|
||||
// must never be done outside of a new major release.
|
||||
|
@ -29,6 +30,18 @@ type TextMapCarrier interface {
|
|||
// must never be done outside of a new major release.
|
||||
}
|
||||
|
||||
// ValuesGetter can return multiple values for a single key,
|
||||
// with contrast to TextMapCarrier.Get which returns a single value.
|
||||
type ValuesGetter interface {
|
||||
// DO NOT CHANGE: any modification will not be backwards compatible and
|
||||
// must never be done outside of a new major release.
|
||||
|
||||
// Values returns all values associated with the passed key.
|
||||
Values(key string) []string
|
||||
// DO NOT CHANGE: any modification will not be backwards compatible and
|
||||
// must never be done outside of a new major release.
|
||||
}
|
||||
|
||||
// MapCarrier is a TextMapCarrier that uses a map held in memory as a storage
|
||||
// medium for propagated key-value pairs.
|
||||
type MapCarrier map[string]string
|
||||
|
@ -55,14 +68,25 @@ func (c MapCarrier) Keys() []string {
|
|||
return keys
|
||||
}
|
||||
|
||||
// HeaderCarrier adapts http.Header to satisfy the TextMapCarrier interface.
|
||||
// HeaderCarrier adapts http.Header to satisfy the TextMapCarrier and ValuesGetter interfaces.
|
||||
type HeaderCarrier http.Header
|
||||
|
||||
// Get returns the value associated with the passed key.
|
||||
// Compile time check that HeaderCarrier implements ValuesGetter.
|
||||
var _ TextMapCarrier = HeaderCarrier{}
|
||||
|
||||
// Compile time check that HeaderCarrier implements TextMapCarrier.
|
||||
var _ ValuesGetter = HeaderCarrier{}
|
||||
|
||||
// Get returns the first value associated with the passed key.
|
||||
func (hc HeaderCarrier) Get(key string) string {
|
||||
return http.Header(hc).Get(key)
|
||||
}
|
||||
|
||||
// Values returns all values associated with the passed key.
|
||||
func (hc HeaderCarrier) Values(key string) []string {
|
||||
return http.Header(hc).Values(key)
|
||||
}
|
||||
|
||||
// Set stores the key-value pair.
|
||||
func (hc HeaderCarrier) Set(key string, value string) {
|
||||
http.Header(hc).Set(key, value)
|
||||
|
@ -89,6 +113,8 @@ type TextMapPropagator interface {
|
|||
// must never be done outside of a new major release.
|
||||
|
||||
// Extract reads cross-cutting concerns from the carrier into a Context.
|
||||
// Implementations may check if the carrier implements ValuesGetter,
|
||||
// to support extraction of multiple values per key.
|
||||
Extract(ctx context.Context, carrier TextMapCarrier) context.Context
|
||||
// DO NOT CHANGE: any modification will not be backwards compatible and
|
||||
// must never be done outside of a new major release.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:best-practices"
|
||||
"config:best-practices",
|
||||
"helpers:pinGitHubActionDigestsToSemver"
|
||||
],
|
||||
"ignorePaths": [],
|
||||
"labels": ["Skip Changelog", "dependencies"],
|
||||
|
@ -25,6 +26,10 @@
|
|||
{
|
||||
"matchPackageNames": ["golang.org/x/**"],
|
||||
"groupName": "golang.org/x"
|
||||
},
|
||||
{
|
||||
"matchPackageNames": ["go.opentelemetry.io/otel/sdk/log/logtest"],
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -57,14 +57,15 @@ type autoTracer struct {
|
|||
var _ Tracer = autoTracer{}
|
||||
|
||||
func (t autoTracer) Start(ctx context.Context, name string, opts ...SpanStartOption) (context.Context, Span) {
|
||||
var psc SpanContext
|
||||
var psc, sc SpanContext
|
||||
sampled := true
|
||||
span := new(autoSpan)
|
||||
|
||||
// Ask eBPF for sampling decision and span context info.
|
||||
t.start(ctx, span, &psc, &sampled, &span.spanContext)
|
||||
t.start(ctx, span, &psc, &sampled, &sc)
|
||||
|
||||
span.sampled.Store(sampled)
|
||||
span.spanContext = sc
|
||||
|
||||
ctx = ContextWithSpan(ctx, span)
|
||||
|
||||
|
|
|
@ -251,13 +251,20 @@ func (s *Span) UnmarshalJSON(data []byte) error {
|
|||
type SpanFlags int32
|
||||
|
||||
const (
|
||||
// SpanFlagsTraceFlagsMask is a mask for trace-flags.
|
||||
//
|
||||
// Bits 0-7 are used for trace flags.
|
||||
SpanFlagsTraceFlagsMask SpanFlags = 255
|
||||
// Bits 8 and 9 are used to indicate that the parent span or link span is remote.
|
||||
// Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
|
||||
// Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote.
|
||||
// SpanFlagsContextHasIsRemoteMask is a mask for HAS_IS_REMOTE status.
|
||||
//
|
||||
// Bits 8 and 9 are used to indicate that the parent span or link span is
|
||||
// remote. Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
|
||||
SpanFlagsContextHasIsRemoteMask SpanFlags = 256
|
||||
// SpanFlagsContextHasIsRemoteMask indicates the Span is remote.
|
||||
// SpanFlagsContextIsRemoteMask is a mask for IS_REMOTE status.
|
||||
//
|
||||
// Bits 8 and 9 are used to indicate that the parent span or link span is
|
||||
// remote. Bit 9 (`IS_REMOTE`) indicates whether the span or link is
|
||||
// remote.
|
||||
SpanFlagsContextIsRemoteMask SpanFlags = 512
|
||||
)
|
||||
|
||||
|
@ -266,27 +273,31 @@ const (
|
|||
type SpanKind int32
|
||||
|
||||
const (
|
||||
// Indicates that the span represents an internal operation within an application,
|
||||
// as opposed to an operation happening at the boundaries. Default value.
|
||||
// SpanKindInternal indicates that the span represents an internal
|
||||
// operation within an application, as opposed to an operation happening at
|
||||
// the boundaries.
|
||||
SpanKindInternal SpanKind = 1
|
||||
// Indicates that the span covers server-side handling of an RPC or other
|
||||
// remote network request.
|
||||
// SpanKindServer indicates that the span covers server-side handling of an
|
||||
// RPC or other remote network request.
|
||||
SpanKindServer SpanKind = 2
|
||||
// Indicates that the span describes a request to some remote service.
|
||||
// SpanKindClient indicates that the span describes a request to some
|
||||
// remote service.
|
||||
SpanKindClient SpanKind = 3
|
||||
// Indicates that the span describes a producer sending a message to a broker.
|
||||
// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans. A PRODUCER span ends when the message was accepted
|
||||
// by the broker while the logical processing of the message might span a much longer time.
|
||||
// SpanKindProducer indicates that the span describes a producer sending a
|
||||
// message to a broker. Unlike SpanKindClient and SpanKindServer, there is
|
||||
// often no direct critical path latency relationship between producer and
|
||||
// consumer spans. A SpanKindProducer span ends when the message was
|
||||
// accepted by the broker while the logical processing of the message might
|
||||
// span a much longer time.
|
||||
SpanKindProducer SpanKind = 4
|
||||
// Indicates that the span describes consumer receiving a message from a broker.
|
||||
// Like the PRODUCER kind, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans.
|
||||
// SpanKindConsumer indicates that the span describes a consumer receiving
|
||||
// a message from a broker. Like SpanKindProducer, there is often no direct
|
||||
// critical path latency relationship between producer and consumer spans.
|
||||
SpanKindConsumer SpanKind = 5
|
||||
)
|
||||
|
||||
// Event is a time-stamped annotation of the span, consisting of user-supplied
|
||||
// text description and key-value pairs.
|
||||
// SpanEvent is a time-stamped annotation of the span, consisting of
|
||||
// user-supplied text description and key-value pairs.
|
||||
type SpanEvent struct {
|
||||
// time_unix_nano is the time the event occurred.
|
||||
Time time.Time `json:"timeUnixNano,omitempty"`
|
||||
|
@ -369,10 +380,11 @@ func (se *SpanEvent) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// A pointer from the current span to another span in the same trace or in a
|
||||
// different trace. For example, this can be used in batching operations,
|
||||
// where a single batch handler processes multiple requests from different
|
||||
// traces or when the handler receives a request from a different project.
|
||||
// SpanLink is a reference from the current span to another span in the same
|
||||
// trace or in a different trace. For example, this can be used in batching
|
||||
// operations, where a single batch handler processes multiple requests from
|
||||
// different traces or when the handler receives a request from a different
|
||||
// project.
|
||||
type SpanLink struct {
|
||||
// A unique identifier of a trace that this linked span is part of. The ID is a
|
||||
// 16-byte array.
|
||||
|
|
|
@ -3,17 +3,19 @@
|
|||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
// StatusCode is the status of a Span.
|
||||
//
|
||||
// For the semantics of status codes see
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
|
||||
type StatusCode int32
|
||||
|
||||
const (
|
||||
// The default status.
|
||||
// StatusCodeUnset is the default status.
|
||||
StatusCodeUnset StatusCode = 0
|
||||
// The Span has been validated by an Application developer or Operator to
|
||||
// have completed successfully.
|
||||
// StatusCodeOK is used when the Span has been validated by an Application
|
||||
// developer or Operator to have completed successfully.
|
||||
StatusCodeOK StatusCode = 1
|
||||
// The Span contains an error.
|
||||
// StatusCodeError is used when the Span contains an error.
|
||||
StatusCodeError StatusCode = 2
|
||||
)
|
||||
|
||||
|
@ -30,7 +32,7 @@ func (s StatusCode) String() string {
|
|||
return "<unknown telemetry.StatusCode>"
|
||||
}
|
||||
|
||||
// The Status type defines a logical error model that is suitable for different
|
||||
// Status defines a logical error model that is suitable for different
|
||||
// programming environments, including REST APIs and RPC APIs.
|
||||
type Status struct {
|
||||
// A developer-facing human readable error message.
|
||||
|
|
|
@ -71,7 +71,7 @@ func (td *Traces) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// A collection of ScopeSpans from a Resource.
|
||||
// ResourceSpans is a collection of ScopeSpans from a Resource.
|
||||
type ResourceSpans struct {
|
||||
// The resource for the spans in this message.
|
||||
// If this field is not set then no resource info is known.
|
||||
|
@ -128,7 +128,7 @@ func (rs *ResourceSpans) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// A collection of Spans produced by an InstrumentationScope.
|
||||
// ScopeSpans is a collection of Spans produced by an InstrumentationScope.
|
||||
type ScopeSpans struct {
|
||||
// The instrumentation scope information for the spans in this message.
|
||||
// Semantically when InstrumentationScope isn't set, it is equivalent with
|
||||
|
|
|
@ -316,7 +316,7 @@ func (v Value) String() string {
|
|||
case ValueKindBool:
|
||||
return strconv.FormatBool(v.asBool())
|
||||
case ValueKindBytes:
|
||||
return fmt.Sprint(v.asBytes())
|
||||
return string(v.asBytes())
|
||||
case ValueKindMap:
|
||||
return fmt.Sprint(v.asMap())
|
||||
case ValueKindSlice:
|
||||
|
|
|
@ -95,6 +95,8 @@ var autoInstEnabled = new(bool)
|
|||
// tracerProvider return a noopTracerProvider if autoEnabled is false,
|
||||
// otherwise it will return a TracerProvider from the sdk package used in
|
||||
// auto-instrumentation.
|
||||
//
|
||||
//go:noinline
|
||||
func (noopSpan) tracerProvider(autoEnabled *bool) TracerProvider {
|
||||
if *autoEnabled {
|
||||
return newAutoTracerProvider()
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright The OpenTelemetry Authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
dirs=$(find . -type d -not -path "*/internal*" -not -path "*/test*" -not -path "*/example*" -not -path "*/.*" | sort)
|
||||
|
||||
missingReadme=false
|
||||
for dir in $dirs; do
|
||||
if [ ! -f "$dir/README.md" ]; then
|
||||
echo "couldn't find README.md for $dir"
|
||||
missingReadme=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$missingReadme" = true ] ; then
|
||||
echo "Error: some READMEs couldn't be found."
|
||||
exit 1
|
||||
fi
|
|
@ -5,5 +5,5 @@ package otel // import "go.opentelemetry.io/otel"
|
|||
|
||||
// Version is the current release version of OpenTelemetry in use.
|
||||
func Version() string {
|
||||
return "1.35.0"
|
||||
return "1.36.0"
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
module-sets:
|
||||
stable-v1:
|
||||
version: v1.35.0
|
||||
version: v1.36.0
|
||||
modules:
|
||||
- go.opentelemetry.io/otel
|
||||
- go.opentelemetry.io/otel/bridge/opencensus
|
||||
|
@ -23,11 +23,11 @@ module-sets:
|
|||
- go.opentelemetry.io/otel/sdk/metric
|
||||
- go.opentelemetry.io/otel/trace
|
||||
experimental-metrics:
|
||||
version: v0.57.0
|
||||
version: v0.58.0
|
||||
modules:
|
||||
- go.opentelemetry.io/otel/exporters/prometheus
|
||||
experimental-logs:
|
||||
version: v0.11.0
|
||||
version: v0.12.0
|
||||
modules:
|
||||
- go.opentelemetry.io/otel/log
|
||||
- go.opentelemetry.io/otel/sdk/log
|
||||
|
@ -40,4 +40,6 @@ module-sets:
|
|||
- go.opentelemetry.io/otel/schema
|
||||
excluded-modules:
|
||||
- go.opentelemetry.io/otel/internal/tools
|
||||
- go.opentelemetry.io/otel/log/logtest
|
||||
- go.opentelemetry.io/otel/sdk/log/logtest
|
||||
- go.opentelemetry.io/otel/trace/internal/telemetry/test
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// DeepCopyDescriptor copies a Descriptor, deeply copying its contents
|
||||
// DeepCopyDescriptor copies a Descriptor, deeply copying its contents.
|
||||
func DeepCopyDescriptor(original *v1.Descriptor) *v1.Descriptor {
|
||||
tmp := *original
|
||||
if original.URLs != nil {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -396,7 +397,7 @@ func (c *Copier) copyInternal(ctx context.Context, source, destination types.Ima
|
|||
// TimeoutStartSec=, the service manager will allow the service to continue to start, provided the
|
||||
// service repeats "EXTEND_TIMEOUT_USEC=..." within the interval specified until the service startup
|
||||
// status is finished by "READY=1"."
|
||||
extendValue := []byte(fmt.Sprintf("EXTEND_TIMEOUT_USEC=%d", extension.Microseconds()))
|
||||
extendValue := fmt.Appendf(nil, "EXTEND_TIMEOUT_USEC=%d", extension.Microseconds())
|
||||
extendTimeout := func() {
|
||||
if _, err := conn.Write(extendValue); err != nil {
|
||||
logrus.Errorf("Increasing EXTEND_TIMEOUT_USEC failed: %v", err)
|
||||
|
@ -555,11 +556,9 @@ func checkRegistrySourcesAllows(dest types.ImageReference) (insecure *bool, err
|
|||
return nil, fmt.Errorf("registry %q denied by policy: not in allowed registries list (%s)", reference.Domain(dref), registrySources)
|
||||
}
|
||||
|
||||
for _, insecureDomain := range sources.InsecureRegistries {
|
||||
if insecureDomain == reference.Domain(dref) {
|
||||
insecure := true
|
||||
return &insecure, nil
|
||||
}
|
||||
if slices.Contains(sources.InsecureRegistries, reference.Domain(dref)) {
|
||||
insecure := true
|
||||
return &insecure, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"go.podman.io/storage"
|
||||
)
|
||||
|
||||
// ImageDiskUsage reports the total size of an image. That is the size
|
||||
// ImageDiskUsage reports the total size of an image. That is the size.
|
||||
type ImageDiskUsage struct {
|
||||
// Number of containers using the image.
|
||||
Containers int
|
||||
|
|
|
@ -24,25 +24,25 @@ type SearchFilter struct {
|
|||
func ParseSearchFilter(filter []string) (*SearchFilter, error) {
|
||||
sFilter := new(SearchFilter)
|
||||
for _, f := range filter {
|
||||
arr := strings.SplitN(f, "=", 2)
|
||||
switch arr[0] {
|
||||
keyword, value, ok := strings.Cut(f, "=")
|
||||
switch keyword {
|
||||
case define.SearchFilterStars:
|
||||
if len(arr) < 2 {
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid filter %q, should be stars=<value>", filter)
|
||||
}
|
||||
stars, err := strconv.Atoi(arr[1])
|
||||
stars, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("incorrect value type for stars filter: %w", err)
|
||||
}
|
||||
sFilter.Stars = stars
|
||||
case define.SearchFilterAutomated:
|
||||
if len(arr) == 2 && arr[1] == "false" {
|
||||
if ok && value == "false" {
|
||||
sFilter.IsAutomated = types.OptionalBoolFalse
|
||||
} else {
|
||||
sFilter.IsAutomated = types.OptionalBoolTrue
|
||||
}
|
||||
case define.SearchFilterOfficial:
|
||||
if len(arr) == 2 && arr[1] == "false" {
|
||||
if ok && value == "false" {
|
||||
sFilter.IsOfficial = types.OptionalBoolFalse
|
||||
} else {
|
||||
sFilter.IsOfficial = types.OptionalBoolTrue
|
||||
|
|
|
@ -72,7 +72,7 @@ func (r *Runtime) filterImages(ctx context.Context, images []*Image, filters com
|
|||
//
|
||||
// after, since, before, containers, dangling, id, label, readonly, reference, intermediate
|
||||
//
|
||||
// compileImageFilters returns: compiled filters, if LayerTree is needed, error
|
||||
// compileImageFilters returns: compiled filters, if LayerTree is needed, error.
|
||||
func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOptions) (compiledFilters, bool, error) {
|
||||
logrus.Tracef("Parsing image filters %s", options.Filters)
|
||||
if len(options.Filters) == 0 {
|
||||
|
@ -89,18 +89,16 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
|
|||
var key, value string
|
||||
var filter filterFunc
|
||||
negate := false
|
||||
split := strings.SplitN(f, "!=", 2)
|
||||
if len(split) == 2 {
|
||||
key, value, ok := strings.Cut(f, "!=")
|
||||
if ok {
|
||||
negate = true
|
||||
} else {
|
||||
split = strings.SplitN(f, "=", 2)
|
||||
if len(split) != 2 {
|
||||
key, value, ok = strings.Cut(f, "=")
|
||||
if !ok {
|
||||
return nil, false, fmt.Errorf(filterInvalidValue, f)
|
||||
}
|
||||
}
|
||||
|
||||
key = split[0]
|
||||
value = split[1]
|
||||
switch key {
|
||||
case "after", "since":
|
||||
img, err := r.time(key, value)
|
||||
|
@ -254,7 +252,7 @@ func (r *Runtime) bool(duplicate map[string]string, key, value string) (bool, er
|
|||
return set, nil
|
||||
}
|
||||
|
||||
// filterManifest filters whether or not the image is a manifest list
|
||||
// filterManifest filters whether or not the image is a manifest list.
|
||||
func filterManifest(ctx context.Context, value bool) filterFunc {
|
||||
return func(img *Image, _ *layerTree) (bool, error) {
|
||||
isManifestList, err := img.IsManifestList(ctx)
|
||||
|
@ -266,7 +264,7 @@ func filterManifest(ctx context.Context, value bool) filterFunc {
|
|||
}
|
||||
|
||||
// filterReferences creates a reference filter for matching the specified wantedReferenceMatches value (OR logic)
|
||||
// and for matching the unwantedReferenceMatches values (AND logic)
|
||||
// and for matching the unwantedReferenceMatches values (AND logic).
|
||||
func filterReferences(r *Runtime, wantedReferenceMatches, unwantedReferenceMatches []string) filterFunc {
|
||||
return func(img *Image, _ *layerTree) (bool, error) {
|
||||
// Empty reference filters, return true
|
||||
|
@ -357,7 +355,7 @@ func nameMatchesReference(name string, ref reference.Named) bool {
|
|||
return name == ref.String()
|
||||
}
|
||||
|
||||
// imageMatchesReferenceFilter returns true if an image matches the filter value given
|
||||
// imageMatchesReferenceFilter returns true if an image matches the filter value given.
|
||||
func imageMatchesReferenceFilter(r *Runtime, img *Image, value string) (bool, error) {
|
||||
lookedUp, _, _ := r.LookupImage(value, nil)
|
||||
if lookedUp != nil {
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -173,12 +174,7 @@ func (i *Image) Digests() []digest.Digest {
|
|||
// hasDigest returns whether the specified value matches any digest of the
|
||||
// image.
|
||||
func (i *Image) hasDigest(wantedDigest digest.Digest) bool {
|
||||
for _, d := range i.Digests() {
|
||||
if d == wantedDigest {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(i.Digests(), wantedDigest)
|
||||
}
|
||||
|
||||
// containsDigestPrefix returns whether the specified value matches any digest of the
|
||||
|
@ -267,12 +263,12 @@ func (i *Image) Labels(ctx context.Context) (map[string]string, error) {
|
|||
return data.Labels, nil
|
||||
}
|
||||
|
||||
// TopLayer returns the top layer id as a string
|
||||
// TopLayer returns the top layer id as a string.
|
||||
func (i *Image) TopLayer() string {
|
||||
return i.storageImage.TopLayer
|
||||
}
|
||||
|
||||
// Parent returns the parent image or nil if there is none
|
||||
// Parent returns the parent image or nil if there is none.
|
||||
func (i *Image) Parent(ctx context.Context) (*Image, error) {
|
||||
tree, err := i.runtime.newFreshLayerTree()
|
||||
if err != nil {
|
||||
|
@ -383,7 +379,7 @@ func (i *Image) removeContainers(options *RemoveImagesOptions) error {
|
|||
// an image specified by imageID.
|
||||
type RemoveContainerFunc func(imageID string) error
|
||||
|
||||
// RemoveImagesReport is the assembled data from removing *one* image.
|
||||
// RemoveImageReport is the assembled data from removing *one* image.
|
||||
type RemoveImageReport struct {
|
||||
// ID of the image.
|
||||
ID string
|
||||
|
@ -638,16 +634,9 @@ func (i *Image) Untag(name string) error {
|
|||
|
||||
name = ref.String()
|
||||
|
||||
foundName := false
|
||||
for _, n := range i.Names() {
|
||||
if n == name {
|
||||
foundName = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// Return an error if the name is not found, the c/storage
|
||||
// RemoveNames() API does not create one if no match is found.
|
||||
if !foundName {
|
||||
if !slices.Contains(i.Names(), name) {
|
||||
return fmt.Errorf("%s: %w", name, errTagUnknown)
|
||||
}
|
||||
|
||||
|
@ -942,7 +931,7 @@ func (i *Image) hasDifferentDigestWithSystemContext(ctx context.Context, remoteR
|
|||
return true, nil
|
||||
}
|
||||
|
||||
// driverData gets the driver data from the store on a layer
|
||||
// driverData gets the driver data from the store on a layer.
|
||||
func (i *Image) driverData() (*DriverData, error) {
|
||||
store := i.runtime.store
|
||||
layerID := i.TopLayer()
|
||||
|
@ -995,7 +984,7 @@ func (i *Image) source(ctx context.Context) (types.ImageSource, error) {
|
|||
}
|
||||
|
||||
// rawConfigBlob returns the image's config as a raw byte slice. Users need to
|
||||
// unmarshal it to the corresponding type (OCI, Docker v2s{1,2})
|
||||
// unmarshal it to the corresponding type (OCI, Docker v2s{1,2}).
|
||||
func (i *Image) rawConfigBlob(ctx context.Context) ([]byte, error) {
|
||||
ref, err := i.StorageReference()
|
||||
if err != nil {
|
||||
|
@ -1021,7 +1010,7 @@ func (i *Image) Manifest(ctx context.Context) (rawManifest []byte, mimeType stri
|
|||
}
|
||||
|
||||
// getImageID creates an image object and uses the hex value of the config
|
||||
// blob's digest (if it has one) as the image ID for parsing the store reference
|
||||
// blob's digest (if it has one) as the image ID for parsing the store reference.
|
||||
func getImageID(ctx context.Context, src types.ImageReference, sys *types.SystemContext) (string, error) {
|
||||
newImg, err := src.NewImage(ctx, sys)
|
||||
if err != nil {
|
||||
|
|
|
@ -33,24 +33,24 @@ type ImageConfig struct {
|
|||
// * WORKDIR
|
||||
// * LABEL
|
||||
// * STOPSIGNAL
|
||||
// * ONBUILD
|
||||
// * ONBUILD.
|
||||
func ImageConfigFromChanges(changes []string) (*ImageConfig, error) { // nolint:gocyclo
|
||||
config := &ImageConfig{}
|
||||
|
||||
for _, change := range changes {
|
||||
// First, let's assume proper Dockerfile format - space
|
||||
// separator between instruction and value
|
||||
split := strings.SplitN(change, " ", 2)
|
||||
outerKey, value, ok := strings.Cut(change, " ")
|
||||
|
||||
if len(split) != 2 {
|
||||
split = strings.SplitN(change, "=", 2)
|
||||
if len(split) != 2 {
|
||||
if !ok {
|
||||
outerKey, value, ok = strings.Cut(change, "=")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid change %q - must be formatted as KEY VALUE", change)
|
||||
}
|
||||
}
|
||||
|
||||
outerKey := strings.ToUpper(strings.TrimSpace(split[0]))
|
||||
value := strings.TrimSpace(split[1])
|
||||
outerKey = strings.ToUpper(strings.TrimSpace(outerKey))
|
||||
value = strings.TrimSpace(value)
|
||||
switch outerKey {
|
||||
case "USER":
|
||||
// Assume literal contents are the user.
|
||||
|
@ -96,18 +96,11 @@ func ImageConfigFromChanges(changes []string) (*ImageConfig, error) { // nolint:
|
|||
// For now: we only support key=value
|
||||
// We will attempt to strip quotation marks if present.
|
||||
|
||||
var key, val string
|
||||
|
||||
splitEnv := strings.SplitN(value, "=", 2)
|
||||
key = splitEnv[0]
|
||||
key, val, _ := strings.Cut(value, "=") // val is "" if there is no "="
|
||||
// We do need a key
|
||||
if key == "" {
|
||||
return nil, fmt.Errorf("invalid change %q - ENV must have at least one argument", change)
|
||||
}
|
||||
// Perfectly valid to not have a value
|
||||
if len(splitEnv) == 2 {
|
||||
val = splitEnv[1]
|
||||
}
|
||||
|
||||
if strings.HasPrefix(key, `"`) && strings.HasSuffix(key, `"`) {
|
||||
key = strings.TrimPrefix(strings.TrimSuffix(key, `"`), `"`)
|
||||
|
@ -192,17 +185,11 @@ func ImageConfigFromChanges(changes []string) (*ImageConfig, error) { // nolint:
|
|||
// Potentially problematic: LABEL might theoretically
|
||||
// allow an = in the key? If people really do this, we
|
||||
// may need to investigate more advanced parsing.
|
||||
var (
|
||||
key, val string
|
||||
)
|
||||
|
||||
splitLabel := strings.SplitN(value, "=", 2)
|
||||
key, val, ok := strings.Cut(value, "=")
|
||||
// Unlike ENV, LABEL must have a value
|
||||
if len(splitLabel) != 2 {
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid change %q - LABEL must be formatted key=value", change)
|
||||
}
|
||||
key = splitLabel[0]
|
||||
val = splitLabel[1]
|
||||
|
||||
if strings.HasPrefix(key, `"`) && strings.HasSuffix(key, `"`) {
|
||||
key = strings.TrimPrefix(strings.TrimSuffix(key, `"`), `"`)
|
||||
|
|
|
@ -303,10 +303,8 @@ func (m *ManifestList) LookupInstance(ctx context.Context, architecture, os, var
|
|||
}
|
||||
|
||||
for _, image := range allImages {
|
||||
for _, imageDigest := range append(image.Digests(), image.Digest()) {
|
||||
if imageDigest == instanceDigest {
|
||||
return image, nil
|
||||
}
|
||||
if slices.Contains(image.Digests(), instanceDigest) || instanceDigest == image.Digest() {
|
||||
return image, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +320,7 @@ func (m *ManifestList) saveAndReload() error {
|
|||
return m.reloadID(newID)
|
||||
}
|
||||
|
||||
// Reload the image and list instances from storage
|
||||
// Reload the image and list instances from storage.
|
||||
func (m *ManifestList) reload() error {
|
||||
listID := m.ID()
|
||||
return m.reloadID(listID)
|
||||
|
@ -338,7 +336,7 @@ func (m *ManifestList) reloadID(listID string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// getManifestList is a helper to obtain a manifest list
|
||||
// getManifestList is a helper to obtain a manifest list.
|
||||
func (i *Image) getManifestList() (manifests.List, error) {
|
||||
_, list, err := manifests.LoadFromImage(i.runtime.store, i.ID())
|
||||
if errors.Is(err, manifesterrors.ErrManifestTypeNotSupported) {
|
||||
|
@ -441,7 +439,7 @@ func (m *ManifestList) Inspect() (*define.ManifestListData, error) {
|
|||
return &inspectList, nil
|
||||
}
|
||||
|
||||
// Options for adding an image or artifact to a manifest list.
|
||||
// ManifestListAddOptions for adding an image or artifact to a manifest list.
|
||||
type ManifestListAddOptions struct {
|
||||
// Add all images to the list if the to-be-added image itself is a
|
||||
// manifest list.
|
||||
|
@ -538,8 +536,8 @@ func (m *ManifestList) Add(ctx context.Context, name string, options *ManifestLi
|
|||
return newDigest, nil
|
||||
}
|
||||
|
||||
// Options for creating an artifact manifest for one or more files and adding
|
||||
// the artifact manifest to a manifest list.
|
||||
// ManifestListAddArtifactOptions used for creating an artifact manifest for one or more
|
||||
// files and adding the artifact manifest to a manifest list.
|
||||
type ManifestListAddArtifactOptions struct {
|
||||
// The artifactType to set in the artifact manifest.
|
||||
Type *string `json:"artifact_type"`
|
||||
|
@ -557,7 +555,7 @@ type ManifestListAddArtifactOptions struct {
|
|||
Subject string `json:"subject"`
|
||||
}
|
||||
|
||||
// Add adds one or more manifests to the manifest list and returns the digest
|
||||
// AddArtifact adds one or more manifests to the manifest list and returns the digest
|
||||
// of the added instance.
|
||||
func (m *ManifestList) AddArtifact(ctx context.Context, options *ManifestListAddArtifactOptions, files ...string) (digest.Digest, error) {
|
||||
if options == nil {
|
||||
|
@ -628,7 +626,7 @@ func (m *ManifestList) AddArtifact(ctx context.Context, options *ManifestListAdd
|
|||
return newDigest, nil
|
||||
}
|
||||
|
||||
// Options for annotating a manifest list.
|
||||
// ManifestListAnnotateOptions used for annotating a manifest list.
|
||||
type ManifestListAnnotateOptions struct {
|
||||
// Add the specified annotations to the added image. Empty values are ignored.
|
||||
Annotations map[string]string
|
||||
|
@ -650,7 +648,7 @@ type ManifestListAnnotateOptions struct {
|
|||
Subject string
|
||||
}
|
||||
|
||||
// Annotate an image instance specified by `d` in the manifest list.
|
||||
// AnnotateInstance annotates an image instance specified by `d` in the manifest list.
|
||||
func (m *ManifestList) AnnotateInstance(d digest.Digest, options *ManifestListAnnotateOptions) error {
|
||||
ctx := context.Background()
|
||||
|
||||
|
|
|
@ -252,10 +252,8 @@ func (l *list) InstanceByFile(file string) (digest.Digest, error) {
|
|||
return "", err
|
||||
}
|
||||
for instanceDigest, files := range l.artifacts.Files {
|
||||
for _, file := range files {
|
||||
if file == abs {
|
||||
return instanceDigest, nil
|
||||
}
|
||||
if slices.Contains(files, abs) {
|
||||
return instanceDigest, nil
|
||||
}
|
||||
}
|
||||
return "", os.ErrNotExist
|
||||
|
@ -675,7 +673,7 @@ func (l *list) Add(ctx context.Context, sys *types.SystemContext, ref types.Imag
|
|||
// AddArtifactOptions contains options which control the contents of the
|
||||
// artifact manifest that AddArtifact will create and add to the image index.
|
||||
|
||||
// This should provide for all of the ways to construct a manifest outlined in
|
||||
// AddArtifactOptions should provide for all of the ways to construct a manifest outlined in
|
||||
// https://github.com/opencontainers/image-spec/blob/main/manifest.md#guidelines-for-artifact-usage
|
||||
// - no blobs → set ManifestArtifactType
|
||||
// - blobs, no configuration → set ManifestArtifactType and possibly LayerMediaType, and provide file names
|
||||
|
|
|
@ -74,7 +74,7 @@ type NameTagPair struct {
|
|||
named reference.Named
|
||||
}
|
||||
|
||||
// ToNameTagsPairs splits repoTags into name&tag pairs.
|
||||
// ToNameTagPairs splits repoTags into name&tag pairs.
|
||||
// Guaranteed to return at least one pair.
|
||||
func ToNameTagPairs(repoTags []reference.Named) ([]NameTagPair, error) {
|
||||
none := "<none>"
|
||||
|
|
|
@ -28,7 +28,7 @@ func (i *Image) toOCI(ctx context.Context) (*ociv1.Image, error) {
|
|||
}
|
||||
|
||||
// historiesMatch returns the number of entries in the histories which have the
|
||||
// same contents
|
||||
// same contents.
|
||||
func historiesMatch(a, b []ociv1.History) int {
|
||||
i := 0
|
||||
for i < len(a) && i < len(b) {
|
||||
|
@ -61,7 +61,7 @@ func historiesMatch(a, b []ociv1.History) int {
|
|||
}
|
||||
|
||||
// areParentAndChild checks diff ID and history in the two images and return
|
||||
// true if the second should be considered to be directly based on the first
|
||||
// true if the second should be considered to be directly based on the first.
|
||||
func areParentAndChild(parent, child *ociv1.Image) bool {
|
||||
// the child and candidate parent should share all of the
|
||||
// candidate parent's diff IDs, which together would have
|
||||
|
|
|
@ -253,8 +253,8 @@ func (r *Runtime) copyFromDefault(ctx context.Context, ref types.ImageReference,
|
|||
storageName = imageName
|
||||
|
||||
case ociTransport.Transport.Name():
|
||||
split := strings.SplitN(ref.StringWithinTransport(), ":", 2)
|
||||
if len(split) == 1 || split[1] == "" {
|
||||
_, refName, ok := strings.Cut(ref.StringWithinTransport(), ":")
|
||||
if !ok || refName == "" {
|
||||
// Same trick as for the dir transport: we cannot use
|
||||
// the path to a directory as the name.
|
||||
storageName, err = getImageID(ctx, ref, nil)
|
||||
|
@ -263,7 +263,7 @@ func (r *Runtime) copyFromDefault(ctx context.Context, ref types.ImageReference,
|
|||
}
|
||||
imageName = "sha256:" + storageName[1:]
|
||||
} else { // If the OCI-reference includes an image reference, use it
|
||||
storageName = split[1]
|
||||
storageName = refName
|
||||
imageName = storageName
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ type Runtime struct {
|
|||
systemContext types.SystemContext
|
||||
}
|
||||
|
||||
// Returns a copy of the runtime's system context.
|
||||
// SystemContext returns a copy of the runtime's system context.
|
||||
func (r *Runtime) SystemContext() *types.SystemContext {
|
||||
return r.systemContextCopy()
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ func (r *Runtime) storageToImage(storageImage *storage.Image, ref types.ImageRef
|
|||
}
|
||||
}
|
||||
|
||||
// getImagesAndLayers obtains consistent slices of Image and storage.Layer
|
||||
// getImagesAndLayers obtains consistent slices of Image and storage.Layer.
|
||||
func (r *Runtime) getImagesAndLayers() ([]*Image, []storage.Layer, error) {
|
||||
snapshot, err := r.store.MultiList(
|
||||
storage.MultiListOptions{
|
||||
|
@ -225,7 +225,7 @@ type LookupImageOptions struct {
|
|||
|
||||
var errNoHexValue = errors.New("invalid format: no 64-byte hexadecimal value")
|
||||
|
||||
// Lookup Image looks up `name` in the local container storage. Returns the
|
||||
// LookupImage looks up `name` in the local container storage. Returns the
|
||||
// image and the name it has been found with. Note that name may also use the
|
||||
// `containers-storage:` prefix used to refer to the containers-storage
|
||||
// transport. Returns storage.ErrImageUnknown if the image could not be found.
|
||||
|
|
|
@ -94,11 +94,11 @@ func (r *Runtime) Search(ctx context.Context, term string, options *SearchOption
|
|||
// that we cannot use the reference parser from the containers/image
|
||||
// library as the search term may container arbitrary input such as
|
||||
// wildcards. See bugzilla.redhat.com/show_bug.cgi?id=1846629.
|
||||
spl := strings.SplitN(term, "/", 2)
|
||||
perhapsRegistry, perhapsTerm, ok := strings.Cut(term, "/")
|
||||
switch {
|
||||
case len(spl) > 1:
|
||||
searchRegistries = []string{spl[0]}
|
||||
term = spl[1]
|
||||
case ok:
|
||||
searchRegistries = []string{perhapsRegistry}
|
||||
term = perhapsTerm
|
||||
case len(options.Registries) > 0:
|
||||
searchRegistries = options.Registries
|
||||
default:
|
||||
|
@ -203,15 +203,9 @@ func (r *Runtime) searchImageInRegistry(ctx context.Context, term, registry stri
|
|||
// limit is the number of results to output
|
||||
// if the total number of results is less than the limit, output all
|
||||
// if the limit has been set by the user, output those number of queries
|
||||
limit = searchMaxQueries
|
||||
if len(results) < limit {
|
||||
limit = len(results)
|
||||
}
|
||||
limit = min(len(results), searchMaxQueries)
|
||||
if options.Limit != 0 {
|
||||
limit = len(results)
|
||||
if options.Limit < len(results) {
|
||||
limit = options.Limit
|
||||
}
|
||||
limit = min(len(results), options.Limit)
|
||||
}
|
||||
|
||||
paramsArr := []SearchResult{}
|
||||
|
@ -264,15 +258,9 @@ func searchRepositoryTags(ctx context.Context, sys *types.SystemContext, registr
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("getting repository tags: %v", err)
|
||||
}
|
||||
limit := searchMaxQueries
|
||||
if len(tags) < limit {
|
||||
limit = len(tags)
|
||||
}
|
||||
limit := min(len(tags), searchMaxQueries)
|
||||
if options.Limit != 0 {
|
||||
limit = len(tags)
|
||||
if options.Limit < limit {
|
||||
limit = options.Limit
|
||||
}
|
||||
limit = min(len(tags), options.Limit)
|
||||
}
|
||||
paramsArr := []SearchResult{}
|
||||
for i := range limit {
|
||||
|
|
|
@ -213,7 +213,7 @@ func convertIPAMConfToNetwork(network *types.Network, ipam *ipamConfig, confPath
|
|||
return nil
|
||||
}
|
||||
|
||||
// getNetworkArgsFromConfList returns the map of args in a conflist, argType should be labels or options
|
||||
// getNetworkArgsFromConfList returns the map of args in a conflist, argType should be labels or options.
|
||||
func getNetworkArgsFromConfList(args map[string]any, argType string) map[string]string {
|
||||
if args, ok := args[argType]; ok {
|
||||
if labels, ok := args.(map[string]any); ok {
|
||||
|
@ -355,9 +355,7 @@ func convertSpecgenPortsToCNIPorts(ports []types.PortMapping) ([]cniPortMapEntry
|
|||
if port.Protocol == "" {
|
||||
return nil, errors.New("port protocol should not be empty")
|
||||
}
|
||||
protocols := strings.Split(port.Protocol, ",")
|
||||
|
||||
for _, protocol := range protocols {
|
||||
for protocol := range strings.SplitSeq(port.Protocol, ",") {
|
||||
if !slices.Contains([]string{"tcp", "udp", "sctp"}, protocol) {
|
||||
return nil, fmt.Errorf("unknown port protocol %s", protocol)
|
||||
}
|
||||
|
|
|
@ -14,19 +14,19 @@ const (
|
|||
defaultIPv4Route = "0.0.0.0/0"
|
||||
defaultIPv6Route = "::/0"
|
||||
// defaultPodmanDomainName is used for the dnsname plugin to define
|
||||
// a localized domain name for a created network
|
||||
// a localized domain name for a created network.
|
||||
defaultPodmanDomainName = "dns.podman"
|
||||
|
||||
// cniDeviceName is the default name for a new bridge, it should be suffixed with an integer
|
||||
// cniDeviceName is the default name for a new bridge, it should be suffixed with an integer.
|
||||
cniDeviceName = "cni-podman"
|
||||
|
||||
// podmanLabelKey key used to store the podman network label in a cni config
|
||||
// podmanLabelKey key used to store the podman network label in a cni config.
|
||||
podmanLabelKey = "podman_labels"
|
||||
|
||||
// podmanOptionsKey key used to store the podman network options in a cni config
|
||||
// podmanOptionsKey key used to store the podman network options in a cni config.
|
||||
podmanOptionsKey = "podman_options"
|
||||
|
||||
// ingressPolicySameBridge is used to only allow connection on the same bridge network
|
||||
// ingressPolicySameBridge is used to only allow connection on the same bridge network.
|
||||
ingressPolicySameBridge = "same-bridge"
|
||||
)
|
||||
|
||||
|
@ -66,7 +66,7 @@ type ipamConfig struct {
|
|||
Ranges [][]ipamLocalHostRangeConf `json:"ranges,omitempty"`
|
||||
}
|
||||
|
||||
// ipamLocalHostRangeConf describes the new style IPAM ranges
|
||||
// ipamLocalHostRangeConf describes the new style IPAM ranges.
|
||||
type ipamLocalHostRangeConf struct {
|
||||
Subnet string `json:"subnet"`
|
||||
RangeStart string `json:"rangeStart,omitempty"`
|
||||
|
@ -74,18 +74,18 @@ type ipamLocalHostRangeConf struct {
|
|||
Gateway string `json:"gateway,omitempty"`
|
||||
}
|
||||
|
||||
// ipamRoute describes a route in an ipam config
|
||||
// ipamRoute describes a route in an ipam config.
|
||||
type ipamRoute struct {
|
||||
Dest string `json:"dst"`
|
||||
}
|
||||
|
||||
// portMapConfig describes the default portmapping config
|
||||
// portMapConfig describes the default portmapping config.
|
||||
type portMapConfig struct {
|
||||
PluginType string `json:"type"`
|
||||
Capabilities map[string]bool `json:"capabilities"`
|
||||
}
|
||||
|
||||
// VLANConfig describes the macvlan config
|
||||
// VLANConfig describes the macvlan config.
|
||||
type VLANConfig struct {
|
||||
PluginType string `json:"type"`
|
||||
Master string `json:"master"`
|
||||
|
@ -95,30 +95,30 @@ type VLANConfig struct {
|
|||
Capabilities map[string]bool `json:"capabilities,omitempty"`
|
||||
}
|
||||
|
||||
// firewallConfig describes the firewall plugin
|
||||
// firewallConfig describes the firewall plugin.
|
||||
type firewallConfig struct {
|
||||
PluginType string `json:"type"`
|
||||
Backend string `json:"backend"`
|
||||
IngressPolicy string `json:"ingressPolicy,omitempty"`
|
||||
}
|
||||
|
||||
// tuningConfig describes the tuning plugin
|
||||
// tuningConfig describes the tuning plugin.
|
||||
type tuningConfig struct {
|
||||
PluginType string `json:"type"`
|
||||
}
|
||||
|
||||
// dnsNameConfig describes the dns container name resolution plugin config
|
||||
// dnsNameConfig describes the dns container name resolution plugin config.
|
||||
type dnsNameConfig struct {
|
||||
PluginType string `json:"type"`
|
||||
DomainName string `json:"domainName"`
|
||||
Capabilities map[string]bool `json:"capabilities"`
|
||||
}
|
||||
|
||||
// ncList describes a generic map
|
||||
// ncList describes a generic map.
|
||||
type ncList map[string]any
|
||||
|
||||
// newNcList creates a generic map of values with string
|
||||
// keys and adds in version and network name
|
||||
// keys and adds in version and network name.
|
||||
func newNcList(name, version string, labels, options map[string]string) ncList {
|
||||
n := ncList{}
|
||||
n["cniVersion"] = version
|
||||
|
@ -136,7 +136,7 @@ func newNcList(name, version string, labels, options map[string]string) ncList {
|
|||
return n
|
||||
}
|
||||
|
||||
// newHostLocalBridge creates a new LocalBridge for host-local
|
||||
// newHostLocalBridge creates a new LocalBridge for host-local.
|
||||
func newHostLocalBridge(name string, isGateWay, ipMasq bool, mtu, vlan int, ipamConf *ipamConfig) *hostLocalBridge {
|
||||
bridge := hostLocalBridge{
|
||||
PluginType: "bridge",
|
||||
|
@ -157,7 +157,7 @@ func newHostLocalBridge(name string, isGateWay, ipMasq bool, mtu, vlan int, ipam
|
|||
return &bridge
|
||||
}
|
||||
|
||||
// newIPAMHostLocalConf creates a new IPAMHostLocal configuration
|
||||
// newIPAMHostLocalConf creates a new IPAMHostLocal configuration.
|
||||
func newIPAMHostLocalConf(routes []ipamRoute, ipamRanges [][]ipamLocalHostRangeConf) ipamConfig {
|
||||
ipamConf := ipamConfig{
|
||||
PluginType: "host-local",
|
||||
|
@ -168,7 +168,7 @@ func newIPAMHostLocalConf(routes []ipamRoute, ipamRanges [][]ipamLocalHostRangeC
|
|||
return ipamConf
|
||||
}
|
||||
|
||||
// newIPAMLocalHostRange create a new IPAM range
|
||||
// newIPAMLocalHostRange create a new IPAM range.
|
||||
func newIPAMLocalHostRange(subnet types.IPNet, leaseRange *types.LeaseRange, gw net.IP) *ipamLocalHostRangeConf {
|
||||
hostRange := &ipamLocalHostRangeConf{
|
||||
Subnet: subnet.String(),
|
||||
|
@ -197,7 +197,7 @@ func newIPAMRoute(r *net.IPNet) ipamRoute {
|
|||
}
|
||||
|
||||
// newIPAMDefaultRoute creates a new IPAMDefault route of
|
||||
// 0.0.0.0/0 for IPv4 or ::/0 for IPv6
|
||||
// 0.0.0.0/0 for IPv4 or ::/0 for IPv6.
|
||||
func newIPAMDefaultRoute(isIPv6 bool) (ipamRoute, error) {
|
||||
route := defaultIPv4Route
|
||||
if isIPv6 {
|
||||
|
@ -211,7 +211,7 @@ func newIPAMDefaultRoute(isIPv6 bool) (ipamRoute, error) {
|
|||
}
|
||||
|
||||
// newPortMapPlugin creates a predefined, default portmapping
|
||||
// configuration
|
||||
// configuration.
|
||||
func newPortMapPlugin() portMapConfig {
|
||||
return portMapConfig{
|
||||
PluginType: "portmap",
|
||||
|
@ -219,7 +219,7 @@ func newPortMapPlugin() portMapConfig {
|
|||
}
|
||||
}
|
||||
|
||||
// newFirewallPlugin creates a generic firewall plugin
|
||||
// newFirewallPlugin creates a generic firewall plugin.
|
||||
func newFirewallPlugin(isolate bool) firewallConfig {
|
||||
fw := firewallConfig{
|
||||
PluginType: "firewall",
|
||||
|
@ -230,7 +230,7 @@ func newFirewallPlugin(isolate bool) firewallConfig {
|
|||
return fw
|
||||
}
|
||||
|
||||
// newTuningPlugin creates a generic tuning section
|
||||
// newTuningPlugin creates a generic tuning section.
|
||||
func newTuningPlugin() tuningConfig {
|
||||
return tuningConfig{
|
||||
PluginType: "tuning",
|
||||
|
@ -238,7 +238,7 @@ func newTuningPlugin() tuningConfig {
|
|||
}
|
||||
|
||||
// newDNSNamePlugin creates the dnsname config with a given
|
||||
// domainname
|
||||
// domainname.
|
||||
func newDNSNamePlugin(domainName string) dnsNameConfig {
|
||||
return dnsNameConfig{
|
||||
PluginType: "dnsname",
|
||||
|
@ -247,7 +247,7 @@ func newDNSNamePlugin(domainName string) dnsNameConfig {
|
|||
}
|
||||
}
|
||||
|
||||
// hasDNSNamePlugin looks to see if the dnsname cni plugin is present
|
||||
// hasDNSNamePlugin looks to see if the dnsname cni plugin is present.
|
||||
func hasDNSNamePlugin(paths []string) bool {
|
||||
for _, p := range paths {
|
||||
if err := fileutils.Exists(filepath.Join(p, "dnsname")); err == nil {
|
||||
|
@ -257,7 +257,7 @@ func hasDNSNamePlugin(paths []string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// newVLANPlugin creates a macvlanconfig with a given device name
|
||||
// newVLANPlugin creates a macvlanconfig with a given device name.
|
||||
func newVLANPlugin(pluginType, device, mode string, mtu int, ipam *ipamConfig) VLANConfig {
|
||||
m := VLANConfig{
|
||||
PluginType: pluginType,
|
||||
|
|
|
@ -295,14 +295,14 @@ func getNetworkIDFromName(name string) string {
|
|||
|
||||
// Implement the NetUtil interface for easy code sharing with other network interfaces.
|
||||
|
||||
// ForEach call the given function for each network
|
||||
// ForEach call the given function for each network.
|
||||
func (n *cniNetwork) ForEach(run func(types.Network)) {
|
||||
for _, val := range n.networks {
|
||||
run(*val.libpodNet)
|
||||
}
|
||||
}
|
||||
|
||||
// Len return the number of networks
|
||||
// Len return the number of networks.
|
||||
func (n *cniNetwork) Len() int {
|
||||
return len(n.networks)
|
||||
}
|
||||
|
|
|
@ -177,9 +177,9 @@ func getRuntimeConfig(netns, conName, conID, networkName string, ports []cniPort
|
|||
}
|
||||
|
||||
// Propagate environment CNI_ARGS
|
||||
for _, kvpairs := range strings.Split(os.Getenv("CNI_ARGS"), ";") {
|
||||
if keyval := strings.SplitN(kvpairs, "=", 2); len(keyval) == 2 {
|
||||
rt.Args = append(rt.Args, [2]string{keyval[0], keyval[1]})
|
||||
for kvpairs := range strings.SplitSeq(os.Getenv("CNI_ARGS"), ";") {
|
||||
if key, val, ok := strings.Cut(kvpairs, "="); ok {
|
||||
rt.Args = append(rt.Args, [2]string{key, val})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ type HostEntry struct {
|
|||
Names []string
|
||||
}
|
||||
|
||||
// Params for the New() function call
|
||||
// Params for the New() function call.
|
||||
type Params struct {
|
||||
// BaseFile is the file where we read entries from and add entries to
|
||||
// the target hosts file. If the name is empty it will not read any entries.
|
||||
|
@ -98,7 +98,7 @@ func Remove(file string, entries HostEntries) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// new see comment on New()
|
||||
// new see comment on New().
|
||||
func newHost(params *Params) error {
|
||||
entries, err := parseExtraHosts(params.ExtraHosts, params.HostContainersInternalIP)
|
||||
if err != nil {
|
||||
|
@ -128,7 +128,7 @@ func newHost(params *Params) error {
|
|||
return writeHostFile(params.TargetFile, entries, containerIPs)
|
||||
}
|
||||
|
||||
// add see comment on Add()
|
||||
// add see comment on Add().
|
||||
func add(file string, entries HostEntries) error {
|
||||
currentEntries, err := parseHostsFile(file)
|
||||
if err != nil {
|
||||
|
@ -152,7 +152,7 @@ func add(file string, entries HostEntries) error {
|
|||
return addEntriesIfNotExists(f, entries, names)
|
||||
}
|
||||
|
||||
// addIfExists see comment on AddIfExists()
|
||||
// addIfExists see comment on AddIfExists().
|
||||
func addIfExists(file string, existsEntries, newEntries HostEntries) error {
|
||||
// special case when there are no existing entries do a normal add
|
||||
// this can happen when we connect a network which was not connected
|
||||
|
@ -190,7 +190,7 @@ func addIfExists(file string, existsEntries, newEntries HostEntries) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// remove see comment on Remove()
|
||||
// remove see comment on Remove().
|
||||
func remove(file string, entries HostEntries) error {
|
||||
currentEntries, err := parseHostsFile(file)
|
||||
if err != nil {
|
||||
|
@ -236,24 +236,23 @@ func checkIfEntryExists(current HostEntry, entries HostEntries) bool {
|
|||
func parseExtraHosts(extraHosts []string, hostContainersInternalIP string) (HostEntries, error) {
|
||||
entries := make(HostEntries, 0, len(extraHosts))
|
||||
for _, entry := range extraHosts {
|
||||
values := strings.SplitN(entry, ":", 2)
|
||||
if len(values) != 2 {
|
||||
namesString, ip, ok := strings.Cut(entry, ":")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unable to parse host entry %q: incorrect format", entry)
|
||||
}
|
||||
if values[0] == "" {
|
||||
if namesString == "" {
|
||||
return nil, fmt.Errorf("hostname in host entry %q is empty", entry)
|
||||
}
|
||||
if values[1] == "" {
|
||||
if ip == "" {
|
||||
return nil, fmt.Errorf("IP address in host entry %q is empty", entry)
|
||||
}
|
||||
ip := values[1]
|
||||
if values[1] == HostGateway {
|
||||
if ip == HostGateway {
|
||||
if hostContainersInternalIP == "" {
|
||||
return nil, fmt.Errorf("unable to replace %q of host entry %q: host containers internal IP address is empty", HostGateway, entry)
|
||||
}
|
||||
ip = hostContainersInternalIP
|
||||
}
|
||||
names := strings.Split(values[0], ";")
|
||||
names := strings.Split(namesString, ";")
|
||||
e := HostEntry{IP: ip, Names: names}
|
||||
entries = append(entries, e)
|
||||
}
|
||||
|
@ -300,7 +299,7 @@ func parseHostsFile(file string) (HostEntries, error) {
|
|||
return entries, scanner.Err()
|
||||
}
|
||||
|
||||
// writeHostFile write the entries to the given file
|
||||
// writeHostFile write the entries to the given file.
|
||||
func writeHostFile(file string, userEntries, containerIPs HostEntries) error {
|
||||
f, err := os.Create(file)
|
||||
if err != nil {
|
||||
|
@ -322,7 +321,7 @@ func writeHostFile(file string, userEntries, containerIPs HostEntries) error {
|
|||
}
|
||||
|
||||
// addEntriesIfNotExists only adds the entries for names that are not already
|
||||
// in the hosts file, otherwise we start overwriting user entries
|
||||
// in the hosts file, otherwise we start overwriting user entries.
|
||||
func addEntriesIfNotExists(f io.StringWriter, containerIPs HostEntries, names map[string]struct{}) error {
|
||||
for _, entry := range containerIPs {
|
||||
freeNames := make([]string, 0, len(entry.Names))
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"go.podman.io/storage/pkg/unshare"
|
||||
)
|
||||
|
||||
// HostContainersInternalOptions contains the options for GetHostContainersInternalIP()
|
||||
// HostContainersInternalOptions contains the options for GetHostContainersInternalIP().
|
||||
type HostContainersInternalOptions struct {
|
||||
// Conf is the containers.Conf, must not be nil
|
||||
Conf *config.Config
|
||||
|
@ -46,7 +46,7 @@ var machineHostContainersInternalIP = sync.OnceValue(func() string {
|
|||
return ""
|
||||
})
|
||||
|
||||
// GetHostContainersInternalIP returns the host.containers.internal ip
|
||||
// GetHostContainersInternalIP returns the host.containers.internal ip.
|
||||
func GetHostContainersInternalIP(opts HostContainersInternalOptions) string {
|
||||
switch opts.Conf.Containers.HostContainersInternalIP {
|
||||
case "":
|
||||
|
@ -99,7 +99,7 @@ func GetHostContainersInternalIP(opts HostContainersInternalOptions) string {
|
|||
|
||||
// GetHostContainersInternalIPExcluding returns the host.containers.internal ip
|
||||
// Exclude are ips that should not be returned, this is useful to prevent returning the same ip as in the container.
|
||||
// if netStatus is not nil then networkInterface also must be non nil otherwise this function panics
|
||||
// if netStatus is not nil then networkInterface also must be non nil otherwise this function panics.
|
||||
func GetHostContainersInternalIPExcluding(conf *config.Config, netStatus map[string]types.StatusBlock, networkInterface types.ContainerNetwork, exclude []net.IP) string {
|
||||
return GetHostContainersInternalIP(HostContainersInternalOptions{
|
||||
Conf: conf,
|
||||
|
|
|
@ -30,18 +30,18 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// rootlessNetnsDir is the directory name
|
||||
// rootlessNetnsDir is the directory name.
|
||||
rootlessNetnsDir = "rootless-netns"
|
||||
// refCountFile file name for the ref count file
|
||||
// refCountFile file name for the ref count file.
|
||||
refCountFile = "ref-count"
|
||||
|
||||
// infoCacheFile file name for the cache file used to store the rootless netns info
|
||||
// infoCacheFile file name for the cache file used to store the rootless netns info.
|
||||
infoCacheFile = "info.json"
|
||||
|
||||
// rootlessNetNsConnPidFile is the name of the rootless netns slirp4netns/pasta pid file
|
||||
// rootlessNetNsConnPidFile is the name of the rootless netns slirp4netns/pasta pid file.
|
||||
rootlessNetNsConnPidFile = "rootless-netns-conn.pid"
|
||||
|
||||
// persistentCNIDir is the directory where the CNI files are stored
|
||||
// persistentCNIDir is the directory where the CNI files are stored.
|
||||
persistentCNIDir = "/var/lib/cni"
|
||||
|
||||
tmpfs = "tmpfs"
|
||||
|
@ -100,7 +100,7 @@ func New(dir string, backend NetworkBackend, conf *config.Config) (*Netns, error
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getPath is a small wrapper around filepath.Join() to have a bit less code
|
||||
// getPath is a small wrapper around filepath.Join() to have a bit less code.
|
||||
func (n *Netns) getPath(path string) string {
|
||||
return filepath.Join(n.dir, path)
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ func (n *Netns) cleanupRootlessNetns() error {
|
|||
return err
|
||||
}
|
||||
|
||||
// mountAndMkdirDest convenience wrapper for mount and mkdir
|
||||
// mountAndMkdirDest convenience wrapper for mount and mkdir.
|
||||
func mountAndMkdirDest(source string, target string, fstype string, flags uintptr) error {
|
||||
if err := os.MkdirAll(target, 0o700); err != nil {
|
||||
return wrapError("create mount point", err)
|
||||
|
@ -656,8 +656,9 @@ func (n *Netns) Run(lock *lockfile.LockFile, toRun func() error) error {
|
|||
return inErr
|
||||
}
|
||||
|
||||
// IPAddresses returns the currently used ip addresses in the netns
|
||||
// These should then not be assigned for the host.containers.internal entry.
|
||||
// Info returns the currently used ip addresses for the rootless-netns.
|
||||
// These should be used to configure the containers resolv.conf and
|
||||
// host.containers.internal entries.
|
||||
func (n *Netns) Info() *types.RootlessNetnsInfo {
|
||||
return n.info
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import "go.podman.io/common/libnetwork/types"
|
|||
// This is a helper package to allow code sharing between the different
|
||||
// network interfaces.
|
||||
|
||||
// NetUtil is a helper interface which all network interfaces should implement to allow easy code sharing
|
||||
// NetUtil is a helper interface which all network interfaces should implement to allow easy code sharing.
|
||||
type NetUtil interface {
|
||||
// ForEach executes the given function for each network
|
||||
ForEach(func(types.Network))
|
||||
|
|
|
@ -3,7 +3,7 @@ package util
|
|||
import "net"
|
||||
|
||||
// getLiveNetworkSubnets returns a slice of subnets representing what the system
|
||||
// has defined as network interfaces
|
||||
// has defined as network interfaces.
|
||||
func getLiveNetworkSubnets() ([]*net.IPNet, error) {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
|
@ -20,7 +20,7 @@ func getLiveNetworkSubnets() ([]*net.IPNet, error) {
|
|||
return nets, nil
|
||||
}
|
||||
|
||||
// GetLiveNetworkNames returns a list of network interface names on the system
|
||||
// GetLiveNetworkNames returns a list of network interface names on the system.
|
||||
func GetLiveNetworkNames() ([]string, error) {
|
||||
liveInterfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
|
|
|
@ -23,7 +23,7 @@ func incByte(subnet *net.IPNet, idx int, shift uint) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// NextSubnet returns subnet incremented by 1
|
||||
// NextSubnet returns subnet incremented by 1.
|
||||
func NextSubnet(subnet *net.IPNet) (*net.IPNet, error) {
|
||||
newSubnet := &net.IPNet{
|
||||
IP: subnet.IP,
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
)
|
||||
|
||||
// ParseMTU parses the mtu option
|
||||
// ParseMTU parses the mtu option.
|
||||
func ParseMTU(mtu string) (int, error) {
|
||||
if mtu == "" {
|
||||
return 0, nil // default
|
||||
|
@ -20,7 +20,7 @@ func ParseMTU(mtu string) (int, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
// ParseVlan parses the vlan option
|
||||
// ParseVlan parses the vlan option.
|
||||
func ParseVlan(vlan string) (int, error) {
|
||||
if vlan == "" {
|
||||
return 0, nil // default
|
||||
|
@ -35,7 +35,7 @@ func ParseVlan(vlan string) (int, error) {
|
|||
return v, nil
|
||||
}
|
||||
|
||||
// ParseIsolate parses the isolate option
|
||||
// ParseIsolate parses the isolate option.
|
||||
func ParseIsolate(isolate string) (string, error) {
|
||||
switch isolate {
|
||||
case "":
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
// GetBridgeInterfaceNames returns all bridge interface names
|
||||
// already used by network configs
|
||||
// already used by network configs.
|
||||
func GetBridgeInterfaceNames(n NetUtil) []string {
|
||||
names := make([]string, 0, n.Len())
|
||||
n.ForEach(func(net types.Network) {
|
||||
|
@ -24,7 +24,7 @@ func GetBridgeInterfaceNames(n NetUtil) []string {
|
|||
}
|
||||
|
||||
// GetUsedNetworkNames returns all network names already used
|
||||
// by network configs
|
||||
// by network configs.
|
||||
func GetUsedNetworkNames(n NetUtil) []string {
|
||||
names := make([]string, 0, n.Len())
|
||||
n.ForEach(func(net types.Network) {
|
||||
|
@ -35,7 +35,7 @@ func GetUsedNetworkNames(n NetUtil) []string {
|
|||
|
||||
// GetFreeDeviceName returns a free device name which can
|
||||
// be used for new configs as name and bridge interface name.
|
||||
// The base name is suffixed by a number
|
||||
// The base name is suffixed by a number.
|
||||
func GetFreeDeviceName(n NetUtil) (string, error) {
|
||||
bridgeNames := GetBridgeInterfaceNames(n)
|
||||
netNames := GetUsedNetworkNames(n)
|
||||
|
@ -77,7 +77,7 @@ func GetUsedSubnets(n NetUtil) ([]*net.IPNet, error) {
|
|||
return append(subnets, liveSubnets...), nil
|
||||
}
|
||||
|
||||
// GetFreeIPv4NetworkSubnet returns a unused ipv4 subnet
|
||||
// GetFreeIPv4NetworkSubnet returns a unused ipv4 subnet.
|
||||
func GetFreeIPv4NetworkSubnet(usedNetworks []*net.IPNet, subnetPools []config.SubnetPool) (*types.Subnet, error) {
|
||||
var err error
|
||||
for _, pool := range subnetPools {
|
||||
|
@ -109,7 +109,7 @@ func GetFreeIPv4NetworkSubnet(usedNetworks []*net.IPNet, subnetPools []config.Su
|
|||
return nil, errors.New("could not find free subnet from subnet pools")
|
||||
}
|
||||
|
||||
// GetFreeIPv6NetworkSubnet returns a unused ipv6 subnet
|
||||
// GetFreeIPv6NetworkSubnet returns a unused ipv6 subnet.
|
||||
func GetFreeIPv6NetworkSubnet(usedNetworks []*net.IPNet) (*types.Subnet, error) {
|
||||
// FIXME: Is 10000 fine as limit? We should prevent an endless loop.
|
||||
for range 10000 {
|
||||
|
@ -128,7 +128,7 @@ func GetFreeIPv6NetworkSubnet(usedNetworks []*net.IPNet) (*types.Subnet, error)
|
|||
return nil, errors.New("failed to get random ipv6 subnet")
|
||||
}
|
||||
|
||||
// Map docker driver network options to podman network options
|
||||
// MapDockerBridgeDriverOptions docker driver network options to podman network options.
|
||||
func MapDockerBridgeDriverOptions(n *types.Network) {
|
||||
// validate the given options
|
||||
for key, value := range n.Options {
|
||||
|
|
|
@ -143,7 +143,7 @@ func ValidateSetupOptions(n NetUtil, namespacePath string, options types.SetupOp
|
|||
return nil
|
||||
}
|
||||
|
||||
// validatePerNetworkOpts checks that all given static ips are in a subnet on this network
|
||||
// validatePerNetworkOpts checks that all given static ips are in a subnet on this network.
|
||||
func validatePerNetworkOpts(network *types.Network, netOpts *types.PerNetworkOptions) error {
|
||||
if netOpts.InterfaceName == "" {
|
||||
return fmt.Errorf("interface name on network %s is empty", network.Name)
|
||||
|
|
|
@ -292,7 +292,7 @@ func (n *netavarkNetwork) networkCreate(newNetwork *types.Network, defaultNet bo
|
|||
return newNetwork, nil
|
||||
}
|
||||
|
||||
// ipvlan shares the same mac address so supporting DHCP is not really possible
|
||||
// ipvlan shares the same mac address so supporting DHCP is not really possible.
|
||||
var errIpvlanNoDHCP = errors.New("ipam driver dhcp is not supported with ipvlan")
|
||||
|
||||
func createIpvlanOrMacvlan(network *types.Network) error {
|
||||
|
|
|
@ -50,7 +50,7 @@ func newNetavarkError(msg string, err error) error {
|
|||
}
|
||||
|
||||
// Type to implement io.Writer interface
|
||||
// This will write the logrus at info level
|
||||
// This will write the logrus at info level.
|
||||
type logrusNetavarkWriter struct{}
|
||||
|
||||
func (l *logrusNetavarkWriter) Write(b []byte) (int, error) {
|
||||
|
@ -58,7 +58,7 @@ func (l *logrusNetavarkWriter) Write(b []byte) (int, error) {
|
|||
return len(b), nil
|
||||
}
|
||||
|
||||
// getRustLogEnv returns the RUST_LOG env var based on the current logrus level
|
||||
// getRustLogEnv returns the RUST_LOG env var based on the current logrus level.
|
||||
func getRustLogEnv() string {
|
||||
level := logrus.GetLevel().String()
|
||||
// rust env_log uses warn instead of warning
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
idBucket = "ids"
|
||||
// lastIP this is used as key to store the last allocated ip
|
||||
// note that this string should not be 4 or 16 byte long
|
||||
// note that this string should not be 4 or 16 byte long.
|
||||
lastIP = "lastIP"
|
||||
)
|
||||
|
||||
|
@ -380,7 +380,7 @@ func (n *netavarkNetwork) removeNetworkIPAMBucket(network *types.Network) error
|
|||
}
|
||||
|
||||
// requiresIPAMAlloc return true when we have to allocate ips for this network
|
||||
// it checks the ipam driver and if subnets are set
|
||||
// it checks the ipam driver and if subnets are set.
|
||||
func requiresIPAMAlloc(network *types.Network) bool {
|
||||
// only do host allocation when driver is set to HostLocalIPAMDriver or unset
|
||||
switch network.IPAMOptions[types.Driver] {
|
||||
|
|
|
@ -342,14 +342,14 @@ func (n *netavarkNetwork) getNetwork(nameOrID string) (*types.Network, error) {
|
|||
|
||||
// Implement the NetUtil interface for easy code sharing with other network interfaces.
|
||||
|
||||
// ForEach call the given function for each network
|
||||
// ForEach call the given function for each network.
|
||||
func (n *netavarkNetwork) ForEach(run func(types.Network)) {
|
||||
for _, val := range n.networks {
|
||||
run(*val)
|
||||
}
|
||||
}
|
||||
|
||||
// Len return the number of networks
|
||||
// Len return the number of networks.
|
||||
func (n *netavarkNetwork) Len() int {
|
||||
return len(n.networks)
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// defaultNetworkBackendFileName is the file name for sentinel file to store the backend
|
||||
// defaultNetworkBackendFileName is the file name for sentinel file to store the backend.
|
||||
defaultNetworkBackendFileName = "defaultNetworkBackend"
|
||||
|
||||
// netavarkBinary is the name of the netavark binary
|
||||
// netavarkBinary is the name of the netavark binary.
|
||||
netavarkBinary = "netavark"
|
||||
// aardvarkBinary is the name of the aardvark binary
|
||||
// aardvarkBinary is the name of the aardvark binary.
|
||||
aardvarkBinary = "aardvark-dns"
|
||||
)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// cniConfigDirRootless is the directory in XDG_CONFIG_HOME for cni plugins
|
||||
// cniConfigDirRootless is the directory in XDG_CONFIG_HOME for cni plugins.
|
||||
cniConfigDirRootless = "cni/net.d/"
|
||||
|
||||
cniSupported = true
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package network
|
||||
|
||||
const (
|
||||
// cniConfigDir is the directory where cni configuration is found
|
||||
// cniConfigDir is the directory where cni configuration is found.
|
||||
cniConfigDir = "/etc/cni/net.d/"
|
||||
// netavarkConfigDir is the config directory for the rootful network files
|
||||
// netavarkConfigDir is the config directory for the rootful network files.
|
||||
netavarkConfigDir = "/etc/containers/networks"
|
||||
// netavarkRunDir is the run directory for the rootful temporary network files such as the ipam db
|
||||
// netavarkRunDir is the run directory for the rootful temporary network files such as the ipam db.
|
||||
netavarkRunDir = "/run/containers/networks"
|
||||
)
|
||||
|
|
|
@ -30,11 +30,11 @@ const (
|
|||
mapGuestAddrOpt = "--map-guest-addr"
|
||||
|
||||
// dnsForwardIpv4 static ip used as nameserver address inside the netns,
|
||||
// given this is a "link local" ip it should be very unlikely that it causes conflicts
|
||||
// given this is a "link local" ip it should be very unlikely that it causes conflicts.
|
||||
dnsForwardIpv4 = "169.254.1.1"
|
||||
|
||||
// mapGuestAddrIpv4 static ip used as forwarder address inside the netns to reach the host,
|
||||
// given this is a "link local" ip it should be very unlikely that it causes conflicts
|
||||
// given this is a "link local" ip it should be very unlikely that it causes conflicts.
|
||||
mapGuestAddrIpv4 = "169.254.1.2"
|
||||
)
|
||||
|
||||
|
@ -141,13 +141,13 @@ func Setup(opts *SetupOptions) (*SetupResult, error) {
|
|||
}
|
||||
|
||||
result.IPv6 = ipv6
|
||||
result.DNSForwardIPs = filterIpFamily(dnsForwardIPs, ipv4, ipv6)
|
||||
result.MapGuestAddrIPs = filterIpFamily(mapGuestAddrIPs, ipv4, ipv6)
|
||||
result.DNSForwardIPs = filterIPFamily(dnsForwardIPs, ipv4, ipv6)
|
||||
result.MapGuestAddrIPs = filterIPFamily(mapGuestAddrIPs, ipv4, ipv6)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func filterIpFamily(ips []string, ipv4, ipv6 bool) []string {
|
||||
func filterIPFamily(ips []string, ipv4, ipv6 bool) []string {
|
||||
var result []string
|
||||
for _, ip := range ips {
|
||||
ipp := net.ParseIP(ip)
|
||||
|
@ -212,8 +212,7 @@ func createPastaArgs(opts *SetupOptions) ([]string, []string, []string, error) {
|
|||
}
|
||||
|
||||
for _, i := range opts.Ports {
|
||||
protocols := strings.Split(i.Protocol, ",")
|
||||
for _, protocol := range protocols {
|
||||
for protocol := range strings.SplitSeq(i.Protocol, ",") {
|
||||
var addr string
|
||||
|
||||
if i.HostIP != "" {
|
||||
|
|
|
@ -76,9 +76,8 @@ func filterResolvDNS(resolvConf []byte, ipv6Enabled bool, netnsEnabled bool) []b
|
|||
|
||||
// getLines parses input into lines and strips away comments.
|
||||
func getLines(input []byte) [][]byte {
|
||||
lines := bytes.Split(input, []byte("\n"))
|
||||
var output [][]byte
|
||||
for _, currentLine := range lines {
|
||||
for currentLine := range bytes.SplitSeq(input, []byte("\n")) {
|
||||
commentIndex := bytes.Index(currentLine, []byte("#"))
|
||||
if commentIndex == -1 {
|
||||
output = append(output, currentLine)
|
||||
|
|
|
@ -3,17 +3,10 @@ package slirp4netns
|
|||
import "net"
|
||||
|
||||
const (
|
||||
ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/default/accept_dad"
|
||||
BinaryName = "slirp4netns"
|
||||
|
||||
// defaultMTU the default MTU override
|
||||
defaultMTU = 65520
|
||||
|
||||
// default slirp4ns subnet
|
||||
defaultSubnet = "10.0.2.0/24"
|
||||
BinaryName = "slirp4netns"
|
||||
)
|
||||
|
||||
// SetupResult return type from Setup()
|
||||
// SetupResult return type from Setup().
|
||||
type SetupResult struct {
|
||||
// Pid of the created slirp4netns process
|
||||
Pid int
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package slirp4netns
|
||||
|
||||
const (
|
||||
ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/default/accept_dad"
|
||||
|
||||
// defaultMTU the default MTU override.
|
||||
defaultMTU = 65520
|
||||
|
||||
// default slirp4ns subnet.
|
||||
defaultSubnet = "10.0.2.0/24"
|
||||
)
|
|
@ -124,11 +124,10 @@ func parseNetworkOptions(config *config.Config, extraOptions []string) (*network
|
|||
enableIPv6: true,
|
||||
}
|
||||
for _, o := range options {
|
||||
parts := strings.SplitN(o, "=", 2)
|
||||
if len(parts) < 2 {
|
||||
option, value, ok := strings.Cut(o, "=")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unknown option for slirp4netns: %q", o)
|
||||
}
|
||||
option, value := parts[0], parts[1]
|
||||
switch option {
|
||||
case "cidr":
|
||||
ipv4, _, err := net.ParseCIDR(value)
|
||||
|
@ -426,7 +425,7 @@ func Setup(opts *SetupOptions) (*SetupResult, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// Get expected slirp ipv4 address based on subnet. If subnet is null use default subnet
|
||||
// GetIP returns the slirp ipv4 address based on subnet. If subnet is null use default subnet.
|
||||
// Reference: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#description
|
||||
func GetIP(subnet *net.IPNet) (*net.IP, error) {
|
||||
_, slirpSubnet, _ := net.ParseCIDR(defaultSubnet)
|
||||
|
@ -440,7 +439,7 @@ func GetIP(subnet *net.IPNet) (*net.IP, error) {
|
|||
return expectedIP, nil
|
||||
}
|
||||
|
||||
// Get expected slirp Gateway ipv4 address based on subnet
|
||||
// GetGateway returns the slirp gateway ipv4 address based on subnet.
|
||||
// Reference: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#description
|
||||
func GetGateway(subnet *net.IPNet) (*net.IP, error) {
|
||||
_, slirpSubnet, _ := net.ParseCIDR(defaultSubnet)
|
||||
|
@ -454,7 +453,7 @@ func GetGateway(subnet *net.IPNet) (*net.IP, error) {
|
|||
return expectedGatewayIP, nil
|
||||
}
|
||||
|
||||
// Get expected slirp DNS ipv4 address based on subnet
|
||||
// GetDNS returns slirp DNS ipv4 address based on subnet.
|
||||
// Reference: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#description
|
||||
func GetDNS(subnet *net.IPNet) (*net.IP, error) {
|
||||
_, slirpSubnet, _ := net.ParseCIDR(defaultSubnet)
|
||||
|
@ -639,8 +638,7 @@ func setupRootlessPortMappingViaSlirp(ports []types.PortMapping, cmd *exec.Cmd,
|
|||
// for each port we want to add we need to open a connection to the slirp4netns control socket
|
||||
// and send the add_hostfwd command.
|
||||
for _, port := range ports {
|
||||
protocols := strings.Split(port.Protocol, ",")
|
||||
for _, protocol := range protocols {
|
||||
for protocol := range strings.SplitSeq(port.Protocol, ",") {
|
||||
hostIP := port.HostIP
|
||||
if hostIP == "" {
|
||||
hostIP = "0.0.0.0"
|
||||
|
@ -656,7 +654,7 @@ func setupRootlessPortMappingViaSlirp(ports []types.PortMapping, cmd *exec.Cmd,
|
|||
return nil
|
||||
}
|
||||
|
||||
// openSlirp4netnsPort sends the slirp4netns pai quey to the given socket
|
||||
// openSlirp4netnsPort sends the slirp4netns pai quey to the given socket.
|
||||
func openSlirp4netnsPort(apiSocket, proto, hostip string, hostport, guestport uint16) error {
|
||||
conn, err := net.Dial("unix", apiSocket)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package types
|
||||
|
||||
const (
|
||||
// BridgeNetworkDriver defines the bridge driver
|
||||
// BridgeNetworkDriver defines the bridge driver.
|
||||
BridgeNetworkDriver = "bridge"
|
||||
// DefaultNetworkDriver is the default network type used
|
||||
// DefaultNetworkDriver is the default network type used.
|
||||
DefaultNetworkDriver = BridgeNetworkDriver
|
||||
// MacVLANNetworkDriver defines the macvlan driver
|
||||
// MacVLANNetworkDriver defines the macvlan driver.
|
||||
MacVLANNetworkDriver = "macvlan"
|
||||
// MacVLANNetworkDriver defines the macvlan driver
|
||||
// MacVLANNetworkDriver defines the macvlan driver.
|
||||
IPVLANNetworkDriver = "ipvlan"
|
||||
|
||||
// IPAM drivers
|
||||
// IPAM drivers.
|
||||
Driver = "driver"
|
||||
// HostLocalIPAMDriver store the ip locally in a db
|
||||
// HostLocalIPAMDriver store the ip locally in a db.
|
||||
HostLocalIPAMDriver = "host-local"
|
||||
// DHCPIPAMDriver get subnet and ip from dhcp server
|
||||
// DHCPIPAMDriver get subnet and ip from dhcp server.
|
||||
DHCPIPAMDriver = "dhcp"
|
||||
// NoneIPAMDriver do not provide ipam management
|
||||
// NoneIPAMDriver do not provide ipam management.
|
||||
NoneIPAMDriver = "none"
|
||||
|
||||
// DefaultSubnet is the name that will be used for the default CNI network.
|
||||
|
@ -27,18 +27,18 @@ const (
|
|||
BridgeModeManaged = "managed"
|
||||
BridgeModeUnmanaged = "unmanaged"
|
||||
|
||||
// valid macvlan driver mode values
|
||||
// valid macvlan driver mode values.
|
||||
MacVLANModeBridge = "bridge"
|
||||
MacVLANModePrivate = "private"
|
||||
MacVLANModeVepa = "vepa"
|
||||
MacVLANModePassthru = "passthru"
|
||||
|
||||
// valid ipvlan driver modes
|
||||
// valid ipvlan driver modes.
|
||||
IPVLANModeL2 = "l2"
|
||||
IPVLANModeL3 = "l3"
|
||||
IPVLANModeL3s = "l3s"
|
||||
|
||||
// valid network options
|
||||
// valid network options.
|
||||
VLANOption = "vlan"
|
||||
MTUOption = "mtu"
|
||||
ModeOption = "mode"
|
||||
|
@ -56,11 +56,11 @@ const (
|
|||
Netavark NetworkBackend = "netavark"
|
||||
)
|
||||
|
||||
// ValidBridgeModes is the list of valid mode options for the bridge driver
|
||||
// ValidBridgeModes is the list of valid mode options for the bridge driver.
|
||||
var ValidBridgeModes = []string{BridgeModeManaged, BridgeModeUnmanaged}
|
||||
|
||||
// ValidMacVLANModes is the list of valid mode options for the macvlan driver
|
||||
// ValidMacVLANModes is the list of valid mode options for the macvlan driver.
|
||||
var ValidMacVLANModes = []string{MacVLANModeBridge, MacVLANModePrivate, MacVLANModeVepa, MacVLANModePassthru}
|
||||
|
||||
// ValidIPVLANModes is the list of valid mode options for the ipvlan driver
|
||||
// ValidIPVLANModes is the list of valid mode options for the ipvlan driver.
|
||||
var ValidIPVLANModes = []string{IPVLANModeL2, IPVLANModeL3, IPVLANModeL3s}
|
||||
|
|
|
@ -8,17 +8,17 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// ErrNoSuchNetwork indicates the requested network does not exist
|
||||
// ErrNoSuchNetwork indicates the requested network does not exist.
|
||||
ErrNoSuchNetwork = errors.New("network not found")
|
||||
|
||||
// ErrInvalidArg indicates that an invalid argument was passed
|
||||
// ErrInvalidArg indicates that an invalid argument was passed.
|
||||
ErrInvalidArg = errors.New("invalid argument")
|
||||
|
||||
// ErrNetworkExists indicates that a network with the given name already
|
||||
// exists.
|
||||
ErrNetworkExists = errors.New("network already exists")
|
||||
|
||||
// ErrNotRootlessNetns indicates the rootless netns can only be used as root
|
||||
// ErrNotRootlessNetns indicates the rootless netns can only be used as root.
|
||||
ErrNotRootlessNetns = errors.New("rootless netns cannot be used as root")
|
||||
|
||||
// NameRegex is a regular expression to validate names.
|
||||
|
@ -33,6 +33,6 @@ var (
|
|||
// a hexadecimal string.
|
||||
NotHexRegex = regexp.Delayed(`[^0-9a-fA-F]`)
|
||||
|
||||
// MaxInterfaceNameLength is the maximum length of a network interface name
|
||||
// MaxInterfaceNameLength is the maximum length of a network interface name.
|
||||
MaxInterfaceNameLength = 15
|
||||
)
|
||||
|
|
|
@ -87,7 +87,7 @@ type Network struct {
|
|||
IPAMOptions map[string]string `json:"ipam_options,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkOptions for a given container.
|
||||
// NetworkUpdateOptions for a given container.
|
||||
type NetworkUpdateOptions struct {
|
||||
// List of custom DNS server for podman's DNS resolver.
|
||||
// Priority order will be kept as defined by user in the configuration.
|
||||
|
@ -104,7 +104,7 @@ type NetworkInfo struct {
|
|||
DNS DNSNetworkInfo `json:"dns,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkInfo contains the DNS information.
|
||||
// DNSNetworkInfo contains the DNS information.
|
||||
type DNSNetworkInfo struct {
|
||||
Version string `json:"version,omitempty"`
|
||||
Package string `json:"package,omitempty"`
|
||||
|
@ -116,7 +116,7 @@ type IPNet struct {
|
|||
net.IPNet
|
||||
}
|
||||
|
||||
// ParseCIDR parse a string to IPNet
|
||||
// ParseCIDR parse a string to IPNet.
|
||||
func ParseCIDR(cidr string) (IPNet, error) {
|
||||
ip, subnet, err := net.ParseCIDR(cidr)
|
||||
if err != nil {
|
||||
|
@ -347,6 +347,7 @@ type RootlessNetnsInfo struct {
|
|||
// IPAddresses used in the netns, must not be used for host.containers.internal
|
||||
IPAddresses []net.IP
|
||||
// DnsForwardIps ips used in resolv.conf
|
||||
//nolint:staticcheck //It wants this to be named DNSForwardIps but this would be a breaking change and thus is not worth it.
|
||||
DnsForwardIps []string
|
||||
// MapGuestIps should be used for the host.containers.internal entry when set
|
||||
MapGuestIps []string
|
||||
|
|
|
@ -14,7 +14,7 @@ func IsIPv4(netIP net.IP) bool {
|
|||
return netIP != nil && netIP.To4() != nil
|
||||
}
|
||||
|
||||
// LastIPInSubnet gets the last IP in a subnet
|
||||
// LastIPInSubnet gets the last IP in a subnet.
|
||||
func LastIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer
|
||||
// re-parse to ensure clean network address
|
||||
_, cidr, err := net.ParseCIDR(addr.String())
|
||||
|
@ -32,7 +32,7 @@ func LastIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer
|
|||
return cidr.IP, nil
|
||||
}
|
||||
|
||||
// FirstIPInSubnet gets the first IP in a subnet
|
||||
// FirstIPInSubnet gets the first IP in a subnet.
|
||||
func FirstIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer
|
||||
// re-parse to ensure clean network address
|
||||
_, cidr, err := net.ParseCIDR(addr.String())
|
||||
|
@ -47,7 +47,7 @@ func FirstIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer
|
|||
return cidr.IP, nil
|
||||
}
|
||||
|
||||
// NormalizeIP will transform the given ip to the 4 byte len ipv4 if possible
|
||||
// NormalizeIP will transform the given ip to the 4 byte len ipv4 if possible.
|
||||
func NormalizeIP(ip *net.IP) {
|
||||
ipv4 := ip.To4()
|
||||
if ipv4 != nil {
|
||||
|
|
|
@ -19,13 +19,13 @@ import (
|
|||
"net"
|
||||
)
|
||||
|
||||
// NextIP returns IP incremented by 1
|
||||
// NextIP returns IP incremented by 1.
|
||||
func NextIP(ip net.IP) net.IP {
|
||||
i := ipToInt(ip)
|
||||
return intToIP(i.Add(i, big.NewInt(1)))
|
||||
}
|
||||
|
||||
// PrevIP returns IP decremented by 1
|
||||
// PrevIP returns IP decremented by 1.
|
||||
func PrevIP(ip net.IP) net.IP {
|
||||
i := ipToInt(ip)
|
||||
return intToIP(i.Sub(i, big.NewInt(1)))
|
||||
|
@ -34,7 +34,7 @@ func PrevIP(ip net.IP) net.IP {
|
|||
// Cmp compares two IPs, returning the usual ordering:
|
||||
// a < b : -1
|
||||
// a == b : 0
|
||||
// a > b : 1
|
||||
// a > b : 1.
|
||||
func Cmp(a, b net.IP) int {
|
||||
aa := ipToInt(a)
|
||||
bb := ipToInt(b)
|
||||
|
|
|
@ -10,7 +10,7 @@ const (
|
|||
// ProfilePrefix is used for version-independent presence checks.
|
||||
ProfilePrefix = "containers-default-"
|
||||
|
||||
// Profile default name
|
||||
// Profile default name.
|
||||
Profile = ProfilePrefix + version.Version
|
||||
)
|
||||
|
||||
|
|
|
@ -208,14 +208,14 @@ func parseAAParserVersion(output string) (int, error) {
|
|||
// AppArmor parser version 2.9.1
|
||||
// Copyright (C) 1999-2008 Novell Inc.
|
||||
// Copyright 2009-2012 Canonical Ltd.
|
||||
lines := strings.SplitN(output, "\n", 2)
|
||||
words := strings.Split(lines[0], " ")
|
||||
firstLine, _, _ := strings.Cut(output, "\n")
|
||||
words := strings.Split(firstLine, " ")
|
||||
version := words[len(words)-1]
|
||||
|
||||
// trim "-beta1" suffix from version="3.0.0-beta1" if exists
|
||||
version = strings.SplitN(version, "-", 2)[0]
|
||||
version, _, _ = strings.Cut(version, "-")
|
||||
// also trim "~..." suffix used historically (https://gitlab.com/apparmor/apparmor/-/commit/bca67d3d27d219d11ce8c9cc70612bd637f88c10)
|
||||
version = strings.SplitN(version, "~", 2)[0]
|
||||
version, _, _ = strings.Cut(version, "~")
|
||||
|
||||
// split by major minor version
|
||||
v := strings.Split(version, ".")
|
||||
|
|
|
@ -39,7 +39,7 @@ func NewAppArmorVerifier() *ApparmorVerifier {
|
|||
// The method will error if:
|
||||
// - the process runs in rootless mode
|
||||
// - AppArmor is disabled by the host system
|
||||
// - the `apparmor_parser` binary is not discoverable
|
||||
// - the `apparmor_parser` binary is not discoverable.
|
||||
func (a *ApparmorVerifier) IsSupported() error {
|
||||
if a.impl.UnshareIsRootless() {
|
||||
return errors.New("AppAmor is not supported on rootless containers")
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue