mirror of https://github.com/k3s-io/k3s
Update generated and dep addition of safefile
parent
ed4401c126
commit
763122ae4b
|
@ -842,6 +842,10 @@
|
|||
"ImportPath": "github.com/daviddengcn/go-colortext",
|
||||
"Rev": "511bcaf42ccd42c38aba7427b6673277bf19e2a1"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/dchest/safefile",
|
||||
"Rev": "855e8d98f1852d48dde521e0522408d1fe7e836a"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/dgrijalva/jwt-go",
|
||||
"Comment": "v3.0.0-4-g01aeca5",
|
||||
|
@ -849,152 +853,152 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/distribution/digestset",
|
||||
"Comment": "v2.6.0-rc.1-209-gedc3ab29",
|
||||
"Comment": "v2.6.0-rc.1-209-gedc3ab2",
|
||||
"Rev": "edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/distribution/reference",
|
||||
"Comment": "v2.6.0-rc.1-209-gedc3ab29",
|
||||
"Comment": "v2.6.0-rc.1-209-gedc3ab2",
|
||||
"Rev": "edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/blkiodev",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/container",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/events",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/filters",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/image",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/mount",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/network",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/registry",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/strslice",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/swarm",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/swarm/runtime",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/time",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/versions",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/api/types/volume",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/client",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/ioutils",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/jsonlog",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/jsonmessage",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/longpath",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/mount",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/stdcopy",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/symlink",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/system",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/term",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/term/windows",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/tlsconfig",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616fb1",
|
||||
"Comment": "docs-v1.12.0-rc4-2016-07-15-7401-g4f3616f",
|
||||
"Rev": "4f3616fb1c112e206b88cb7a9922bf49067a7756"
|
||||
},
|
||||
{
|
||||
|
@ -1019,7 +1023,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/libnetwork/ipvs",
|
||||
"Comment": "v0.8.0-dev.2-910-gba46b928",
|
||||
"Comment": "v0.8.0-dev.2-910-gba46b92",
|
||||
"Rev": "ba46b928444931e6865d8618dc03622cac79aa6f"
|
||||
},
|
||||
{
|
||||
|
@ -1146,127 +1150,127 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/gogoproto",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/compare",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/defaultcheck",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/description",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/embedcheck",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/enumstringer",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/equal",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/face",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/gostring",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/marshalto",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/oneofcheck",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/populate",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/size",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/stringer",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/testgen",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/union",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/plugin/unmarshal",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/descriptor",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/generator",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/grpc",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/protoc-gen-gogo/plugin",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/sortkeys",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/vanity",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/vanity/command",
|
||||
"Comment": "v0.4-3-gc0656edd",
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
|
@ -1778,6 +1782,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/inconshreveable/mousetrap",
|
||||
"Comment": "v1.0",
|
||||
"Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
|
||||
},
|
||||
{
|
||||
|
@ -2162,77 +2167,77 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/apparmor",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/cgroups",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/cgroups/fs",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/cgroups/rootless",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/cgroups/systemd",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/configs",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/configs/validate",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/criurpc",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/keys",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/seccomp",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/stacktrace",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/system",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/user",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/utils",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e6720",
|
||||
"Comment": "v1.0.0-rc4-50-g4d6e672",
|
||||
"Rev": "4d6e6720a7c885c37b4cb083c0d372dda3425120"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -29167,6 +29167,40 @@ SOFTWARE.
|
|||
================================================================================
|
||||
|
||||
|
||||
================================================================================
|
||||
= vendor/github.com/dchest/safefile licensed under: =
|
||||
|
||||
Copyright (c) 2013 Dmitry Chestnykh <dmitry@codingrobots.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
= vendor/github.com/dchest/safefile/LICENSE 499ffd499356286ac590c21f7b8bd677
|
||||
================================================================================
|
||||
|
||||
|
||||
================================================================================
|
||||
= vendor/github.com/dgrijalva/jwt-go licensed under: =
|
||||
|
||||
|
|
|
@ -254,6 +254,7 @@ filegroup(
|
|||
"//pkg/kubelet/apis:all-srcs",
|
||||
"//pkg/kubelet/cadvisor:all-srcs",
|
||||
"//pkg/kubelet/certificate:all-srcs",
|
||||
"//pkg/kubelet/checkpoint:all-srcs",
|
||||
"//pkg/kubelet/client:all-srcs",
|
||||
"//pkg/kubelet/cm:all-srcs",
|
||||
"//pkg/kubelet/config:all-srcs",
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["checkpoint.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpoint",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/volume/util:go_default_library",
|
||||
"//vendor/github.com/dchest/safefile:go_default_library",
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["checkpoint_test.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpoint",
|
||||
library = ":go_default_library",
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -1,10 +1,4 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
|
@ -26,6 +20,7 @@ go_library(
|
|||
"//conditions:default": [],
|
||||
}),
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/config",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
|
@ -33,6 +28,7 @@ go_library(
|
|||
"//pkg/apis/core/install:go_default_library",
|
||||
"//pkg/apis/core/v1:go_default_library",
|
||||
"//pkg/apis/core/validation:go_default_library",
|
||||
"//pkg/kubelet/checkpoint:go_default_library",
|
||||
"//pkg/kubelet/container:go_default_library",
|
||||
"//pkg/kubelet/events:go_default_library",
|
||||
"//pkg/kubelet/types:go_default_library",
|
||||
|
@ -112,4 +108,5 @@ filegroup(
|
|||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
|
@ -14,6 +14,7 @@ go_library(
|
|||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/pod",
|
||||
deps = [
|
||||
"//pkg/kubelet/checkpoint:go_default_library",
|
||||
"//pkg/kubelet/configmap:go_default_library",
|
||||
"//pkg/kubelet/container:go_default_library",
|
||||
"//pkg/kubelet/secret:go_default_library",
|
||||
|
|
|
@ -124,6 +124,7 @@ filegroup(
|
|||
"//vendor/github.com/d2g/dhcp4client:all-srcs",
|
||||
"//vendor/github.com/davecgh/go-spew/spew:all-srcs",
|
||||
"//vendor/github.com/daviddengcn/go-colortext:all-srcs",
|
||||
"//vendor/github.com/dchest/safefile:all-srcs",
|
||||
"//vendor/github.com/dgrijalva/jwt-go:all-srcs",
|
||||
"//vendor/github.com/docker/distribution/digestset:all-srcs",
|
||||
"//vendor/github.com/docker/distribution/reference:all-srcs",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.1
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.4
|
||||
- tip
|
|
@ -0,0 +1,30 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"rename.go",
|
||||
"safefile.go",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:windows_amd64": [
|
||||
"rename_nonatomic.go",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
importpath = "github.com/dchest/safefile",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
Copyright (c) 2013 Dmitry Chestnykh <dmitry@codingrobots.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,44 @@
|
|||
# safefile
|
||||
|
||||
[![Build Status](https://travis-ci.org/dchest/safefile.svg)](https://travis-ci.org/dchest/safefile) [![Windows Build status](https://ci.appveyor.com/api/projects/status/owlifxeekg75t2ho?svg=true)](https://ci.appveyor.com/project/dchest/safefile)
|
||||
|
||||
Go package safefile implements safe "atomic" saving of files.
|
||||
|
||||
Instead of truncating and overwriting the destination file, it creates a
|
||||
temporary file in the same directory, writes to it, and then renames the
|
||||
temporary file to the original name when calling Commit.
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
$ go get github.com/dchest/safefile
|
||||
```
|
||||
|
||||
### Documentation
|
||||
|
||||
<https://godoc.org/github.com/dchest/safefile>
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
f, err := safefile.Create("/home/ken/report.txt", 0644)
|
||||
if err != nil {
|
||||
// ...
|
||||
}
|
||||
// Created temporary file /home/ken/sf-ppcyksu5hyw2mfec.tmp
|
||||
|
||||
defer f.Close()
|
||||
|
||||
_, err = io.WriteString(f, "Hello world")
|
||||
if err != nil {
|
||||
// ...
|
||||
}
|
||||
// Wrote "Hello world" to /home/ken/sf-ppcyksu5hyw2mfec.tmp
|
||||
|
||||
err = f.Commit()
|
||||
if err != nil {
|
||||
// ...
|
||||
}
|
||||
// Renamed /home/ken/sf-ppcyksu5hyw2mfec.tmp to /home/ken/report.txt
|
||||
```
|
|
@ -0,0 +1,24 @@
|
|||
version: "{build}"
|
||||
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
clone_folder: c:\projects\src\github.com\dchest\safefile
|
||||
|
||||
environment:
|
||||
PATH: c:\projects\bin;%PATH%
|
||||
GOPATH: c:\projects
|
||||
NOTIFY_TIMEOUT: 5s
|
||||
|
||||
install:
|
||||
- go version
|
||||
- go get golang.org/x/tools/cmd/vet
|
||||
- go get -v -t ./...
|
||||
|
||||
build_script:
|
||||
- go tool vet -all .
|
||||
- go build ./...
|
||||
- go test -v -race ./...
|
||||
|
||||
test: off
|
||||
|
||||
deploy: off
|
|
@ -0,0 +1,9 @@
|
|||
// +build !plan9,!windows windows,go1.5
|
||||
|
||||
package safefile
|
||||
|
||||
import "os"
|
||||
|
||||
func rename(oldname, newname string) error {
|
||||
return os.Rename(oldname, newname)
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// +build plan9 windows,!go1.5
|
||||
|
||||
// os.Rename on Windows before Go 1.5 and Plan 9 will not overwrite existing
|
||||
// files, thus we cannot guarantee atomic saving of file by doing rename.
|
||||
// We will have to do some voodoo to minimize data loss on those systems.
|
||||
|
||||
package safefile
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func rename(oldname, newname string) error {
|
||||
err := os.Rename(oldname, newname)
|
||||
if err != nil {
|
||||
// If newname exists ("original"), we will try renaming it to a
|
||||
// new temporary name, then renaming oldname to the newname,
|
||||
// and deleting the renamed original. If system crashes between
|
||||
// renaming and deleting, the original file will still be available
|
||||
// under the temporary name, so users can manually recover data.
|
||||
// (No automatic recovery is possible because after crash the
|
||||
// temporary name is not known.)
|
||||
var origtmp string
|
||||
for {
|
||||
origtmp, err = makeTempName(newname, filepath.Base(newname))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = os.Stat(origtmp)
|
||||
if err == nil {
|
||||
continue // most likely will never happen
|
||||
}
|
||||
break
|
||||
}
|
||||
err = os.Rename(newname, origtmp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Rename(oldname, newname)
|
||||
if err != nil {
|
||||
// Rename still fails, try to revert original rename,
|
||||
// ignoring errors.
|
||||
os.Rename(origtmp, newname)
|
||||
return err
|
||||
}
|
||||
// Rename succeeded, now delete original file.
|
||||
os.Remove(origtmp)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
// Copyright 2013 Dmitry Chestnykh. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package safefile implements safe "atomic" saving of files.
|
||||
//
|
||||
// Instead of truncating and overwriting the destination file, it creates a
|
||||
// temporary file in the same directory, writes to it, and then renames the
|
||||
// temporary file to the original name when calling Commit.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// f, err := safefile.Create("/home/ken/report.txt", 0644)
|
||||
// if err != nil {
|
||||
// // ...
|
||||
// }
|
||||
// // Created temporary file /home/ken/sf-ppcyksu5hyw2mfec.tmp
|
||||
//
|
||||
// defer f.Close()
|
||||
//
|
||||
// _, err = io.WriteString(f, "Hello world")
|
||||
// if err != nil {
|
||||
// // ...
|
||||
// }
|
||||
// // Wrote "Hello world" to /home/ken/sf-ppcyksu5hyw2mfec.tmp
|
||||
//
|
||||
// err = f.Commit()
|
||||
// if err != nil {
|
||||
// // ...
|
||||
// }
|
||||
// // Renamed /home/ken/sf-ppcyksu5hyw2mfec.tmp to /home/ken/report.txt
|
||||
//
|
||||
package safefile
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base32"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ErrAlreadyCommitted error is returned when calling Commit on a file that
|
||||
// has been already successfully committed.
|
||||
var ErrAlreadyCommitted = errors.New("file already committed")
|
||||
|
||||
type File struct {
|
||||
*os.File
|
||||
origName string
|
||||
closeFunc func(*File) error
|
||||
isClosed bool // if true, temporary file has been closed, but not renamed
|
||||
isCommitted bool // if true, the file has been successfully committed
|
||||
}
|
||||
|
||||
func makeTempName(origname, prefix string) (tempname string, err error) {
|
||||
origname = filepath.Clean(origname)
|
||||
if len(origname) == 0 || origname[len(origname)-1] == filepath.Separator {
|
||||
return "", os.ErrInvalid
|
||||
}
|
||||
// Generate 10 random bytes.
|
||||
// This gives 80 bits of entropy, good enough
|
||||
// for making temporary file name unpredictable.
|
||||
var rnd [10]byte
|
||||
if _, err := rand.Read(rnd[:]); err != nil {
|
||||
return "", err
|
||||
}
|
||||
name := prefix + "-" + strings.ToLower(base32.StdEncoding.EncodeToString(rnd[:])) + ".tmp"
|
||||
return filepath.Join(filepath.Dir(origname), name), nil
|
||||
}
|
||||
|
||||
// Create creates a temporary file in the same directory as filename,
|
||||
// which will be renamed to the given filename when calling Commit.
|
||||
func Create(filename string, perm os.FileMode) (*File, error) {
|
||||
for {
|
||||
tempname, err := makeTempName(filename, "sf")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f, err := os.OpenFile(tempname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
|
||||
if err != nil {
|
||||
if os.IsExist(err) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &File{
|
||||
File: f,
|
||||
origName: filename,
|
||||
closeFunc: closeUncommitted,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// OrigName returns the original filename given to Create.
|
||||
func (f *File) OrigName() string {
|
||||
return f.origName
|
||||
}
|
||||
|
||||
// Close closes temporary file and removes it.
|
||||
// If the file has been committed, Close is no-op.
|
||||
func (f *File) Close() error {
|
||||
return f.closeFunc(f)
|
||||
}
|
||||
|
||||
func closeUncommitted(f *File) error {
|
||||
err0 := f.File.Close()
|
||||
err1 := os.Remove(f.Name())
|
||||
f.closeFunc = closeAgainError
|
||||
if err0 != nil {
|
||||
return err0
|
||||
}
|
||||
return err1
|
||||
}
|
||||
|
||||
func closeAfterFailedRename(f *File) error {
|
||||
// Remove temporary file.
|
||||
//
|
||||
// The note from Commit function applies here too, as we may be
|
||||
// removing a different file. However, since we rely on our temporary
|
||||
// names being unpredictable, this should not be a concern.
|
||||
f.closeFunc = closeAgainError
|
||||
return os.Remove(f.Name())
|
||||
}
|
||||
|
||||
func closeCommitted(f *File) error {
|
||||
// noop
|
||||
return nil
|
||||
}
|
||||
|
||||
func closeAgainError(f *File) error {
|
||||
return os.ErrInvalid
|
||||
}
|
||||
|
||||
// Commit safely commits data into the original file by syncing temporary
|
||||
// file to disk, closing it and renaming to the original file name.
|
||||
//
|
||||
// In case of success, the temporary file is closed and no longer exists
|
||||
// on disk. It is safe to call Close after Commit: the operation will do
|
||||
// nothing.
|
||||
//
|
||||
// In case of error, the temporary file is still opened and exists on disk;
|
||||
// it must be closed by callers by calling Close or by trying to commit again.
|
||||
|
||||
// Note that when trying to Commit again after a failed Commit when the file
|
||||
// has been closed, but not renamed to its original name (the new commit will
|
||||
// try again to rename it), safefile cannot guarantee that the temporary file
|
||||
// has not been changed, or that it is the same temporary file we were dealing
|
||||
// with. However, since the temporary name is unpredictable, it is unlikely
|
||||
// that this happened accidentally. If complete atomicity is needed, do not
|
||||
// Commit again after error, write the file again.
|
||||
func (f *File) Commit() error {
|
||||
if f.isCommitted {
|
||||
return ErrAlreadyCommitted
|
||||
}
|
||||
if !f.isClosed {
|
||||
// Sync to disk.
|
||||
err := f.Sync()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Close underlying os.File.
|
||||
err = f.File.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f.isClosed = true
|
||||
}
|
||||
// Rename.
|
||||
err := rename(f.Name(), f.origName)
|
||||
if err != nil {
|
||||
f.closeFunc = closeAfterFailedRename
|
||||
return err
|
||||
}
|
||||
f.closeFunc = closeCommitted
|
||||
f.isCommitted = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteFile is a safe analog of ioutil.WriteFile.
|
||||
func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
||||
f, err := Create(filename, perm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
n, err := f.Write(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err == nil && n < len(data) {
|
||||
err = io.ErrShortWrite
|
||||
return err
|
||||
}
|
||||
return f.Commit()
|
||||
}
|
Loading…
Reference in New Issue