diff --git a/go.mod b/go.mod index a2d018e5..cb2fc51d 100644 --- a/go.mod +++ b/go.mod @@ -28,30 +28,32 @@ require ( github.com/go-ini/ini v1.62.0 // indirect github.com/go-openapi/spec v0.19.5 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/gorilla/mux v1.8.0 github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect github.com/graymeta/stow v0.2.7 github.com/hashicorp/go-multierror v1.1.1 github.com/imdario/mergo v0.3.12 github.com/influxdata/influxdb v1.2.0 - github.com/mholt/archiver v0.0.0-20180417220235-e4ef56d48eb0 + github.com/mholt/archiver v2.1.0+incompatible github.com/minio/minio-go v6.0.14+incompatible github.com/nats-io/nats-streaming-server v0.22.0 github.com/nats-io/nats.go v1.11.0 github.com/nats-io/stan.go v0.9.0 - github.com/nwaples/rardecode v1.1.0 // indirect + github.com/nwaples/rardecode v1.1.2 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect github.com/opencontainers/runc v1.0.1 // indirect github.com/ory/dockertest v3.3.5+incompatible + github.com/pierrec/lz4 v2.6.1+incompatible // indirect github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.11.0 github.com/prometheus/common v0.26.0 github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 - github.com/satori/go.uuid v1.2.0 + github.com/satori/go.uuid v1.2.1-0.20181016170032-d91630c85102 github.com/spf13/cobra v1.2.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 - github.com/ulikunitz/xz v0.5.9 // indirect + github.com/ulikunitz/xz v0.5.10 // indirect github.com/wcharczuk/go-chart v2.0.1+incompatible go.opencensus.io v0.23.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.23.0 diff --git a/go.sum b/go.sum index a86674d2..3ab385db 100644 --- a/go.sum +++ b/go.sum @@ -327,8 +327,9 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -574,8 +575,8 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mholt/archiver v0.0.0-20180417220235-e4ef56d48eb0 h1:581DnhoG2Q33rqM3X6Is+8agf17B2vlzV/H52/Xvcd0= -github.com/mholt/archiver v0.0.0-20180417220235-e4ef56d48eb0/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU= +github.com/mholt/archiver v2.1.0+incompatible h1:1ivm7KAHPtPere1YDOdrY6xGdbMNGRWThZbYh5lWZT0= +github.com/mholt/archiver v2.1.0+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= @@ -628,8 +629,8 @@ github.com/nats-io/stan.go v0.9.0 h1:TB73Y31au++0sU0VmnBy2pYkSrwH0zUFNRB9YePHqC4 github.com/nats-io/stan.go v0.9.0/go.mod h1:0jEuBXKauB1HHJswHM/lx05K48TJ1Yxj6VIfM4k+aB4= github.com/ncw/swift v1.0.49/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= -github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= +github.com/nwaples/rardecode v1.1.2 h1:Cj0yZY6T1Zx1R7AhTbyGSALm44/Mmq+BAPc4B/p/d3M= +github.com/nwaples/rardecode v1.1.2/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -664,8 +665,9 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= +github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -718,8 +720,9 @@ github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OK github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/satori/go.uuid v1.2.1-0.20181016170032-d91630c85102 h1:WAQaHPfnpevd8SKXCcy5nk3JzEv2h5Q0kSwvoMqXiZs= +github.com/satori/go.uuid v1.2.1-0.20181016170032-d91630c85102/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -781,8 +784,8 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri github.com/uber/jaeger-client-go v2.25.0+incompatible h1:IxcNZ7WRY1Y3G4poYlx24szfsn/3LvK9QHCq9oQw8+U= github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= -github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= -github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= +github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= diff --git a/pkg/controller/api_test.go b/pkg/controller/api_test.go index e003d82d..8f551d81 100644 --- a/pkg/controller/api_test.go +++ b/pkg/controller/api_test.go @@ -359,7 +359,9 @@ func TestMain(m *testing.M) { panicIf(err) // testNS isolation for running multiple CI builds concurrently. - testNS = uuid.NewV4().String() + id, err := uuid.NewV4() + panicIf(err) + testNS = id.String() _, err = kubeClient.CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: testNS, diff --git a/pkg/fetcher/fetcher.go b/pkg/fetcher/fetcher.go index ac647b20..46e5a5a8 100644 --- a/pkg/fetcher/fetcher.go +++ b/pkg/fetcher/fetcher.go @@ -354,8 +354,16 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, pkg *fv1.Package, req Functio if archiver.Zip.Match(tmpPath) && !req.KeepArchive { // unarchive tmp file to a tmp unarchive path - tmpUnarchivePath := filepath.Join(fetcher.sharedVolumePath, uuid.NewV4().String()) - err := fetcher.unarchive(tmpPath, tmpUnarchivePath) + id, err := uuid.NewV4() + if err != nil { + logger.Error("error generating uuid", + zap.Error(err), + zap.String("archive_location", tmpPath)) + return http.StatusInternalServerError, err + } + + tmpUnarchivePath := filepath.Join(fetcher.sharedVolumePath, id.String()) + err = fetcher.unarchive(tmpPath, tmpUnarchivePath) if err != nil { logger.Error("error unarchive", zap.Error(err), diff --git a/pkg/fission-cli/cmd/function/create.go b/pkg/fission-cli/cmd/function/create.go index 8e993fd7..0e67ff5d 100644 --- a/pkg/fission-cli/cmd/function/create.go +++ b/pkg/fission-cli/cmd/function/create.go @@ -214,7 +214,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { } buildcmd := input.String(flagkey.PkgBuildCmd) - pkgName := fmt.Sprintf("%v-%v", fnName, uuid.NewV4().String()) + id, err := uuid.NewV4() + if err != nil { + return errors.Wrap(err, "error generating uuid") + } + pkgName := fmt.Sprintf("%v-%v", fnName, id.String()) // create new package in the same namespace as the function. pkgMetadata, err = _package.CreatePackage(input, opts.Client(), pkgName, fnNamespace, envName, envNamespace, @@ -363,7 +367,11 @@ func (opts *CreateSubCommand) run(input cli.Input) error { } } - triggerName := uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return errors.Wrap(err, "error generating UUID") + } + triggerName := id.String() ht := &fv1.HTTPTrigger{ ObjectMeta: metav1.ObjectMeta{ Name: triggerName, diff --git a/pkg/fission-cli/cmd/httptrigger/create.go b/pkg/fission-cli/cmd/httptrigger/create.go index d274c1ba..d0a7f373 100644 --- a/pkg/fission-cli/cmd/httptrigger/create.go +++ b/pkg/fission-cli/cmd/httptrigger/create.go @@ -70,7 +70,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { // just name triggers by uuid. if len(triggerName) == 0 { console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.HtName)) - triggerName = uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return err + } + triggerName = id.String() } fnNamespace := input.String(flagkey.NamespaceFunction) diff --git a/pkg/fission-cli/cmd/kubewatch/create.go b/pkg/fission-cli/cmd/kubewatch/create.go index 9a656aaa..e4792df2 100644 --- a/pkg/fission-cli/cmd/kubewatch/create.go +++ b/pkg/fission-cli/cmd/kubewatch/create.go @@ -53,7 +53,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { watchName := input.String(flagkey.KwName) if len(watchName) == 0 { console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.MqtName)) - watchName = uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return errors.Wrap(err, "error generating uuid") + } + watchName = id.String() } fnName := input.String(flagkey.KwFnName) fnNamespace := input.String(flagkey.NamespaceFunction) diff --git a/pkg/fission-cli/cmd/mqtrigger/create.go b/pkg/fission-cli/cmd/mqtrigger/create.go index d61c07b7..5c14e557 100644 --- a/pkg/fission-cli/cmd/mqtrigger/create.go +++ b/pkg/fission-cli/cmd/mqtrigger/create.go @@ -54,7 +54,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { mqtName := input.String(flagkey.MqtName) if len(mqtName) == 0 { console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.MqtName)) - mqtName = uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return err + } + mqtName = id.String() } fnName := input.String(flagkey.MqtFnName) fnNamespace := input.String(flagkey.NamespaceFunction) diff --git a/pkg/fission-cli/cmd/package/create.go b/pkg/fission-cli/cmd/package/create.go index 34d1ee14..b15975ac 100644 --- a/pkg/fission-cli/cmd/package/create.go +++ b/pkg/fission-cli/cmd/package/create.go @@ -160,7 +160,11 @@ func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkg } if len(pkgName) == 0 { - pkgName = strings.ToLower(uuid.NewV4().String()) + id, err := uuid.NewV4() + if err != nil { + return nil, errors.Wrap(err, "error generating UUID") + } + pkgName = strings.ToLower(id.String()) } pkg := &fv1.Package{ diff --git a/pkg/fission-cli/cmd/package/package.go b/pkg/fission-cli/cmd/package/package.go index 48b5d754..15ca96de 100644 --- a/pkg/fission-cli/cmd/package/package.go +++ b/pkg/fission-cli/cmd/package/package.go @@ -124,7 +124,11 @@ func CreateArchive(client client.Interface, input cli.Input, includeFiles []stri return nil, err } - file := filepath.Join(tmpDir, uuid.NewV4().String()) + id, err := uuid.NewV4() + if err != nil { + return nil, err + } + file := filepath.Join(tmpDir, id.String()) err = utils.DownloadUrl(context.Background(), http.DefaultClient, fileURL, file) if err != nil { return nil, errors.Wrap(err, "error downloading file from the given URL") diff --git a/pkg/fission-cli/cmd/package/util/util.go b/pkg/fission-cli/cmd/package/util/util.go index 06173596..8af91ce8 100644 --- a/pkg/fission-cli/cmd/package/util/util.go +++ b/pkg/fission-cli/cmd/package/util/util.go @@ -107,7 +107,11 @@ func DownloadToTempFile(fileUrl string) (string, error) { return "", errors.Wrapf(err, "error creating temp directory %v", tmpDir) } - tmpFilename := uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return "", errors.Wrapf(err, "error generating UUID") + } + tmpFilename := id.String() destination := filepath.Join(tmpDir, tmpFilename) err = WriteArchiveToFile(destination, reader) @@ -135,7 +139,11 @@ func WriteArchiveToFile(fileName string, reader io.Reader) error { if err != nil { return err } - tmpFileName := uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return err + } + tmpFileName := id.String() path := filepath.Join(tmpDir, tmpFileName+".tmp") w, err := os.Create(path) diff --git a/pkg/fission-cli/cmd/spec/init.go b/pkg/fission-cli/cmd/spec/init.go index c342b509..c49a22ad 100644 --- a/pkg/fission-cli/cmd/spec/init.go +++ b/pkg/fission-cli/cmd/spec/init.go @@ -67,7 +67,11 @@ func (opts *InitSubCommand) complete(input cli.Input) error { deployID := input.String(flagkey.SpecDeployID) if len(deployID) == 0 { - deployID = uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return errors.Wrap(err, "error generating UUID") + } + deployID = id.String() } // Create spec dir diff --git a/pkg/fission-cli/cmd/timetrigger/create.go b/pkg/fission-cli/cmd/timetrigger/create.go index 8482e5fd..903da849 100644 --- a/pkg/fission-cli/cmd/timetrigger/create.go +++ b/pkg/fission-cli/cmd/timetrigger/create.go @@ -56,7 +56,11 @@ func (opts *CreateSubCommand) do(input cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error { name := input.String(flagkey.TtName) if len(name) == 0 { - name = uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return err + } + name = id.String() } fnName := input.String(flagkey.TtFnName) diff --git a/pkg/storagesvc/localstorage.go b/pkg/storagesvc/localstorage.go index efc38ed0..1fda9eb6 100644 --- a/pkg/storagesvc/localstorage.go +++ b/pkg/storagesvc/localstorage.go @@ -32,10 +32,14 @@ func (ls localStorage) getStorageType() StorageType { return ls.storageType } -func (ls localStorage) getUploadFileName() string { +func (ls localStorage) getUploadFileName() (string, error) { // This is not the item ID (that's returned by Put) // should we just use handler.Filename? what are the constraints here? - return uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return "", err + } + return id.String(), err } func (ls localStorage) getContainerName() string { diff --git a/pkg/storagesvc/s3storage.go b/pkg/storagesvc/s3storage.go index 560ed155..19eba855 100644 --- a/pkg/storagesvc/s3storage.go +++ b/pkg/storagesvc/s3storage.go @@ -49,9 +49,12 @@ func (ss s3Storage) getContainerName() string { return ss.bucketName } -func (ss s3Storage) getUploadFileName() string { - uploadName := uuid.NewV4().String() - return path.Join(ss.subDir, uploadName) +func (ss s3Storage) getUploadFileName() (string, error) { + id, err := uuid.NewV4() + if err != nil { + return "", err + } + return path.Join(ss.subDir, id.String()), nil } func (ss s3Storage) dial() (stow.Location, error) { diff --git a/pkg/storagesvc/storagesvc.go b/pkg/storagesvc/storagesvc.go index 37e5b5bc..642eddbd 100644 --- a/pkg/storagesvc/storagesvc.go +++ b/pkg/storagesvc/storagesvc.go @@ -40,7 +40,7 @@ type ( dial() (stow.Location, error) // getSubDir() string getContainerName() string - getUploadFileName() string + getUploadFileName() (string, error) } // StorageService is a struct to hold all things for storage service diff --git a/pkg/storagesvc/stowClient.go b/pkg/storagesvc/stowClient.go index edd337e0..e50a353d 100644 --- a/pkg/storagesvc/stowClient.go +++ b/pkg/storagesvc/stowClient.go @@ -111,7 +111,10 @@ func MakeStowClient(logger *zap.Logger, storage Storage) (*StowClient, error) { // putFile writes the file on the storage func (client *StowClient) putFile(file multipart.File, fileSize int64) (string, error) { - uploadName := client.config.storage.getUploadFileName() + uploadName, err := client.config.storage.getUploadFileName() + if err != nil { + return "", err + } // save the file to the storage backend item, err := client.container.Put(uploadName, file, fileSize, nil) diff --git a/pkg/tracker/tracker.go b/pkg/tracker/tracker.go index 301bfdf8..2a4979ba 100644 --- a/pkg/tracker/tracker.go +++ b/pkg/tracker/tracker.go @@ -47,7 +47,11 @@ type ( ) func init() { - Tracker = &tracker{gaPropertyID: os.Getenv(GA_TRACKING_ID), cid: uuid.NewV4().String()} + id, err := uuid.NewV4() + if err != nil { + panic(err) + } + Tracker = &tracker{gaPropertyID: os.Getenv(GA_TRACKING_ID), cid: id.String()} } func (t *tracker) SendEvent(e Event) error { diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 263de5ff..67aea4df 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -88,7 +88,11 @@ func IsReadyPod(pod *apiv1.Pod) bool { // GetTempDir creates and return a temporary directory func GetTempDir() (string, error) { - tmpDir := uuid.NewV4().String() + id, err := uuid.NewV4() + if err != nil { + return "", err + } + tmpDir := id.String() dir, err := ioutil.TempDir("", tmpDir) return dir, err }