Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Change cache api #256

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ addlicense: ## Add license to all go files
@find web/src -type f -name "*.css" | xargs addlicense -l apache -y 2023 -c "sigma"

## Kube:
kube_deploy: ## Deploy sigma on k8s using helm
kube_install: ## Install sigma on k8s using helm
@if [ -z $(KUBECONFIG) ]; then \
KUBECONFIG=$$HOME/.kube/config; \
fi;
Expand All @@ -138,7 +138,7 @@ kube_deploy: ## Deploy sigma on k8s using helm
--set minio.secretKey=$(RANDOM_PASSWORD) \
--kubeconfig $(KUBECONFIG)

kube_undeploy: ## Uninstall sigma on k8s using helm
kube_uninstall: ## Uninstall sigma on k8s using helm
@KUBECONFIG=$(KUBECONFIG)
@helm uninstall $(APPNAME) -n$(NAMESPACE)

Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_VERSION=1.21.4-alpine3.18
ARG GOLANG_VERSION=1.21.5-alpine3.18
ARG NODE_VERSION=18-alpine3.18
ARG ALPINE_VERSION=3.18

Expand Down Expand Up @@ -27,7 +27,7 @@ RUN set -eux && \

FROM alpine:${ALPINE_VERSION} as trivy

ARG TRIVY_VERSION=0.47.0
ARG TRIVY_VERSION=0.48.0
ARG ORAS_VERSION=1.0.0
ARG TARGETARCH

Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_VERSION=1.21.4-alpine3.18
ARG GOLANG_VERSION=1.21.5-alpine3.18
ARG BUILDKIT_VERSION=v0.12.4-rootless
ARG ALPINE_VERSION=3.18

Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_VERSION=1.21.4-bookworm
ARG GOLANG_VERSION=1.21.5-bookworm
ARG NODE_VERSION=18-alpine3.18
ARG ALPINE_VERSION=3.18
ARG DEBIAN_VERSION=bookworm-slim
Expand Down Expand Up @@ -27,7 +27,7 @@ RUN set -eux && \

FROM alpine:${ALPINE_VERSION} as trivy

ARG TRIVY_VERSION=0.47.0
ARG TRIVY_VERSION=0.48.0
ARG ORAS_VERSION=1.0.0
ARG TARGETARCH

Expand Down
12 changes: 6 additions & 6 deletions cmd/builder/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func NewAPI(authorization, endpoint string) api {
}

// CreateCache ...
func (a api) CreateCache(ctx context.Context, builderID, runnerID int64, p string) error {
func (a api) CreateCache(ctx context.Context, builderID int64, p string) error {
file, err := os.Open(p)
if err != nil {
return err
}
code, _, err := a.DoRequest(ctx, http.MethodPost, fmt.Sprintf("/api/v1/caches/?builder_id=%d&runner_id=%d", builderID, runnerID), nil, file)
code, _, err := a.DoRequest(ctx, http.MethodPost, fmt.Sprintf("/api/v1/caches/%d", builderID), nil, file)
if err != nil {
return err
}
Expand All @@ -74,8 +74,8 @@ func (a api) CreateCache(ctx context.Context, builderID, runnerID int64, p strin
}

// GetCache ...
func (a api) GetCache(ctx context.Context, builderID, runnerID int64) (io.ReadCloser, error) {
code, reader, err := a.DoRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/caches/?builder_id=%d&runner_id=%d", builderID, runnerID), nil)
func (a api) GetCache(ctx context.Context, builderID int64) (io.ReadCloser, error) {
code, reader, err := a.DoRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/caches/%d", builderID), nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func (a api) DoRequest(ctx context.Context, method, path string, headers http.He
}

func (b Builder) initCache() error {
reader, err := b.api.GetCache(context.Background(), b.BuilderID, b.RunnerID)
reader, err := b.api.GetCache(context.Background(), b.BuilderID)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return err
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func (b Builder) exportCache() error {
if err != nil {
return fmt.Errorf("Read compressed file failed: %v", err)
}
err = b.api.CreateCache(context.Background(), b.BuilderID, b.RunnerID, path.Join(cache, compressedCache))
err = b.api.CreateCache(context.Background(), b.BuilderID, path.Join(cache, compressedCache))
if err != nil {
return fmt.Errorf("Export cache to server failed: %v", err)
}
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/go-sigma/sigma
go 1.21.4

require (
code.gitea.io/sdk/gitea v0.16.0
code.gitea.io/sdk/gitea v0.17.0
github.com/BurntSushi/toml v1.3.2
github.com/IBM/sarama v1.42.1
github.com/Masterminds/sprig/v3 v3.2.3
github.com/alicebob/miniredis/v2 v2.31.0
github.com/aliyun/aliyun-oss-go-sdk v3.0.1+incompatible
github.com/anchore/syft v0.98.0
github.com/aquasecurity/trivy v0.47.0
github.com/aws/aws-sdk-go v1.48.11
github.com/aquasecurity/trivy v0.48.0
github.com/aws/aws-sdk-go v1.48.16
github.com/bytedance/json v0.0.0-20190516032711-0d89175f1949
github.com/caarlos0/env/v9 v9.0.0
github.com/casbin/casbin/v2 v2.79.0
Expand Down Expand Up @@ -55,7 +55,7 @@ require (
github.com/smartystreets/goconvey v1.8.1
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
github.com/spf13/viper v1.18.1
github.com/stretchr/testify v1.8.4
github.com/swaggo/echo-swagger v1.4.1
github.com/swaggo/swag v1.16.2
Expand All @@ -65,14 +65,14 @@ require (
github.com/xanzy/go-gitlab v0.94.0
go.uber.org/mock v0.3.0
golang.org/x/crypto v0.16.0
golang.org/x/exp v0.0.0-20231127185646-65229373498e
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb
golang.org/x/net v0.19.0
golang.org/x/oauth2 v0.15.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.4
gorm.io/driver/sqlite v1.5.4
gorm.io/gen v0.3.23
gorm.io/gen v0.3.24
gorm.io/gorm v1.25.5
gorm.io/plugin/dbresolver v1.5.0
gorm.io/plugin/soft_delete v1.2.1
Expand Down Expand Up @@ -133,15 +133,15 @@ require (
github.com/emirpasic/gods v1.18.1 // indirect
github.com/facebookincubator/nvdtools v0.1.5 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/github/go-spdx/v2 v2.2.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-fed/httpsig v1.1.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand All @@ -158,7 +158,7 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-containerregistry v0.16.1 // indirect
github.com/google/go-containerregistry v0.17.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 // indirect
Expand Down Expand Up @@ -233,7 +233,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/scylladb/go-set v1.0.3-0.20200225121959-cc7b2070d91e // indirect
Expand All @@ -243,7 +243,7 @@ require (
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/smarty/assertions v1.15.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spdx/tools-golang v0.5.3 // indirect
github.com/spdx/tools-golang v0.5.4-0.20231108154018-0c0f394b5e1a // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
Expand Down Expand Up @@ -290,7 +290,7 @@ require (
gorm.io/datatypes v1.2.0 // indirect
gorm.io/driver/sqlserver v1.5.1 // indirect
gorm.io/hints v1.1.2 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20230816210353-14e408962443 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
modernc.org/libc v1.34.9 // indirect
Expand All @@ -299,7 +299,7 @@ require (
modernc.org/sqlite v1.27.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace gorm.io/plugin/soft_delete => github.com/go-sigma/soft_delete v0.0.0-20231124084503-fb6a66078e2b
Loading