From 00628ccb5a64ca8e3eacf280c4ffe78ba8efd5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Nov=C3=A1k?= Date: Wed, 18 Oct 2023 21:02:25 -0700 Subject: [PATCH] Docker build logs (#21) --- .trunk/trunk.yaml | 5 + VERSION | 2 +- go.work.sum | 47 +++++++ packages/api/Dockerfile | 2 +- packages/api/api.hcl | 6 + packages/api/internal/api/api.gen.go | 66 ++++++++-- packages/api/internal/api/spec.gen.go | 47 +++---- packages/api/internal/api/types.gen.go | 24 +++- packages/api/internal/db/envs.go | 25 ++-- packages/api/internal/handlers/envs.go | 75 ++++++++--- packages/api/internal/handlers/store.go | 43 ++++--- packages/api/internal/nomad/env-build.hcl | 1 + packages/api/internal/nomad/env.go | 3 + .../api/internal/utils/build_logs_cache.go | 60 +++++++++ packages/api/main.tf | 22 ++++ .../env-build-task-driver/internal/driver.go | 17 ++- .../env-build-task-driver/internal/env/env.go | 4 + .../internal/env/mock_build.go | 7 +- .../internal/env/rootfs.go | 27 +++- .../internal/env/writer.go | 121 ++++++++++++++++++ .../env-build-task-driver/internal/task.go | 7 +- spec/openapi.yml | 59 +++++++-- 22 files changed, 561 insertions(+), 109 deletions(-) create mode 100644 packages/api/internal/utils/build_logs_cache.go create mode 100644 packages/env-build-task-driver/internal/env/writer.go diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index c697eab76..5356622df 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -22,6 +22,11 @@ lint: paths: - "**/go.work.sum" - "**/go.sum" + - linters: [gitleaks,trufflehog] + paths: + - "**/go.work.sum" + - "**/go.sum" + enabled: - actionlint@1.6.25 - gitleaks@8.18.0 diff --git a/VERSION b/VERSION index b0a122753..58682af41 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.10 \ No newline at end of file +0.0.11 \ No newline at end of file diff --git a/go.work.sum b/go.work.sum index d84b5b352..3cf395589 100644 --- a/go.work.sum +++ b/go.work.sum @@ -577,7 +577,9 @@ github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwS github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk= github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= +github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg= @@ -625,6 +627,7 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 h1:G1bPvciwNyF7IUmKXNt9Ak3m6u9DE1rF+RmtIkBpVdA= github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/aws/aws-sdk-go v1.25.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.42.27 h1:kxsBXQg3ee6LLbqjp5/oUeDgG7TENFrWYDmEVnd7spU= github.com/aws/aws-sdk-go v1.42.27/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aws/aws-sdk-go v1.44.184 h1:/MggyE66rOImXJKl1HqhLQITvWvqIV7w1Q4MaG6FHUo= @@ -690,6 +693,7 @@ github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= +github.com/cilium/ebpf v0.8.1 h1:bLSSEbBLqGPXxls55pGr5qWZaTqcmfDJHhou7t254ao= github.com/cilium/ebpf v0.8.1/go.mod h1:f5zLIM0FSNuAkSyLAN7X+Hy6yznlF1mNiWUMfxMtrgk= github.com/cilium/ebpf v0.9.1 h1:64sn2K3UKw8NbP/blsixRpF3nXuyhz/VjRlRzvlBRu4= github.com/cilium/ebpf v0.9.1/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnxUFY= @@ -725,12 +729,16 @@ github.com/containerd/containerd v1.4.9/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMX github.com/containerd/containerd v1.5.9/go.mod h1:fvQqCfadDGga5HZyn3j4+dx56qj2I9YwBrlSdalvJYQ= github.com/containerd/containerd v1.6.6/go.mod h1:ZoP1geJldzCVY3Tonoz7b1IXk8rIX0Nltt5QE4OMNk0= github.com/containerd/continuity v0.1.0 h1:UFRRY5JemiAhPZrr/uE0n8fMTLcZsUvySPr1+D7pgr8= +github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/containerd/go-cni v1.1.1/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= +github.com/containerd/go-cni v1.1.6 h1:el5WPymG5nRRLQF1EfB97FWob4Tdc8INg8RZMaXWZlo= github.com/containerd/go-cni v1.1.6/go.mod h1:BWtoWl5ghVymxu6MBjg79W9NZrCRyHIdUtk4cauMe34= github.com/containerd/go-cni v1.1.9 h1:ORi7P1dYzCwVM6XPN4n3CbkuOx/NZ2DOqy+SHRdo9rU= github.com/containerd/go-cni v1.1.9/go.mod h1:XYrZJ1d5W6E2VOvjffL3IZq0Dz6bsVlERHbekNK90PM= github.com/containerd/go-runc v1.0.0 h1:oU+lLv1ULm5taqgV/CJivypVODI4SUz1znWjv3nNYS0= github.com/containerd/imgcrypt v1.1.1 h1:LBwiTfoUsdiEGAR1TpvxE+Gzt7469oVu87iR3mv3Byc= +github.com/containerd/imgcrypt v1.1.4 h1:iKTstFebwy3Ak5UF0RHSeuCTahC5OIrPJa6vjMAM81s= github.com/containerd/imgcrypt v1.1.4/go.mod h1:LorQnPtzL/T0IyCeftcsMEO7AqxUDbdO8j/tSUpgxvo= github.com/containerd/nri v0.1.0 h1:6QioHRlThlKh2RkRTR4kIT3PKAcrLo3gIWnjkM4dQmQ= github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k= @@ -740,6 +748,7 @@ github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Ev github.com/containerd/typeurl v1.0.2 h1:Chlt8zIieDbzQFzXzAeBEF92KhExuE4p9p92/QmY7aY= github.com/containerd/zfs v1.0.0 h1:cXLJbx+4Jj7rNsTiqVfm6i+RNLx6FFA2fMmDlEf+Wm8= github.com/containers/ocicrypt v1.1.1 h1:prL8l9w3ntVqXvNH1CiNn5ENjcCnr38JqpSyvKKB4GI= +github.com/containers/ocicrypt v1.1.3 h1:uMxn2wTb4nDR7GqG3rnZSfpJXqWURfzZ7nKydzIeKpA= github.com/containers/ocicrypt v1.1.3/go.mod h1:xpdkbVAuaH3WzbEabUd5yDsl9SwJA5pABH85425Es2g= github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s= github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04= @@ -787,6 +796,7 @@ github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryef github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= +github.com/docker/libnetwork v0.8.0-dev.2.0.20210525090646-64b7a4574d14 h1:GZvuJOpa10/Yl2EinacWoMqJ+XtNPbikclDZvNXBNO8= github.com/docker/libnetwork v0.8.0-dev.2.0.20210525090646-64b7a4574d14/go.mod h1:93m0aTqz6z+g32wla4l4WxTrdtvBRmVzYRkYvasA5Z8= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= @@ -794,6 +804,8 @@ github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QL github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 h1:+3HCtB74++ClLy8GgjUQYeC8R4ILzVcIe8+5edAJJnE= github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f h1:AwZUiMWfYSmIiHdFJIubTSs8BFIFoMmUFbeuwBzHIPs= github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw= github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= @@ -879,9 +891,11 @@ github.com/gofiber/fiber/v2 v2.49.1/go.mod h1:nPUeEBUeeYGgwbDm59Gp7vS8MDyScL6ezr github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.4.0 h1:zgVt4UpGxcqVOw97aRGxT4svlcmdK35fynLNctY32zI= +github.com/gojuno/minimock/v3 v3.0.6 h1:YqHcVR10x2ZvswPK8Ix5yk+hMpspdQ3ckSpkOzyF85I= github.com/gojuno/minimock/v3 v3.0.6/go.mod h1:v61ZjAKHr+WnEkND63nQPCZ/DTfQgJdvbCi3IuoMblY= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= @@ -901,6 +915,7 @@ github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOF github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U= github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= @@ -938,6 +953,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/hashicorp/cap v0.2.0 h1:Cgr1iDczX17y0PNF5VG+bWTtDiimYL8F18izMPbWNy4= github.com/hashicorp/cap v0.2.0/go.mod h1:zb3VvIFA0lM2lbmO69NjowV9dJzJnZS89TaM9blXPJA= github.com/hashicorp/consul v1.7.8/go.mod h1:urbfGaVZDmnXC6geg0LYPh/SRUk1E8nfmDHpz+Q0nLw= +github.com/hashicorp/consul-template v0.29.0 h1:rDmF3Wjqp5ztCq054MruzEpi9ArcyJ/Rp4eWrDhMldM= github.com/hashicorp/consul-template v0.29.0/go.mod h1:p1A8Z6Mz7gbXu38SI1c9nt5ItBK7ACWZG4ZE1A5Tr2M= github.com/hashicorp/consul-template v0.31.0 h1:Mn1t5xkq5X3WqylbBBp0tzlFG+0kAB1jW3/sQZRX1bk= github.com/hashicorp/consul-template v0.31.0/go.mod h1:nN/+pN3FLriPmcS5HARDgFNzeQvWPW8fo07JZ1olMjU= @@ -951,11 +967,13 @@ github.com/hashicorp/go-connlimit v0.3.0 h1:oAojHGjFxUTTTA8c5XXnDqWJ2HLuWbDiBPTp github.com/hashicorp/go-connlimit v0.3.0/go.mod h1:OUj9FGL1tPIhl/2RCfzYHrIiWj+VVPGNyVPnUX8AqS0= github.com/hashicorp/go-cty-funcs v0.0.0-20200930094925-2721b1e36840 h1:kgvybwEeu0SXktbB2y3uLHX9lklLo+nzUwh59A3jzQc= github.com/hashicorp/go-cty-funcs v0.0.0-20200930094925-2721b1e36840/go.mod h1:Abjk0jbRkDaNCzsRhOv2iDCofYpX1eVsjozoiK63qLA= +github.com/hashicorp/go-discover v0.0.0-20210818145131-c573d69da192 h1:eje2KOX8Sf7aYPiAsLnpWdAIrGRMcpFjN/Go/Exb7Zo= github.com/hashicorp/go-discover v0.0.0-20210818145131-c573d69da192/go.mod h1:3/4dzY4lR1Hzt9bBqMhBzG7lngZ0GKx/nL6G/ad62wE= github.com/hashicorp/go-discover v0.0.0-20220621183603-a413e131e836 h1:4wEh+GhB7WtM3ZBlqx7DJ32m4fVt4rK1XeEEez3aook= github.com/hashicorp/go-discover v0.0.0-20220621183603-a413e131e836/go.mod h1:1xfdKvc3pe5WKxfUUHHOGaKMk7NLGhHY1jkyhKo6098= github.com/hashicorp/go-envparse v0.0.0-20180119215841-310ca1881b22 h1:HTmDIaSN95gbdMyrsbNiXSdW4fbGctGQwEqv0H7OhDQ= github.com/hashicorp/go-envparse v0.0.0-20180119215841-310ca1881b22/go.mod h1:/NlxCzN2D4C4L2uDE6ux/h6jM+n98VFQM14nnCIfHJU= +github.com/hashicorp/go-getter v1.5.11 h1:wioTuNmaBU3IE9vdFtFMcmZWj0QzLc6DYaP6sNe5onY= github.com/hashicorp/go-getter v1.5.11/go.mod h1:9i48BP6wpWweI/0/+FBjqLrp9S8XtwUGjiu0QkWHEaY= github.com/hashicorp/go-getter v1.7.0 h1:bzrYP+qu/gMrL1au7/aDvkoOVGUJpeKBgbqRHACAFDY= github.com/hashicorp/go-getter v1.7.0/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= @@ -965,6 +983,7 @@ github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0/go.mod h1:xvb32K2keAc+R8DSFG2IwDcydK9DBQE+fGA5fsw6hSk= github.com/hashicorp/go-kms-wrapping/v2 v2.0.8 h1:9Q2lu1YbbmiAgvYZ7Pr31RdlVonUpX+mmDL7Z7qTA2U= github.com/hashicorp/go-kms-wrapping/v2 v2.0.8/go.mod h1:qTCjxGig/kjuj3hk1z8pOUrzbse/GxB1tGfbrq8tGJg= +github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8= github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g= github.com/hashicorp/go-memdb v1.3.4 h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c= github.com/hashicorp/go-memdb v1.3.4/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg= @@ -974,6 +993,7 @@ github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhE github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-secure-stdlib/base62 v0.1.1/go.mod h1:EdWO6czbmthiwZ3/PUsDV+UD1D5IRU4ActiaWGwt0Yw= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= +github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 h1:p4AKXPPS24tO8Wc8i1gLvSKdmkiSY5xuju57czJ/IJQ= github.com/hashicorp/go-secure-stdlib/mlock v0.1.2/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= @@ -996,12 +1016,14 @@ github.com/hashicorp/nomad/api v0.0.0-20230103221135-ce00d683f9be/go.mod h1:EM/2 github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea h1:xykPFhrBAS2J0VBzVa5e80b5ZtYuNQtgXjN40qBZlD4= github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea/go.mod h1:qRd6nFJYYS6Iqnc/8HcUmko2/2Gw8qTFEmxDLii6W5I= +github.com/hashicorp/raft-boltdb/v2 v2.2.0 h1:/CVN9LSAcH50L3yp2TsPFIpeyHn1m3VF6kiutlDE3Nw= github.com/hashicorp/raft-boltdb/v2 v2.2.0/go.mod h1:SgPUD5TP20z/bswEr210SnkUFvQP/YjKV95aaiTbeMQ= github.com/hashicorp/raft-boltdb/v2 v2.2.2 h1:rlkPtOllgIcKLxVT4nutqlTH2NRFn+tO1wwZk/4Dxqw= github.com/hashicorp/raft-boltdb/v2 v2.2.2/go.mod h1:N8YgaZgNJLpZC+h+by7vDu5rzsRgONThTEeUS3zWbfY= github.com/hashicorp/vault/api v1.8.0/go.mod h1:uJrw6D3y9Rv7hhmS17JQC50jbPDAZdjZoTtrCCxxs7E= github.com/hashicorp/vault/api/auth/kubernetes v0.3.0 h1:HkaCmTKzcgLa2tjdiAid1rbmyQNmQGHfnmvIIM2WorY= github.com/hashicorp/vault/api/auth/kubernetes v0.3.0/go.mod h1:l1B4MGtLc+P37MabBQiIhP3qd9agj0vqhETmaQjjC/Y= +github.com/hashicorp/vault/sdk v0.4.1 h1:3SaHOJY687jY1fnB61PtL0cOkKItphrbLmux7T92HBo= github.com/hashicorp/vault/sdk v0.4.1/go.mod h1:aZ3fNuL5VNydQk8GcLJ2TV8YCRVvyaakYkhZRoVuhj0= github.com/hashicorp/vault/sdk v0.6.0/go.mod h1:+DRpzoXIdMvKc88R4qxr+edwy/RvH5QK8itmxLiDHLc= github.com/hashicorp/vault/sdk v0.9.0 h1:Cbu9ezaZafZTXnen98QKVmufEPquhZ+r1ORZ7csNLFU= @@ -1021,6 +1043,7 @@ github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHL github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb-client-go/v2 v2.4.0 h1:HGBfZYStlx3Kqvsv1h2pJixbCl/jhnFtxpKFAv9Tu5k= @@ -1029,6 +1052,7 @@ github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c h1:qSH github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 h1:vilfsDSy7TDxedi9gyBkMvAirat/oRcL0lFdJBf6tdM= github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= +github.com/intel/goresctrl v0.2.0 h1:JyZjdMQu9Kl/wLXe9xA6s1X+tF6BWsQPFGJMEeCfWzE= github.com/intel/goresctrl v0.2.0/go.mod h1:+CZdzouYFn5EsxgqAQTEzMfwKwuc0fVdMrT9FCCAVRQ= github.com/iris-contrib/schema v0.0.6 h1:CPSBLyx2e91H2yJzPuhGuifVRnZBBJ3pCOMbOvPZaTw= github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA= @@ -1131,6 +1155,7 @@ github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/pkcs11 v1.0.3 h1:iMwmD7I5225wv84WxIG/bmxz9AXjWvTWIbM/TYHvWtw= +github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= @@ -1154,10 +1179,13 @@ github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqky github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo= github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mount v0.2.0/go.mod h1:aAivFE2LB3W4bACsUXChRHQ0qKWsetY4Y9V7sxOougM= +github.com/moby/sys/signal v0.6.0 h1:aDpY94H8VlhTGa9sNYUFCFsMZIUh5wm0B6XkIoJj/iY= github.com/moby/sys/signal v0.6.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg= github.com/moby/sys/symlink v0.1.0 h1:MTFZ74KtNI6qQQpuBxU+uKCim4WtOMokr03hCfJcazE= +github.com/moby/sys/symlink v0.2.0 h1:tk1rOM+Ljp0nFmfOIBtlV3rTDlWOwFRhjEeAhZB0nZc= github.com/moby/sys/symlink v0.2.0/go.mod h1:7uZVF2dqJjG/NsClqul95CqKOBRQyYSNnJ6BMgR/gFs= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5 h1:8Q0qkMVC/MmWkpIdlvZgcv2o2jrlF6zqVOh7W5YHdMA= github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ= @@ -1186,6 +1214,7 @@ github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runc v1.0.3/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= +github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc= github.com/opencontainers/runtime-spec v1.1.0-rc.3 h1:l04uafi6kxByhbxev7OWiuUv0LZxEsYUfDWZ6bztAuU= github.com/opencontainers/runtime-spec v1.1.0-rc.3/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39 h1:H7DMc6FAjgwZZi8BRqjrAAHWoqEr5e5L6pS4V0ezet4= @@ -1231,12 +1260,14 @@ github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/ryanuber/columnize v2.1.1-0.20170703205827-abc90934186a+incompatible h1:ZVvb3R06BXNcQ3nXT2eANJAwGeRu4tbUzLI7sIyFZ2s= github.com/ryanuber/columnize v2.1.1-0.20170703205827-abc90934186a+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.2+incompatible h1:C89EOx/XBWwIXl8wm8OPJBd7kPF25UfsK2X7Ph/zCAk= github.com/ryanuber/columnize v2.1.2+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -1248,11 +1279,13 @@ github.com/schollz/closestmatch v2.1.0+incompatible h1:Uel2GXEpJqOWBrlyI+oY9LTiy github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= github.com/sclevine/agouti v3.0.0+incompatible h1:8IBJS6PWz3uTlMP3YBIR5f+KAldcGuOeFkFbUWfBgK4= github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= +github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 h1:RpforrEYXWkmGwJHIGnLZ3tTWStkjVVstwzNGqxX2Ds= github.com/seccomp/libseccomp-golang v0.10.0 h1:aA4bp+/Zzi0BnWZ2F1wgNBs5gTpm+na2rWM6M9YjLpY= github.com/seccomp/libseccomp-golang v0.10.0/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/shoenig/go-landlock v0.1.5 h1:0a/YjKzqdbll7f/iztN/6pKRSHJEmm8olFWD8xSM86A= github.com/shoenig/go-landlock v0.1.5/go.mod h1:CxztF/8LRAUKUMguGxGTQBJIBiiawxx/BKYVGrHg1/0= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c h1:fyKiXKO1/I/B6Y2U8T7WdQGWzwehOuGIrljPtt7YTTI= @@ -1343,11 +1376,13 @@ github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMzt github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= github.com/zclconf/go-cty v1.4.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= +github.com/zclconf/go-cty-yaml v1.0.2 h1:dNyg4QLTrv2IfJpm7Wtxi55ed5gLGOlPrZ6kMd51hY0= github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= github.com/zclconf/go-cty-yaml v1.0.3 h1:og/eOQ7lvA/WWhHGFETVWNduJM7Rjsv2RRpx1sdFMLc= github.com/zclconf/go-cty-yaml v1.0.3/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -1357,7 +1392,9 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.4 h1:lrneYvz923dvC14R54XcA7FXoZ3mlGZAgmwhfm7H go.etcd.io/etcd/client/v2 v2.305.4 h1:Dcx3/MYyfKcPNLpR4VVQUP5KgYrBeJtktBwEKkw08Ao= go.etcd.io/etcd/client/v3 v3.5.4 h1:p83BUL3tAYS0OT/r0qglgc3M1JjhM0diV8DSWAhVXv4= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 h1:A/5uWzF44DlIgdm/PQFwfMkW0JX+cIcQi/SwLAmZP5M= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0 h1:Ky1MObd188aGbgb5OgNnwGuEEwI9MVIcc7rBW6zk5Ak= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0/go.mod h1:vEhqr0m4eTc+DWxfsXoXue2GBgV2uUwVznkGIHW/e5w= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.3.0 h1:Ydage/P0fRrSPpZeCVxzjqGcI6iVmG2xb43+IR8cjqM= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.3.0/go.mod h1:QNX1aly8ehqqX1LEa6YniTU7VY9I6R3X/oPxhGdTceE= go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= @@ -1510,30 +1547,39 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= k8s.io/api v0.20.6 h1:bgdZrW++LqgrLikWYNruIKAtltXbSCX2l5mJu11hrVE= +k8s.io/api v0.22.5 h1:xk7C+rMjF/EGELiD560jdmwzrB788mfcHiNbMQLIVI8= k8s.io/api v0.22.5/go.mod h1:mEhXyLaSD1qTOf40rRiKXkc+2iCem09rWLlFwhCEiAs= k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= k8s.io/apimachinery v0.20.6 h1:R5p3SlhaABYShQSO6LpPsYHjV05Q+79eBUR0Ut/f4tk= +k8s.io/apimachinery v0.22.5 h1:cIPwldOYm1Slq9VLBRPtEYpyhjIm1C6aAMAoENuvN9s= k8s.io/apimachinery v0.22.5/go.mod h1:xziclGKwuuJ2RM5/rSFQSYAj0zdbci3DH8kj+WvyN0U= k8s.io/apiserver v0.20.6 h1:NnVriMMOpqQX+dshbDoZixqmBhfgrPk2uOh2fzp9vHE= +k8s.io/apiserver v0.22.5 h1:71krQxCUz218ecb+nPhfDsNB6QgP1/4EMvi1a2uYBlg= k8s.io/apiserver v0.22.5/go.mod h1:s2WbtgZAkTKt679sYtSudEQrTGWUSQAPe6MupLnlmaQ= k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= k8s.io/client-go v0.20.6 h1:nJZOfolnsVtDtbGJNCxzOtKUAu7zvXjB8+pMo9UNxZo= +k8s.io/client-go v0.22.5 h1:I8Zn/UqIdi2r02aZmhaJ1hqMxcpfJ3t5VqvHtctHYFo= k8s.io/client-go v0.22.5/go.mod h1:cs6yf/61q2T1SdQL5Rdcjg9J1ElXSwbjSrW2vFImM4Y= k8s.io/component-base v0.20.6 h1:G0inASS5vAqCpzs7M4Sp9dv9d0aElpz39zDHbSB4f4g= +k8s.io/component-base v0.22.5 h1:U0eHqZm7mAFE42hFwYhY6ze/MmVaW00JpMrzVsQmzYE= k8s.io/component-base v0.22.5/go.mod h1:VK3I+TjuF9eaa+Ln67dKxhGar5ynVbwnGrUiNF4MqCI= k8s.io/cri-api v0.20.6 h1:iXX0K2pRrbR8yXbZtDK/bSnmg/uSqIFiVJK1x4LUOMc= +k8s.io/cri-api v0.25.0 h1:INwdXsCDSA/0hGNdPxdE2dQD6ft/5K1EaKXZixvSQxg= +k8s.io/cri-api v0.25.0/go.mod h1:J1rAyQkSJ2Q6I+aBMOVgg2/cbbebso6FNa0UagiR0kc= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac h1:sAvhNk5RRuc6FNYGqe7Ygz3PSo/2wGWbulskmzRX8Vs= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.4.0 h1:7+X0fUguPyrKEC4WjH8iGDg3laWgMo5tMnRTIGTTxGQ= +k8s.io/klog/v2 v2.30.0 h1:bUO6drIvCIsvZ/XFgfxoGFQU/a4Qkh0iAlvUR7vlHJw= k8s.io/klog/v2 v2.30.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd h1:sOHNzJIkytDF6qadMNKhhDRpc6ODik8lVC6nOur7B2c= k8s.io/kubernetes v1.13.0 h1:qTfB+u5M92k2fCCCVP2iuhgwwSOv1EkAkvQY1tQODD8= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= +k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZxKn3tKo5k/eYcs= k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= kernel.org/pub/linux/libs/security/libcap/psx v1.2.66 h1:ikIhPzfkSSAEwBOU+2DWhoF+xnGUhvlMTfQjBVhvzQY= kernel.org/pub/linux/libs/security/libcap/psx v1.2.66/go.mod h1:+l6Ee2F59XiJ2I6WR5ObpC1utCQJZ/VLsEbQCD8RG24= @@ -1564,5 +1610,6 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15 h1:4uqm9Mv+w2MmB sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/structured-merge-diff/v4 v4.0.3 h1:4oyYo8NREp49LBBhKxEqCulFjg26rawYKrnCmg+Sr6c= +sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno= sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= diff --git a/packages/api/Dockerfile b/packages/api/Dockerfile index 600f7469a..062c2bd02 100644 --- a/packages/api/Dockerfile +++ b/packages/api/Dockerfile @@ -10,7 +10,7 @@ RUN go mod download COPY internal internal COPY main.go main.go -RUN make build +RUN --mount=type=cache,target=/root/.cache/go-build make build FROM alpine:3.17 diff --git a/packages/api/api.hcl b/packages/api/api.hcl index f235a6ac2..21efabe2a 100644 --- a/packages/api/api.hcl +++ b/packages/api/api.hcl @@ -63,6 +63,11 @@ variable "bucket_name" { default = "" } +variable "api_secret" { + type = string + default = "" +} + job "orchestration-api" { datacenters = [var.gcp_zone] @@ -108,6 +113,7 @@ job "orchestration-api" { API_ADMIN_KEY = var.api_admin_key ENVIRONMENT = var.environment GOOGLE_CLOUD_STORAGE_BUCKET = var.bucket_name + API_SECRET = var.api_secret } config { diff --git a/packages/api/internal/api/api.gen.go b/packages/api/internal/api/api.gen.go index 9e6a8310e..cd661526d 100644 --- a/packages/api/internal/api/api.gen.go +++ b/packages/api/internal/api/api.gen.go @@ -20,8 +20,11 @@ type ServerInterface interface { // (POST /envs) PostEnvs(c *gin.Context) - // (GET /envs/{envID}) - GetEnvsEnvID(c *gin.Context, envID EnvID, params GetEnvsEnvIDParams) + // (GET /envs/{envID}/builds/{buildID}) + GetEnvsEnvIDBuildsBuildID(c *gin.Context, envID EnvID, buildID BuildID, params GetEnvsEnvIDBuildsBuildIDParams) + + // (POST /envs/{envID}/builds/{buildID}/logs) + PostEnvsEnvIDBuildsBuildIDLogs(c *gin.Context, envID EnvID, buildID BuildID) // (GET /health) GetHealth(c *gin.Context) @@ -72,8 +75,8 @@ func (siw *ServerInterfaceWrapper) PostEnvs(c *gin.Context) { siw.Handler.PostEnvs(c) } -// GetEnvsEnvID operation middleware -func (siw *ServerInterfaceWrapper) GetEnvsEnvID(c *gin.Context) { +// GetEnvsEnvIDBuildsBuildID operation middleware +func (siw *ServerInterfaceWrapper) GetEnvsEnvIDBuildsBuildID(c *gin.Context) { var err error @@ -86,16 +89,58 @@ func (siw *ServerInterfaceWrapper) GetEnvsEnvID(c *gin.Context) { return } + // ------------- Path parameter "buildID" ------------- + var buildID BuildID + + err = runtime.BindStyledParameter("simple", false, "buildID", c.Param("buildID"), &buildID) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter buildID: %w", err), http.StatusBadRequest) + return + } + c.Set(AccessTokenAuthScopes, []string{}) // Parameter object where we will unmarshal all parameters from the context - var params GetEnvsEnvIDParams + var params GetEnvsEnvIDBuildsBuildIDParams + + // ------------- Optional query parameter "logsOffset" ------------- + + err = runtime.BindQueryParameter("form", true, false, "logsOffset", c.Request.URL.Query(), ¶ms.LogsOffset) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter logsOffset: %w", err), http.StatusBadRequest) + return + } + + for _, middleware := range siw.HandlerMiddlewares { + middleware(c) + if c.IsAborted() { + return + } + } + + siw.Handler.GetEnvsEnvIDBuildsBuildID(c, envID, buildID, params) +} + +// PostEnvsEnvIDBuildsBuildIDLogs operation middleware +func (siw *ServerInterfaceWrapper) PostEnvsEnvIDBuildsBuildIDLogs(c *gin.Context) { + + var err error + + // ------------- Path parameter "envID" ------------- + var envID EnvID + + err = runtime.BindStyledParameter("simple", false, "envID", c.Param("envID"), &envID) + if err != nil { + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter envID: %w", err), http.StatusBadRequest) + return + } - // ------------- Optional query parameter "logs" ------------- + // ------------- Path parameter "buildID" ------------- + var buildID BuildID - err = runtime.BindQueryParameter("form", true, false, "logs", c.Request.URL.Query(), ¶ms.Logs) + err = runtime.BindStyledParameter("simple", false, "buildID", c.Param("buildID"), &buildID) if err != nil { - siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter logs: %w", err), http.StatusBadRequest) + siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter buildID: %w", err), http.StatusBadRequest) return } @@ -106,7 +151,7 @@ func (siw *ServerInterfaceWrapper) GetEnvsEnvID(c *gin.Context) { } } - siw.Handler.GetEnvsEnvID(c, envID, params) + siw.Handler.PostEnvsEnvIDBuildsBuildIDLogs(c, envID, buildID) } // GetHealth operation middleware @@ -192,7 +237,8 @@ func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options router.GET(options.BaseURL+"/envs", wrapper.GetEnvs) router.POST(options.BaseURL+"/envs", wrapper.PostEnvs) - router.GET(options.BaseURL+"/envs/:envID", wrapper.GetEnvsEnvID) + router.GET(options.BaseURL+"/envs/:envID/builds/:buildID", wrapper.GetEnvsEnvIDBuildsBuildID) + router.POST(options.BaseURL+"/envs/:envID/builds/:buildID/logs", wrapper.PostEnvsEnvIDBuildsBuildIDLogs) router.GET(options.BaseURL+"/health", wrapper.GetHealth) router.POST(options.BaseURL+"/instances", wrapper.PostInstances) router.POST(options.BaseURL+"/instances/:instanceID/refreshes", wrapper.PostInstancesInstanceIDRefreshes) diff --git a/packages/api/internal/api/spec.gen.go b/packages/api/internal/api/spec.gen.go index f38c36f12..efc546ba1 100644 --- a/packages/api/internal/api/spec.gen.go +++ b/packages/api/internal/api/spec.gen.go @@ -18,29 +18,30 @@ import ( // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/8xYX2/bNhD/KgS3RyVy0+xFb2mbdUaHrmgLbEBgDLR0tthSpEqenBqBvvtwpP5achKn", - "f7Any+Lxjnf3u98ddcdTU5RGg0bHkzteCisKQLD+H+jd8hU9SM0TXgrMecS1KIAnzVrELXyppIWMJ2gr", - "iLhLcygEbcJ9SYIOrdRbXtcRl9qh0CkcVToQOEVzTcKuNNqBP/flYkE/qdEIGulRlKWSqUBpdPzJGU3v", - "en2/WtjwhP8S98GIw6qLr601NtjIwKVWlqSEJ/yFyBgdERzyOuKXi2c/3uZVhTlobLQyCHJk/PLHG39r", - "kG1MpTOy+NvPCPEHsDuwrZt1CwGf42u9k9boorFeWlOCRQlj4I71LTMK3kaCZWbDMAcGAy3RIa4irszW", - "BTUbUSnkyc1qAoNKqox5wYhLhMLNILRTLawVe/pfVmsl0+kR/84Bc7CHh2PSsbCFGcuMVnsm0hSck2sF", - "bL338gii6L1YG6NAaDLmUGDlpsY++PfzsQBdFTy54Wvyj5ygGhPZnpZ8PlbRTIX3NXvTMURjvfO5Ceuq", - "jnjI/CR9qclgelovzPxaxDfGFgI9ZeDzi95rqRG24IuiAOfE9pgi/tDxG0OtFjrusqGnmRMrCRofh7kg", - "Owe3p8CWbawp2G0u05xAQqsti7LUgkDI5kyNqfghe600f2zOR0TeBYdi+BZuj4fx0QFobd5fwLOHW3ki", - "gbSyEvcfiFCC7StfTx/NZ9BEs/RqDcKC/b2FWqi4f5FEeENGvtK8WG8+RywpxlelfAP7VplvdzmIzIs2", - "De+fs6t3y7M3sO93C78r0KHUG+PpRKKiteuLF+zq3ZJHfAfWheAszp+dL8icKUGLUvKEPz9fnC+o4ATm", - "3rcY9M4/bAGn4f1TOmRCqWEwqV4pM57PlxlP+GvAa9Jy0GsvTmwEHUUKpf7a8OTmgd4wyG+9mhDpTM+o", - "fJY2lVJ7ZgErqyGbetd37DnrnYcxCfXt7n5ZEhqCyzs3gdXNqibqFNRZPCYDFZbGzaTmpa9gJpiG2wOs", - "j7Pzzrg+PX4oeWGy/UFmikqhLIXFmOjzLBMoQtWlxlM8QZ7o/iVt+YqD3R9bbPapNSkCnjm01HX65jwt", - "6kOVYw9fmfQzWOaFWNpIDfh9LbWw+zkKy/zOjVRwTCutsdb/E/j21QzPRqHrlhac78dTIna5qVTG1sRO", - "5M7DhDSKzMihvrma9SdIsR1yhxNxPanEi+83kg3LblpkH3NoMpYLxxwKS23mf1ZTdRR4L77zea6P8t9r", - "wPGsRax7hP6umwY3vCgdobBeJA5Aq6MJ0nQGX1uw+TBKvW0iq8yWYS7GuGro7FZiPjOz+RbzpQJfL02H", - "aSbTPu3dLLuYDk0UxW9i92/A1DxxHzp5Isaai9FDspc/C485CBXGgVkk/uGXWZpD+nkOgWH9SAseq3of", - "ugC7pQLtQnta/HyW4naWCx8I7m1Tup89/Vg6hei0ay079fe1rqfDbjhwPopFv989fmx3SqFdsChJzbA+", - "SJbah3QtHpOuxU+k38FcO0Z6D5XVGDrxXX8jqGMLGwsuvw9R74PI+D4DXxE0TSpMomMoC2BomJI7uB9Z", - "y872+87yqRQ+uNHMsOTlzOV6zGfBbja+Tj2NzX7sR5dwzW4O7GPdhv+M6f4T0BNB4bfZXRv0yiqe8Lvw", - "qo53z+hqI6wUaxVCG1ZGfcvfr1wSx6KU53CxPs9gR470Ju8Ovyc633v7L5eO7hL/BQAA//8VU1DJ/BQA", - "AA==", + "H4sIAAAAAAAC/8xY32/buA//VwR9v49unXW9l7y1W28XbNiKdcAdUAQHxaZjbbbkSXS6oPD/fqDkn7GT", + "NNs67KlpRJEi+eGHZB55pPNCK1Bo+fyRF8KIHBCM+29VyixevKaPUvE5LwSmPOBK5MDn7WnADXwtpYGY", + "z9GUEHAbpZALuobbgkQtGqnWvKoCDmqzV6M/O02fVBaFimCv0p7AKZorEraFVhZcLC5nM/oTaYWgkD6K", + "oshkJFBqFX62WtF3nb7/G0j4nP8v7AIc+lMb3hijjbcRg42MLEgJn/NrETN6IljkVcAvZy+e3+ZViSko", + "rLUy8HJk/PL5jb/XyBJdqpgs/vErQnwHZgOmcbNqIOByfKM20miV19YLowswKGG3GIYaFzGFL5FgmE4Y", + "psCcKA92MdUD/zEN0HvJhJ5Mr61Xk4gyQz6/X46gRG9gTjDgEiG3EyhvVQtjxJb+L8pVJqPxE/9OAVMw", + "u49j0jJ/hWnDtMq2TEQRWCtXGbDV1skjiLzzYqV1BkKRMYsCSzs2due+n44FqDLn83ufDnKC6lTEWzpy", + "OV0GEyzR1f19yzIdf9XvaL2vA7ysAu5xNAJDpGMYv9sJM3cW8ESbXKAjIHx50fkvFcIaXInlYK1Y71PE", + "jzlSG2q00HMXNdlNvDiToPBp6POyPwvALDE6Zw+pjFKCC502nMwiAwJhslaGxH7MXiPNn5r9QVtog0Mx", + "fA8P+8P45AA0Ng+X8uTjlo6WICqNxO0d0ZO3feUq65P+AopI25ESCAPmzwZqvvb+RRLhNbW5mnNinfkU", + "saAYXxXyLWwbZa55piBiJ1q3z3/Orm4XZ29h290W7pYnV6kS7YhFYkZnNxfX7Op2wQO+AWN9cGbnL85n", + "ZE4XoEQh+Zy/PJ+dz6jgBKbOtxDUxn1YA47D+05aZCLL+sGkeqXMuO6wiPmcvwG8IS07nfvixLbSkqXI", + "sg8Jn98f6TS9/FbLEaVOdKDSZSkps2zLDGBpFMRj77r+P2W99TAkoa55HpYloT64nHMjWN0vKyJRQT3G", + "YdJTYaHtRGpeuQpmgil42MH6MDu32nbpcSPOtY63O5nJywxlIQyGRJ9nsUDhqy7SjuybPvyKrnzD3u1P", + "DTa71OoIAc8sGuo/Xavf09p7KocevtbRFzC+qbOolurx+0oqYbZTFBa7m4nMYJ9WOmON/yfw7esJng18", + "/y0MWNeZx0RsU11mMVsRO5E7xwlpEJmBQ12b1avPEGEzMvfn62pUiRc/b8Drl924yD41YxhLhWUWhaE2", + "85vVVBV43gsfXZ6r0L3Yho/1aFLtJcQ3gMMxjGh4Dx/ekG43DtrrduTpL3p7CK4TCT0Mq+CoYDNTkegO", + "ZFUM3xrUunxIta5TlOk1w1QMAVrz4oPEdGIMdL3qawmu8OpWRUPbhySxgLxf6+2QPBvPYJSUH2oWPwDR", + "6T6w6+qJkK23tmOyl78FvMNmj5luLVdxzEQHkb0dZQzwd37teW6QLw+1ssO4GTYgUcg7iMxUpV/dLpj1", + "ZwcWwacueDv03tltVp7vYvUXEytcH9wijsGn8NnQXE2iLwWR+dl2kkX/cscsSiH6MsWe/nzPPDlU9dHj", + "gD1Qt2l9P81fF+uwWUwOFEYzc6lukXI71pgmxwWzaNV/P3gPkV5/e3o6eH6K6aHd8TzQBouSVG+evWRl", + "W5+u2VPSNfuFs0RvSRvybAeV5RA64WO33lahgcSATQ8h6qMXGS7n8A1B0djNJFqGMgeGmmVyA4eRtWht", + "f2wtn0rGvfV8okdfHiGcxuN4+NvAc7LP96TMXTObJiSlyerd3M7DUBTyHC5W5zFseE/D4+7v2ta1rO4X", + "dEtb6H8BAAD//zBjcTnYFwAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/packages/api/internal/api/types.gen.go b/packages/api/internal/api/types.gen.go index 39513ed44..95385457a 100644 --- a/packages/api/internal/api/types.gen.go +++ b/packages/api/internal/api/types.gen.go @@ -21,6 +21,9 @@ const ( // Environment defines model for Environment. type Environment struct { + // BuildID Identifier of the build + BuildID string `json:"buildID"` + // EnvID Identifier of the environment EnvID string `json:"envID"` @@ -64,6 +67,9 @@ type NewInstance struct { EnvID string `json:"envID"` } +// BuildID defines model for buildID. +type BuildID = string + // EnvID defines model for envID. type EnvID = string @@ -94,14 +100,24 @@ type PostEnvsMultipartBody struct { EnvID *string `json:"envID,omitempty"` } -// GetEnvsEnvIDParams defines parameters for GetEnvsEnvID. -type GetEnvsEnvIDParams struct { - // Logs Index of the starting build log that should be returned with the environment - Logs *int `form:"logs,omitempty" json:"logs,omitempty"` +// GetEnvsEnvIDBuildsBuildIDParams defines parameters for GetEnvsEnvIDBuildsBuildID. +type GetEnvsEnvIDBuildsBuildIDParams struct { + // LogsOffset Index of the starting build log that should be returned with the environment + LogsOffset *int `form:"logsOffset,omitempty" json:"logsOffset,omitempty"` +} + +// PostEnvsEnvIDBuildsBuildIDLogsJSONBody defines parameters for PostEnvsEnvIDBuildsBuildIDLogs. +type PostEnvsEnvIDBuildsBuildIDLogsJSONBody struct { + // ApiSecret API secret + ApiSecret string `json:"apiSecret"` + Logs []string `json:"logs"` } // PostEnvsMultipartRequestBody defines body for PostEnvs for multipart/form-data ContentType. type PostEnvsMultipartRequestBody PostEnvsMultipartBody +// PostEnvsEnvIDBuildsBuildIDLogsJSONRequestBody defines body for PostEnvsEnvIDBuildsBuildIDLogs for application/json ContentType. +type PostEnvsEnvIDBuildsBuildIDLogsJSONRequestBody PostEnvsEnvIDBuildsBuildIDLogsJSONBody + // PostInstancesJSONRequestBody defines body for PostInstances for application/json ContentType. type PostInstancesJSONRequestBody = NewInstance diff --git a/packages/api/internal/db/envs.go b/packages/api/internal/db/envs.go index 7753390b9..d5662979e 100644 --- a/packages/api/internal/db/envs.go +++ b/packages/api/internal/db/envs.go @@ -5,9 +5,10 @@ import ( "github.com/volatiletech/sqlboiler/v4/queries/qm" + "github.com/volatiletech/sqlboiler/v4/boil" + "github.com/e2b-dev/infra/packages/api/internal/api" "github.com/e2b-dev/infra/packages/api/internal/db/models" - "github.com/volatiletech/sqlboiler/v4/boil" ) func (db *DB) DeleteEnv(envID string) error { @@ -30,9 +31,11 @@ func (db *DB) GetEnvs(teamID string) (result []*api.Environment, err error) { for _, env := range envs { result = append(result, &api.Environment{ - EnvID: env.ID, - Status: api.EnvironmentStatus(env.Status), - Public: env.Public, + EnvID: env.ID, + BuildID: "", + Status: api.EnvironmentStatus(env.Status), + Public: env.Public, + Logs: nil, }) } @@ -58,9 +61,11 @@ func (db *DB) GetEnv(envID string, teamID string) (env *api.Environment, err err dbEnv := dbEnvs[0] return &api.Environment{ - EnvID: dbEnv.ID, - Status: api.EnvironmentStatus(dbEnv.Status), - Public: dbEnv.Public, + EnvID: dbEnv.ID, + BuildID: "", + Status: api.EnvironmentStatus(dbEnv.Status), + Logs: nil, + Public: dbEnv.Public, }, nil } @@ -81,7 +86,7 @@ func (db *DB) CreateEnv(envID string, teamID string, dockerfile string) (*api.En return nil, errMsg } - return &api.Environment{EnvID: envID, Status: api.EnvironmentStatusBuilding, Public: false}, nil + return &api.Environment{EnvID: envID, BuildID: "", Logs: nil, Status: api.EnvironmentStatusBuilding, Public: false}, nil } func (db *DB) UpdateDockerfileEnv(envID string, dockerfile string) (*api.Environment, error) { @@ -105,7 +110,7 @@ func (db *DB) UpdateDockerfileEnv(envID string, dockerfile string) (*api.Environ return nil, fmt.Errorf("didn't find env to update, env with id '%s'", envID) } - return &api.Environment{EnvID: envID, Status: api.EnvironmentStatusBuilding, Public: false}, nil + return &api.Environment{EnvID: envID, BuildID: "", Logs: nil, Status: api.EnvironmentStatusBuilding, Public: false}, nil } func (db *DB) UpdateStatusEnv(envID string, status models.EnvStatusEnum) (*api.Environment, error) { @@ -127,7 +132,7 @@ func (db *DB) UpdateStatusEnv(envID string, status models.EnvStatusEnum) (*api.E return nil, fmt.Errorf("didn't find env to update to, env with id '%s'", envID) } - return &api.Environment{EnvID: envID, Status: api.EnvironmentStatus(status), Public: false}, nil + return &api.Environment{EnvID: envID, BuildID: "", Logs: nil, Status: api.EnvironmentStatus(status), Public: false}, nil } func (db *DB) HasEnvAccess(envID string, teamID string, public bool) (bool, error) { diff --git a/packages/api/internal/handlers/envs.go b/packages/api/internal/handlers/envs.go index 5dd54937e..66b25844f 100644 --- a/packages/api/internal/handlers/envs.go +++ b/packages/api/internal/handlers/envs.go @@ -20,7 +20,7 @@ import ( "github.com/e2b-dev/infra/packages/api/internal/utils" ) -func (a *APIStore) buildEnv(ctx context.Context, envID string, content io.Reader) { +func (a *APIStore) buildEnv(ctx context.Context, envID string, buildID string, content io.Reader) { childCtx, childSpan := a.tracer.Start(ctx, "build-env", trace.WithAttributes( attribute.String("env_id", envID), @@ -28,15 +28,7 @@ func (a *APIStore) buildEnv(ctx context.Context, envID string, content io.Reader ) defer childSpan.End() - buildID, err := uuid.GenerateUUID() - if err != nil { - err = fmt.Errorf("error when generating build id: %w", err) - ReportCriticalError(childCtx, err) - - return - } - - _, err = a.cloudStorage.streamFileUpload(strings.Join([]string{"v1", envID, buildID, "context.tar.gz"}, "/"), content) + _, err := a.cloudStorage.streamFileUpload(strings.Join([]string{"v1", envID, buildID, "context.tar.gz"}, "/"), content) if err != nil { err = fmt.Errorf("error when uploading file to cloud storage: %w", err) ReportCriticalError(childCtx, err) @@ -46,7 +38,7 @@ func (a *APIStore) buildEnv(ctx context.Context, envID string, content io.Reader var buildStatus models.EnvStatusEnum - err = a.nomad.BuildEnvJob(a.tracer, childCtx, envID, buildID) + err = a.nomad.BuildEnvJob(a.tracer, childCtx, envID, buildID, a.apiSecret) if err != nil { err = fmt.Errorf("error when starting build: %w", err) ReportCriticalError(childCtx, err) @@ -166,13 +158,23 @@ func (a *APIStore) PostEnvs(c *gin.Context) { ReportEvent(ctx, "updated environment") } + buildID, err := uuid.GenerateUUID() + if err != nil { + err = fmt.Errorf("error when generating build id: %w", err) + ReportCriticalError(ctx, err) + + return + } + + env.BuildID = buildID + go func() { buildContext, childSpan := a.tracer.Start( trace.ContextWithSpanContext(a.Ctx, span.SpanContext()), "background-build-env", ) - a.buildEnv(buildContext, envID, fileContent) + a.buildEnv(buildContext, envID, buildID, fileContent) childSpan.End() }() @@ -223,10 +225,7 @@ func (a *APIStore) GetEnvs( c.JSON(http.StatusOK, envs) } -func (a *APIStore) GetEnvsEnvID( - c *gin.Context, - envID string, -) { +func (a *APIStore) GetEnvsEnvIDBuildsBuildID(c *gin.Context, envID api.EnvID, buildID api.BuildID, params api.GetEnvsEnvIDBuildsBuildIDParams) { ctx := c.Request.Context() userID := c.Value(constants.UserIDContextKey).(string) @@ -264,9 +263,53 @@ func (a *APIStore) GetEnvsEnvID( ReportEvent(ctx, "got environment detail") + env.BuildID = buildID + + logs, err := a.dockerBuildLogs.Get(envID, buildID) + if err == nil { + env.Logs = logs[*params.LogsOffset:] + } else { + env.Logs = []string{} + msg := fmt.Sprintf("no logs found for env %s and build %s", envID, buildID) + ReportEvent(ctx, msg) + } + + ReportEvent(ctx, "got environment build logs") + a.IdentifyAnalyticsTeam(team.ID) properties := a.GetPackageToPosthogProperties(&c.Request.Header) a.CreateAnalyticsUserEvent(userID, team.ID, "got environment detail", properties.Set("environment", envID)) c.JSON(http.StatusOK, env) } + +func (a *APIStore) PostEnvsEnvIDBuildsBuildIDLogs(c *gin.Context, envID api.EnvID, buildID string) { + ctx := c.Request.Context() + + body, err := parseBody[api.PostEnvsEnvIDBuildsBuildIDLogsJSONRequestBody](ctx, c) + if err != nil { + a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Error when parsing body: %s", err)) + + return + } + + if body.ApiSecret != a.apiSecret { + a.sendAPIStoreError(c, http.StatusForbidden, "Invalid api secret") + + return + } + + err = a.dockerBuildLogs.Append(envID, buildID, body.Logs) + if err != nil { + a.sendAPIStoreError(c, http.StatusInternalServerError, fmt.Sprintf("Error when saving docker build logs: %s", err)) + + err = fmt.Errorf("error when saving docker build logs: %w", err) + ReportCriticalError(ctx, err) + + return + } + + ReportEvent(ctx, "got docker build log") + + c.JSON(http.StatusCreated, nil) +} diff --git a/packages/api/internal/handlers/store.go b/packages/api/internal/handlers/store.go index 70a307778..fe8462f76 100644 --- a/packages/api/internal/handlers/store.go +++ b/packages/api/internal/handlers/store.go @@ -6,7 +6,6 @@ import ( "log" "net/http" "os" - "sync" "time" "cloud.google.com/go/storage" @@ -23,15 +22,15 @@ import ( ) type APIStore struct { - Ctx context.Context - posthog posthog.Client - tracer trace.Tracer - cache *nomad.InstanceCache - nomad *nomad.NomadClient - supabase *db.DB - cloudStorage *cloudStorage - NextId int64 - Lock sync.Mutex + Ctx context.Context + posthog posthog.Client + tracer trace.Tracer + cache *nomad.InstanceCache + nomad *nomad.NomadClient + supabase *db.DB + cloudStorage *cloudStorage + dockerBuildLogs *utils.BuildLogsCache + apiSecret string } func NewAPIStore() *APIStore { @@ -110,15 +109,23 @@ func NewAPIStore() *APIStore { context: ctx, } + apiSecret := os.Getenv("API_SECRET") + if apiSecret == "" { + apiSecret = "SUPER_SECR3T_4PI_K3Y" + } + + dockerBuildLogs := utils.NewBuildLogsCache() + return &APIStore{ - Ctx: ctx, - nomad: nomadClient, - supabase: supabaseClient, - NextId: 1000, - cache: cache, - tracer: tracer, - posthog: posthogClient, - cloudStorage: cStorage, + Ctx: ctx, + nomad: nomadClient, + supabase: supabaseClient, + cache: cache, + tracer: tracer, + posthog: posthogClient, + cloudStorage: cStorage, + apiSecret: apiSecret, + dockerBuildLogs: dockerBuildLogs, } } diff --git a/packages/api/internal/nomad/env-build.hcl b/packages/api/internal/nomad/env-build.hcl index 68932ac48..a1724dd50 100644 --- a/packages/api/internal/nomad/env-build.hcl +++ b/packages/api/internal/nomad/env-build.hcl @@ -33,6 +33,7 @@ job "{{ .JobName }}/{{ .EnvID }}-{{ .BuildID }}" { KERNEL_IMAGE_PATH = "/fc-vm/vmlinux.bin" FIRECRACKER_BINARY_PATH = "/usr/bin/firecracker" CONTEXT_FILE_NAME = "context.tar.gz" + API_SECRET = "{{ .APISecret }}" } config { diff --git a/packages/api/internal/nomad/env.go b/packages/api/internal/nomad/env.go index 3c5c04289..568ac46d5 100644 --- a/packages/api/internal/nomad/env.go +++ b/packages/api/internal/nomad/env.go @@ -36,6 +36,7 @@ func (n *NomadClient) BuildEnvJob( envID string, // build is used to separate builds of the same env that can start simultaneously. Should be an UUID generated on server. buildID string, + apiSecret string, ) error { childCtx, childSpan := t.Start(ctx, "build-env-job", trace.WithAttributes( @@ -55,6 +56,7 @@ func (n *NomadClient) BuildEnvJob( var jobDef bytes.Buffer jobVars := struct { + APISecret string BuildID string EnvID string SpanID string @@ -66,6 +68,7 @@ func (n *NomadClient) BuildEnvJob( MemoryMB int DiskSizeMB int }{ + APISecret: apiSecret, BuildID: buildID, SpanID: spanID, DiskSizeMB: defaultDiskSizeMB, diff --git a/packages/api/internal/utils/build_logs_cache.go b/packages/api/internal/utils/build_logs_cache.go new file mode 100644 index 000000000..8c22ba31d --- /dev/null +++ b/packages/api/internal/utils/build_logs_cache.go @@ -0,0 +1,60 @@ +package utils + +import ( + "fmt" + "sync" + "time" + + "github.com/jellydator/ttlcache/v3" +) + +const ( + logsExpiration = time.Second * 60 * 5 // 5 minutes +) + +type buildEnvID struct { + envID string + buildID string +} + +type BuildLogsCache struct { + cache *ttlcache.Cache[buildEnvID, []string] + mutex sync.RWMutex +} + +func NewBuildLogsCache() *BuildLogsCache { + return &BuildLogsCache{ + cache: ttlcache.New(ttlcache.WithTTL[buildEnvID, []string](logsExpiration)), + mutex: sync.RWMutex{}, + } +} + +func (c *BuildLogsCache) Get(envID, buildID string) ([]string, error) { + c.mutex.RLock() + defer c.mutex.RUnlock() + + key := &buildEnvID{envID: envID, buildID: buildID} + item := c.cache.Get(*key) + + if item != nil { + return item.Value(), nil + } + + return nil, fmt.Errorf("build %s for %s not found in cache", buildID, envID) +} + +func (c *BuildLogsCache) Append(envID, buildID string, logs []string) error { + c.mutex.Lock() + defer c.mutex.Unlock() + + key := &buildEnvID{envID: envID, buildID: buildID} + item := c.cache.Get(*key) + + if item == nil { + c.cache.Set(*key, logs, logsExpiration) + } else { + c.cache.Set(*key, append(item.Value(), logs...), logsExpiration) + } + + return nil +} diff --git a/packages/api/main.tf b/packages/api/main.tf index 0c61b41aa..25e03bbe4 100644 --- a/packages/api/main.tf +++ b/packages/api/main.tf @@ -5,6 +5,10 @@ terraform { source = "kreuzwerker/docker" version = "2.16.0" } + random = { + source = "hashicorp/random" + version = "3.5.1" + } } } @@ -29,6 +33,23 @@ data "google_secret_manager_secret_version" "api_admin_key" { secret = "api-admin-key" } +resource "random_password" "api_secret" { + length = 32 +} + +resource "google_secret_manager_secret" "api_secret" { + secret_id = "api-secret" + + replication { + automatic = true + } +} + +resource "google_secret_manager_secret_version" "api_secret_value" { + secret = google_secret_manager_secret.api_secret.id + + secret_data = random_password.api_secret.result +} resource "nomad_job" "api" { jobspec = file("${path.module}/api.hcl") @@ -49,6 +70,7 @@ resource "nomad_job" "api" { consul_token = var.consul_token environment = var.environment bucket_name = var.bucket_name + api_secret = resource.random_password.api_secret.result } } } diff --git a/packages/env-build-task-driver/internal/driver.go b/packages/env-build-task-driver/internal/driver.go index f9298f6f4..91244ebba 100644 --- a/packages/env-build-task-driver/internal/driver.go +++ b/packages/env-build-task-driver/internal/driver.go @@ -2,7 +2,6 @@ package internal import ( "context" - "github.com/docker/docker/client" docker "github.com/fsouza/go-dockerclient" "github.com/hashicorp/go-hclog" @@ -91,15 +90,15 @@ func NewPlugin(logger hclog.Logger) drivers.DriverPlugin { } return &Driver{ - tracer: tracer, - docker: client, + tracer: tracer, + docker: client, legacyDockerClient: legacyClient, - eventer: eventer.NewEventer(ctx, logger), - config: &Config{}, - tasks: newTaskStore(), - ctx: ctx, - signalShutdown: cancel, - logger: logger, + eventer: eventer.NewEventer(ctx, logger), + config: &Config{}, + tasks: newTaskStore(), + ctx: ctx, + signalShutdown: cancel, + logger: logger, } } diff --git a/packages/env-build-task-driver/internal/env/env.go b/packages/env-build-task-driver/internal/env/env.go index 24ce5c86d..fce213f34 100644 --- a/packages/env-build-task-driver/internal/env/env.go +++ b/packages/env-build-task-driver/internal/env/env.go @@ -3,6 +3,7 @@ package env import ( "context" "fmt" + "io" "os" "path/filepath" @@ -63,6 +64,9 @@ type Env struct { // The amount of free disk to allocate to the VM, in MiB. DiskSizeMB int64 + + // Path to the directory where the temporary files for the build are stored. + BuildLogsWriter io.Writer } //go:embed provision.sh diff --git a/packages/env-build-task-driver/internal/env/mock_build.go b/packages/env-build-task-driver/internal/env/mock_build.go index f482eed2b..5424383f2 100644 --- a/packages/env-build-task-driver/internal/env/mock_build.go +++ b/packages/env-build-task-driver/internal/env/mock_build.go @@ -2,7 +2,6 @@ package env import ( "context" - "github.com/docker/docker/client" docker "github.com/fsouza/go-dockerclient" "go.opentelemetry.io/otel" @@ -34,6 +33,9 @@ func MockBuild(envID, buildID string) { vCPUCount := int64(1) memoryMB := int64(512) diskSizeMB := int64(512) + apiSecret := "SUPER_SECR3T_4PI_K3Y" + + writer := NewWriter(envID, buildID, apiSecret) e := Env{ BuildID: buildID, @@ -49,10 +51,13 @@ func MockBuild(envID, buildID string) { FirecrackerBinaryPath: firecrackerBinaryPath, EnvdPath: envdPath, ContextFileName: contextFileName, + BuildLogsWriter: writer, } err = e.Build(ctx, tracer, client, legacyClient) if err != nil { panic(err) } + writer.Close() + <-writer.Done } diff --git a/packages/env-build-task-driver/internal/env/rootfs.go b/packages/env-build-task-driver/internal/env/rootfs.go index 60844fcab..3e0ad3cb3 100644 --- a/packages/env-build-task-driver/internal/env/rootfs.go +++ b/packages/env-build-task-driver/internal/env/rootfs.go @@ -38,6 +38,20 @@ type Rootfs struct { env *Env } +type MultiWriter struct { + writers []io.Writer +} + +func (mw *MultiWriter) Write(p []byte) (n int, err error) { + for _, writer := range mw.writers { + _, err := writer.Write(p) + if err != nil { + return 0, err + } + } + return len(p), nil +} + func NewRootfs(ctx context.Context, tracer trace.Tracer, env *Env, docker *client.Client, legacyDocker *docker.Client) (*Rootfs, error) { childCtx, childSpan := tracer.Start(ctx, "new-rootfs") defer childSpan.End() @@ -48,6 +62,7 @@ func NewRootfs(ctx context.Context, tracer trace.Tracer, env *Env, docker *clien env: env, } + defer rootfs.cleanupDockerImage(childCtx, tracer) err := rootfs.buildDockerImage(childCtx, tracer) if err != nil { errMsg := fmt.Errorf("error building docker image %w", err) @@ -55,8 +70,6 @@ func NewRootfs(ctx context.Context, tracer trace.Tracer, env *Env, docker *clien return nil, errMsg } - defer rootfs.cleanupDockerImage(childCtx, tracer) - err = rootfs.createRootfsFile(childCtx, tracer) if err != nil { errMsg := fmt.Errorf("error creating rootfs file %w", err) @@ -99,21 +112,29 @@ func (r *Rootfs) buildDockerImage(ctx context.Context, tracer trace.Tracer) erro defer innerBuildSpan.End() buildOutputWriter := telemetry.NewEventWriter(innerBuildCtx, "docker-build-output") + writer := &MultiWriter{ + writers: []io.Writer{buildOutputWriter, r.env.BuildLogsWriter}, + } err = r.legacyClient.BuildImage(docker.BuildImageOptions{ Context: buildCtx, Dockerfile: dockerfileName, InputStream: dockerContextFile, - OutputStream: buildOutputWriter, + OutputStream: writer, Name: r.dockerTag(), }) + if err != nil { + r.env.BuildLogsWriter.Write([]byte(err.Error() + "\n")) + r.env.BuildLogsWriter.Write([]byte("Build failed, received error while building docker image.\n")) + errMsg := fmt.Errorf("error building docker image for env %w", err) telemetry.ReportCriticalError(childCtx, errMsg) return errMsg } + r.env.BuildLogsWriter.Write([]byte("Running postprocessing. It can take up to few minutes.\n")) telemetry.ReportEvent(childCtx, "finished docker image build", attribute.String("tag", r.dockerTag())) return nil diff --git a/packages/env-build-task-driver/internal/env/writer.go b/packages/env-build-task-driver/internal/env/writer.go new file mode 100644 index 000000000..aa864028f --- /dev/null +++ b/packages/env-build-task-driver/internal/env/writer.go @@ -0,0 +1,121 @@ +package env + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + "time" +) + +const ( + API_HOST = "http://localhost:50001" + flushInterval = time.Millisecond * 200 +) + +type BuildLogsWriter struct { + httpClient *http.Client + inputChannel chan string + Done chan struct{} + envID string + buildID string + apiSecret string +} + +type LogsData struct { + APISecret string `json:"apiSecret"` + Logs []string `json:"logs"` +} + +func (w BuildLogsWriter) Close() error { + close(w.inputChannel) + + return nil +} + +func (w BuildLogsWriter) sendLogsAPICall(logs []string) error { + data := LogsData{ + Logs: logs, + APISecret: w.apiSecret, + } + + jsonData, err := json.Marshal(data) + if err != nil { + err = fmt.Errorf("error marshaling json: %w", err) + + return err + } + + response, err := w.httpClient.Post(API_HOST+"/envs/"+w.envID+"/builds/"+w.buildID+"/logs", "application/json", bytes.NewBuffer(jsonData)) + + if err != nil { + err = fmt.Errorf("error posting logs to API: %w", err) + + return err + } + defer response.Body.Close() + + if err != nil { + err = fmt.Errorf("error posting logs to API: %w", err) + return err + } + return nil +} + +func (w BuildLogsWriter) sendToAPI() { + var logs []string + + timer := time.NewTicker(flushInterval) + +forLoop: + for { + select { + case log, open := <-w.inputChannel: + logs = append(logs, log) + if !open { + timer.Stop() + + break forLoop + } + case <-timer.C: + if len(logs) > 0 { + err := w.sendLogsAPICall(logs) + if err != nil { + fmt.Println(err) + } + + logs = nil // Clear the logs slice + } + } + } + + if len(logs) > 0 { + err := w.sendLogsAPICall(logs) + if err != nil { + fmt.Println(err) + } + } + + close(w.Done) +} + +func (w BuildLogsWriter) Write(p []byte) (n int, err error) { + w.inputChannel <- string(p) + + return len(p), nil +} + +func NewWriter(envID string, buildID string, apiSecret string) BuildLogsWriter { + writer := BuildLogsWriter{ + inputChannel: make(chan string, 100), + Done: make(chan struct{}), + httpClient: &http.Client{}, + envID: envID, + buildID: buildID, + apiSecret: apiSecret, + } + + go writer.sendToAPI() + + return writer +} diff --git a/packages/env-build-task-driver/internal/task.go b/packages/env-build-task-driver/internal/task.go index cc6c13991..549b7697d 100644 --- a/packages/env-build-task-driver/internal/task.go +++ b/packages/env-build-task-driver/internal/task.go @@ -79,6 +79,9 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive pkgsPath := cfg.Env["PKGS_PATH"] firecrackerBinaryPath := cfg.Env["FIRECRACKER_BINARY_PATH"] contextFileName := cfg.Env["CONTEXT_FILE_NAME"] + apiSecret := cfg.Env["API_SECRET"] + + writer := env.NewWriter(taskConfig.EnvID, taskConfig.BuildID, apiSecret) env := env.Env{ BuildID: taskConfig.BuildID, @@ -94,6 +97,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive FirecrackerBinaryPath: firecrackerBinaryPath, EnvdPath: envdPath, ContextFileName: contextFileName, + BuildLogsWriter: writer, } cancellableBuildContext, cancel := context.WithCancel(d.ctx) @@ -122,7 +126,6 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive go func() { defer cancel() - h.cancel = cancel buildContext, childBuildSpan := d.tracer.Start( @@ -132,6 +135,8 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive defer childBuildSpan.End() h.run(buildContext, d.tracer, d.docker, d.legacyDockerClient) + writer.Close() + <-writer.Done }() return handle, nil, nil diff --git a/spec/openapi.yml b/spec/openapi.yml index 6198a2f68..8b89d1ec1 100644 --- a/spec/openapi.yml +++ b/spec/openapi.yml @@ -4,10 +4,7 @@ info: title: E2B API servers: - - url: "{server}/v1" - variables: - server: - default: https://api.e2b.dev + - url: https://api.e2b.dev components: securitySchemes: @@ -27,6 +24,12 @@ components: required: true schema: type: string + buildID: + name: buildID + in: path + required: true + schema: + type: string instanceID: name: instanceID in: path @@ -73,6 +76,7 @@ components: Environment: required: - envID + - buildID - status - public - logs @@ -86,6 +90,9 @@ components: envID: type: string description: Identifier of the environment + buildID: + type: string + description: Identifier of the build status: type: string description: Status of the environment @@ -180,12 +187,7 @@ paths: 401: $ref: "#/components/responses/401" 404: - description: Error refreshing instance - not found - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - + $ref: "#/components/responses/404" /envs: get: description: List all environments @@ -247,7 +249,7 @@ paths: 500: $ref: "#/components/responses/500" - /envs/{envID}: + /envs/{envID}/builds/{buildID}: get: description: Get environment info tags: [envs] @@ -255,8 +257,9 @@ paths: - AccessTokenAuth: [] parameters: - $ref: "#/components/parameters/envID" + - $ref: "#/components/parameters/buildID" - in: query - name: logs + name: logsOffset schema: default: 0 type: integer @@ -274,3 +277,35 @@ paths: $ref: "#/components/responses/404" 500: $ref: "#/components/responses/500" + + /envs/{envID}/builds/{buildID}/logs: + post: + description: Add a build log + tags: [envs] + parameters: + - $ref: "#/components/parameters/envID" + - $ref: "#/components/parameters/buildID" + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - apiSecret + - logs + properties: + apiSecret: + description: API secret + type: string + logs: + type: array + items: + type: string + responses: + 201: + description: Successfully added log + 401: + $ref: "#/components/responses/401" + 404: + $ref: "#/components/responses/404" \ No newline at end of file