diff --git a/cmd/builder/builder.go b/cmd/builder/builder.go index bfa0df70..ef2aa882 100644 --- a/cmd/builder/builder.go +++ b/cmd/builder/builder.go @@ -223,7 +223,7 @@ func (b Builder) initToken() error { btConfig.Workers.OCI.Snapshotter = "auto" btConfig.Workers.OCI.NoProcessSandbox = true btConfig.Workers.OCI.GC = ptr.Of(true) - btConfig.Workers.OCI.GCKeepStorage = 10 << 30 // 10GB + btConfig.Workers.OCI.GCKeepStorage.Bytes = 10 << 30 // 10GB btConfig.Workers.OCI.MaxParallelism = 4 btConfig.Workers.OCI.CNIPoolSize = 16 btConfig.Workers.OCI.Rootless = true diff --git a/go.mod b/go.mod index 0613caaf..c8fee045 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,9 @@ go 1.19 require ( github.com/BurntSushi/toml v1.3.2 github.com/alicebob/miniredis/v2 v2.30.4 - github.com/anchore/syft v0.85.0 - github.com/aquasecurity/trivy v0.43.1 - github.com/aws/aws-sdk-go v1.44.312 + github.com/anchore/syft v0.86.1 + github.com/aquasecurity/trivy v0.44.0 + github.com/aws/aws-sdk-go v1.44.314 github.com/bytedance/sonic v1.9.2 github.com/caarlos0/env/v9 v9.0.0 github.com/casbin/casbin/v2 v2.73.0 @@ -15,6 +15,7 @@ require ( github.com/deckarep/golang-set/v2 v2.3.0 github.com/distribution/distribution/v3 v3.0.0-20230722181636-7b502560cad4 github.com/docker/cli v24.0.5+incompatible + github.com/docker/docker v24.0.5+incompatible github.com/dustin/go-humanize v1.0.1 github.com/fatih/color v1.15.0 github.com/glebarez/sqlite v1.9.0 @@ -33,12 +34,12 @@ require ( github.com/labstack/echo/v4 v4.11.1 github.com/matoous/go-nanoid v1.5.0 github.com/matoous/go-nanoid/v2 v2.0.0 - github.com/moby/buildkit v0.11.6 + github.com/moby/buildkit v0.12.0 github.com/opencontainers/distribution-spec/specs-go v0.0.0-20230727214836-6bc87156eacf github.com/opencontainers/go-digest v1.0.0 github.com/redis/go-redis/v9 v9.0.5 github.com/rs/zerolog v1.30.0 - github.com/shirou/gopsutil/v3 v3.23.6 + github.com/shirou/gopsutil/v3 v3.23.7 github.com/smartystreets/goconvey v1.8.1 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 @@ -50,7 +51,7 @@ require ( github.com/wagslane/go-password-validator v0.3.0 go.uber.org/mock v0.2.0 golang.org/x/crypto v0.11.0 - golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 + golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b golang.org/x/oauth2 v0.10.0 gorm.io/driver/mysql v1.5.1 gorm.io/driver/postgres v1.5.2 @@ -72,9 +73,9 @@ require ( github.com/anchore/go-logger v0.0.0-20230627193650-d65da4224867 // indirect github.com/anchore/go-struct-converter v0.0.0-20230627203149-c72ef8859ca9 // indirect github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501 // indirect - github.com/anchore/stereoscope v0.0.0-20230627195312-cd49355d934e // indirect + github.com/anchore/stereoscope v0.0.0-20230727211946-d1f3d766295e // indirect github.com/andybalholm/brotli v1.0.5 // indirect - github.com/aquasecurity/trivy-db v0.0.0-20230703082116-dc52e83376ce // indirect + github.com/aquasecurity/trivy-db v0.0.0-20230726112157-167ba4f2faeb // indirect github.com/becheran/wildmatch-go v1.0.0 // indirect github.com/bmatcuk/doublestar/v4 v4.6.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect @@ -86,7 +87,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v24.0.4+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -169,7 +169,7 @@ require ( github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/smarty/assertions v1.15.0 // indirect - github.com/spdx/tools-golang v0.5.2 // indirect + github.com/spdx/tools-golang v0.5.3 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/go.sum b/go.sum index d15a7df1..78ea724f 100644 --- a/go.sum +++ b/go.sum @@ -93,26 +93,26 @@ github.com/anchore/go-struct-converter v0.0.0-20230627203149-c72ef8859ca9/go.mod github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04 h1:VzprUTpc0vW0nnNKJfJieyH/TZ9UYAnTZs5/gHTdAe8= github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501 h1:AV7qjwMcM4r8wFhJq3jLRztew3ywIyPTRapl2T1s9o8= github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501/go.mod h1:Blo6OgJNiYF41ufcgHKkbCKF2MDOMlrqhXv/ij6ocR4= -github.com/anchore/stereoscope v0.0.0-20230627195312-cd49355d934e h1:zhk3ZLtomMJ750nNCE+c24PonMzoO/SeL/4uTr1L9kM= -github.com/anchore/stereoscope v0.0.0-20230627195312-cd49355d934e/go.mod h1:0LsgHgXO4QFnk2hsYwtqd3fR18PIZXlFLIl2qb9tu3g= -github.com/anchore/syft v0.85.0 h1:JShy/YIqffcIR3cvssABGr/yNDRCgZwpcQPcRLO2nHc= -github.com/anchore/syft v0.85.0/go.mod h1:nCMEh98C1BEfkH49HXKeJNPcUEfDM4B6xmptGT5Lv3Q= +github.com/anchore/stereoscope v0.0.0-20230727211946-d1f3d766295e h1:S6IhYpsBCpvphlHA1tN0glSG/kjVvFzC6OJuU2qW5Pc= +github.com/anchore/stereoscope v0.0.0-20230727211946-d1f3d766295e/go.mod h1:0LsgHgXO4QFnk2hsYwtqd3fR18PIZXlFLIl2qb9tu3g= +github.com/anchore/syft v0.86.1 h1:XYD1iBbLekkyWvpmZoWQAdVYUJT1S0OPqCTlfr3WWk0= +github.com/anchore/syft v0.86.1/go.mod h1:I0dtaA+YkEMEGPqc5ho3Q8VxoRgg4fmvHZ44m0OvFPs= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/aquasecurity/trivy v0.43.1 h1:p1zxj4OQ4GfYsQnJsSl13B1LRmfhp1ahSEmS7uTnVQQ= -github.com/aquasecurity/trivy v0.43.1/go.mod h1:q5xIkiurEA6+Ht9cs3Ut85vzUBq4y1N4s7r9AvloEcQ= -github.com/aquasecurity/trivy-db v0.0.0-20230703082116-dc52e83376ce h1:swoQLWQoZ4HW13XeEji217TTcgi61MuMZdsKrqSTE0A= -github.com/aquasecurity/trivy-db v0.0.0-20230703082116-dc52e83376ce/go.mod h1:cXuqKo+FaMY0ixJNoUcyDHdfCBRPWOysI2Td8N4fRsg= +github.com/aquasecurity/trivy v0.44.0 h1:g7vC3di5S2CrnJw0zBmf+CU8Kgrt9zq+Zj5ji99Q7bc= +github.com/aquasecurity/trivy v0.44.0/go.mod h1:OTjCAcrU3eTA10Xt4d4P6EJkBXPWPxBCXA4NaX3gEQ8= +github.com/aquasecurity/trivy-db v0.0.0-20230726112157-167ba4f2faeb h1:uz2+9G7E0/mjf5Q0MB/BwbpdObU34CKGUdnypTYWTfs= +github.com/aquasecurity/trivy-db v0.0.0-20230726112157-167ba4f2faeb/go.mod h1:st35g9O0ecDGBqnRHNFFz8imlDD3GWTCwo1WyJixI2c= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= -github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.314 h1:d/5Jyk/Fb+PBd/4nzQg0JuC2W4A0knrDIzBgK/ggAow= +github.com/aws/aws-sdk-go v1.44.314/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/becheran/wildmatch-go v1.0.0 h1:mE3dGGkTmpKtT4Z+88t8RStG40yN9T+kFEGj2PZFSzA= github.com/becheran/wildmatch-go v1.0.0/go.mod h1:gbMvj0NtVdJ15Mg/mH9uxk2R1QCistMyU7d9KFzroX4= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -199,8 +199,8 @@ github.com/docker/cli v24.0.5+incompatible h1:WeBimjvS0eKdH4Ygx+ihVq1Q++xg36M/rM github.com/docker/cli v24.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.4+incompatible h1:s/LVDftw9hjblvqIeTiGYXBCD95nOEEl7qRsRrIOuQI= -github.com/docker/docker v24.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY= +github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -655,8 +655,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/buildkit v0.11.6 h1:VYNdoKk5TVxN7k4RvZgdeM4GOyRvIi4Z8MXOY7xvyUs= -github.com/moby/buildkit v0.11.6/go.mod h1:GCqKfHhz+pddzfgaR7WmHVEE3nKKZMMDPpK8mh3ZLv4= +github.com/moby/buildkit v0.12.0 h1:hgPDVSeondFLb28cBtRR5O0N4t8uWGJ4YNukT2aICIs= +github.com/moby/buildkit v0.12.0/go.mod h1:+n9GmkxwBCjVz4u7wmiyh+oqvjIjQM+1zk3iJrWfdos= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -758,8 +758,8 @@ github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624 github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/shirou/gopsutil/v3 v3.23.6 h1:5y46WPI9QBKBbK7EEccUPNXpJpNrvPuTD0O2zHEHT08= -github.com/shirou/gopsutil/v3 v3.23.6/go.mod h1:j7QX50DrXYggrpN30W0Mo+I4/8U2UUIQrnrhqUeWrAU= +github.com/shirou/gopsutil/v3 v3.23.7 h1:C+fHO8hfIppoJ1WdsVm1RoI0RwXoNdfTK7yWXV0wVj4= +github.com/shirou/gopsutil/v3 v3.23.7/go.mod h1:c4gnmoRC0hQuaLqvxnx1//VXQ0Ms/X9UnJF8pddY5z4= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -779,8 +779,8 @@ github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sS github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb/go.mod h1:uKWaldnbMnjsSAXRurWqqrdyZen1R7kxl8TkmWk2OyM= -github.com/spdx/tools-golang v0.5.2 h1:dtMNjJreWPe37584ajk7m/rQtfJaLpRMk7pUGgvekOg= -github.com/spdx/tools-golang v0.5.2/go.mod h1:/ETOahiAo96Ob0/RAIBmFZw6XN0yTnyr/uFZm2NTMhI= +github.com/spdx/tools-golang v0.5.3 h1:ialnHeEYUC4+hkm5vJm4qz2x+oEJbS0mAMFrNXdQraY= +github.com/spdx/tools-golang v0.5.3/go.mod h1:/ETOahiAo96Ob0/RAIBmFZw6XN0yTnyr/uFZm2NTMhI= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= @@ -951,8 +951,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 h1:/yRP+0AN7mf5DkD3BAI6TOFnd51gEoDEb8o35jIFtgw= -golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= +golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1167,7 +1167,6 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index 4072e20b..2f0d0411 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -40,6 +40,10 @@ const ( // BlobUploads represent blob uploads // file always represent like: blob_uploads/{upload_id} BlobUploads = "blob_uploads" + // BlobUploadParts represent blob upload parts + BlobUploadParts = "blob_upload_parts" + // BuilderLogs represent builder logs + BuilderLogs = "builder_logs" // DefaultTimePattern time pattern DefaultTimePattern = "2006-01-02 15:04:05" // ContextJti represents jti in context diff --git a/pkg/dal/migrations/mysql/0001_initialize.down.sql b/pkg/dal/migrations/mysql/0001_initialize.down.sql index ea86f02e..c5051be7 100644 --- a/pkg/dal/migrations/mysql/0001_initialize.down.sql +++ b/pkg/dal/migrations/mysql/0001_initialize.down.sql @@ -2,8 +2,6 @@ DROP TABLE IF EXISTS `namespaces`; DROP TABLE IF EXISTS `repositories`; -DROP TABLE IF EXISTS `repository_tags`; - DROP TABLE IF EXISTS `artifacts`; DROP TABLE IF EXISTS `tags`; @@ -26,5 +24,15 @@ DROP TABLE IF EXISTS `proxy_artifact_blobs`; DROP TABLE IF EXISTS `proxy_tag_tasks`; -DROP TABLE IF EXISTS `casbin_rules`; +DROP TABLE IF EXISTS `audits`; + +DROP TABLE IF EXISTS `daemon_logs`; + +DROP TABLE IF EXISTS `webhooks`; + +DROP TABLE IF EXISTS `webhook_logs`; + +DROP TABLE IF EXISTS `builders`; + +DROP TABLE IF EXISTS `builder_logs`; diff --git a/pkg/dal/migrations/mysql/0001_initialize.up.sql b/pkg/dal/migrations/mysql/0001_initialize.up.sql index 2c248e8a..2a17936e 100644 --- a/pkg/dal/migrations/mysql/0001_initialize.up.sql +++ b/pkg/dal/migrations/mysql/0001_initialize.up.sql @@ -270,3 +270,20 @@ CREATE TABLE IF NOT EXISTS `webhook_logs` ( FOREIGN KEY (`webhook_id`) REFERENCES `webhooks` (`id`) ); +CREATE TABLE IF NOT EXISTS `builders` ( + `id` bigint AUTO_INCREMENT PRIMARY KEY, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + `deleted_at` bigint NOT NULL DEFAULT 0, +); + +CREATE TABLE IF NOT EXISTS `builder_logs` ( + `id` bigint AUTO_INCREMENT PRIMARY KEY, + `builder_id` bigint NOT NULL, + `log` LONGBLOB, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + `deleted_at` bigint NOT NULL DEFAULT 0, + FOREIGN KEY (`builder_id`) REFERENCES `builders` (`id`) +); + diff --git a/pkg/dal/migrations/postgresql/0001_initialize.down.sql b/pkg/dal/migrations/postgresql/0001_initialize.down.sql index be0f1b08..af5d1e0a 100644 --- a/pkg/dal/migrations/postgresql/0001_initialize.down.sql +++ b/pkg/dal/migrations/postgresql/0001_initialize.down.sql @@ -2,8 +2,6 @@ DROP TABLE IF EXISTS "namespaces"; DROP TABLE IF EXISTS "repositories"; -DROP TABLE IF EXISTS "repository_tags"; - DROP TABLE IF EXISTS "artifacts"; DROP TABLE IF EXISTS "tags"; @@ -28,3 +26,15 @@ DROP TABLE IF EXISTS "proxy_tag_tasks"; DROP TABLE IF EXISTS "casbin_rules"; +DROP TABLE IF EXISTS "audits"; + +DROP TABLE IF EXISTS "daemon_logs"; + +DROP TABLE IF EXISTS "webhooks"; + +DROP TABLE IF EXISTS "webhook_logs"; + +DROP TABLE IF EXISTS "builders"; + +DROP TABLE IF EXISTS "builder_logs"; + diff --git a/pkg/dal/migrations/postgresql/0001_initialize.up.sql b/pkg/dal/migrations/postgresql/0001_initialize.up.sql index 64dfa8a4..1db07709 100644 --- a/pkg/dal/migrations/postgresql/0001_initialize.up.sql +++ b/pkg/dal/migrations/postgresql/0001_initialize.up.sql @@ -317,3 +317,20 @@ CREATE TABLE IF NOT EXISTS "webhook_logs" ( FOREIGN KEY ("webhook_id") REFERENCES "webhooks" ("id") ); +CREATE TABLE IF NOT EXISTS "builders" ( + "id" bigserial PRIMARY KEY, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "deleted_at" bigint NOT NULL DEFAULT 0, +); + +CREATE TABLE IF NOT EXISTS "builder_logs" ( + "id" bigserial PRIMARY KEY, + "builder_id" bigint NOT NULL, + "log" bytea, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "deleted_at" bigint NOT NULL DEFAULT 0, + FOREIGN KEY ("builder_id") REFERENCES "builders" ("id") +); + diff --git a/pkg/dal/migrations/sqlite3/0001_initialize.down.sql b/pkg/dal/migrations/sqlite3/0001_initialize.down.sql index ea86f02e..dd036ed3 100644 --- a/pkg/dal/migrations/sqlite3/0001_initialize.down.sql +++ b/pkg/dal/migrations/sqlite3/0001_initialize.down.sql @@ -2,8 +2,6 @@ DROP TABLE IF EXISTS `namespaces`; DROP TABLE IF EXISTS `repositories`; -DROP TABLE IF EXISTS `repository_tags`; - DROP TABLE IF EXISTS `artifacts`; DROP TABLE IF EXISTS `tags`; @@ -28,3 +26,15 @@ DROP TABLE IF EXISTS `proxy_tag_tasks`; DROP TABLE IF EXISTS `casbin_rules`; +DROP TABLE IF EXISTS `audits`; + +DROP TABLE IF EXISTS `daemon_logs`; + +DROP TABLE IF EXISTS `webhooks`; + +DROP TABLE IF EXISTS `webhook_logs`; + +DROP TABLE IF EXISTS `builders`; + +DROP TABLE IF EXISTS `builder_logs`; + diff --git a/pkg/dal/migrations/sqlite3/0001_initialize.up.sql b/pkg/dal/migrations/sqlite3/0001_initialize.up.sql index 4948804a..2261962c 100644 --- a/pkg/dal/migrations/sqlite3/0001_initialize.up.sql +++ b/pkg/dal/migrations/sqlite3/0001_initialize.up.sql @@ -270,3 +270,20 @@ CREATE TABLE IF NOT EXISTS `webhook_logs` ( FOREIGN KEY (`webhook_id`) REFERENCES `webhooks` (`id`) ); +CREATE TABLE IF NOT EXISTS `builders` ( + `id` integer PRIMARY KEY AUTOINCREMENT, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + `deleted_at` bigint NOT NULL DEFAULT 0, +); + +CREATE TABLE IF NOT EXISTS `builder_logs` ( + `id` integer PRIMARY KEY AUTOINCREMENT, + `builder_id` bigint NOT NULL, + `log` BLOB, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + `deleted_at` bigint NOT NULL DEFAULT 0, + FOREIGN KEY (`builder_id`) REFERENCES `builders` (`id`) +); + diff --git a/pkg/types/builder.go b/pkg/types/builder.go new file mode 100644 index 00000000..d90b5e22 --- /dev/null +++ b/pkg/types/builder.go @@ -0,0 +1,42 @@ +// Copyright 2023 sigma +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import "github.com/go-sigma/sigma/pkg/types/enums" + +// Builder config for builder +type Builder struct { + ScmCredentialType enums.ScmCredentialType `env:"SCM_CREDENTIAL_TYPE,notEmpty"` + ScmSshKey string `env:"SCM_SSH_KEY"` + ScmToken string `env:"SCM_TOKEN"` + ScmUsername string `env:"SCM_USERNAME"` + ScmPassword string `env:"SCM_PASSWORD"` + ScmProvider enums.ScmProvider `env:"SCM_PROVIDER,notEmpty"` + ScmRepository string `env:"SCM_REPOSITORY,notEmpty"` + ScmBranch string `env:"SCM_BRANCH" envDefault:"main"` + ScmDepth int `env:"SCM_DEPTH" envDefault:"0"` + ScmSubModule bool `env:"SCM_SUBMODULE" envDefault:"false"` + + OciRegistryDomain string `env:"OCI_REGISTRY_DOMAIN,notEmpty"` + OciRegistryUsername string `env:"OCI_REGISTRY_USERNAME"` + OciRegistryPassword string `env:"OCI_REGISTRY_PASSWORD"` + OciName string `env:"OCI_NAME,notEmpty"` + + BuildkitInsecureRegistries []string `env:"BUILDKIT_INSECURE_REGISTRIES" envSeparator:","` + BuildkitCacheDir string `env:"BUILDKIT_CACHE_DIR" envDefault:"/tmp/buildkit"` + BuildkitContext string `env:"BUILDKIT_CONTEXT" envDefault:"."` + BuildkitDockerfile string `env:"BUILDKIT_DOCKERFILE" envDefault:"Dockerfile"` + BuildkitPlatforms []enums.OciPlatform `env:"BUILDKIT_PLATFORMS" envSeparator:","` +}