-
Notifications
You must be signed in to change notification settings - Fork 38
refactor(CAS proxy): multiple CAS backend providers support #359
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
Changes from all commits
da6f906
b36deb4
1d77bde
95dc8f7
9c97884
2ca507f
15e7560
3a73c68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,34 +17,31 @@ syntax = "proto3"; | |
|
||
package cas.v1; | ||
|
||
option go_package = "github.com/chainloop-dev/chainloop/app/artifact-cas/api/cas/v1;v1"; | ||
|
||
import "google/api/annotations.proto"; | ||
|
||
option go_package = "github.com/chainloop-dev/chainloop/app/artifact-cas/api/cas/v1;v1"; | ||
|
||
service StatusService { | ||
rpc Infoz (InfozRequest) returns (InfozResponse) { | ||
option (google.api.http) = { | ||
get: "/infoz" | ||
}; | ||
} | ||
rpc Statusz (StatuszRequest) returns (StatuszResponse) { | ||
option (google.api.http) = { | ||
get: "/statusz" | ||
}; | ||
} | ||
rpc Infoz(InfozRequest) returns (InfozResponse) { | ||
option (google.api.http) = {get: "/infoz"}; | ||
} | ||
rpc Statusz(StatuszRequest) returns (StatuszResponse) { | ||
option (google.api.http) = {get: "/statusz"}; | ||
} | ||
} | ||
|
||
message InfozRequest { } | ||
message InfozRequest {} | ||
|
||
message InfozResponse { | ||
string version = 1; | ||
string version = 1; | ||
repeated string backends = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is in fact the new part. It exposes the enabled backends. |
||
} | ||
|
||
message StatuszRequest { | ||
// Parameter that can be used by readiness probes | ||
// The main difference is that readiness probes will take into account that all | ||
// dependent services are up and ready | ||
bool readiness = 1; | ||
// Parameter that can be used by readiness probes | ||
// The main difference is that readiness probes will take into account that all | ||
// dependent services are up and ready | ||
bool readiness = 1; | ||
} | ||
|
||
message StatuszResponse {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ import ( | |
|
||
"github.com/chainloop-dev/chainloop/app/artifact-cas/internal/conf" | ||
"github.com/chainloop-dev/chainloop/app/artifact-cas/internal/server" | ||
backend "github.com/chainloop-dev/chainloop/internal/blobmanager" | ||
"github.com/chainloop-dev/chainloop/internal/blobmanager/oci" | ||
"github.com/chainloop-dev/chainloop/internal/credentials" | ||
"github.com/chainloop-dev/chainloop/internal/credentials/manager" | ||
"github.com/chainloop-dev/chainloop/internal/servicelogger" | ||
|
@@ -56,19 +58,36 @@ func init() { | |
flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml") | ||
} | ||
|
||
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server, ms *server.HTTPMetricsServer) *kratos.App { | ||
return kratos.New( | ||
kratos.ID(id), | ||
kratos.Name(Name), | ||
kratos.Version(Version), | ||
kratos.Metadata(map[string]string{}), | ||
kratos.Logger(logger), | ||
kratos.Server( | ||
gs, | ||
hs, | ||
ms, | ||
type app struct { | ||
*kratos.App | ||
backend.Providers | ||
} | ||
|
||
func loadCASBackendProviders(creader credentials.Reader) backend.Providers { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the new dynamic loader |
||
// Currently only OCI is supported | ||
// Here we will load the rest of providers, S3, GCS, etc | ||
p := oci.NewBackendProvider(creader) | ||
return backend.Providers{ | ||
p.ID(): p, | ||
} | ||
} | ||
|
||
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server, ms *server.HTTPMetricsServer, providers backend.Providers) *app { | ||
return &app{ | ||
kratos.New( | ||
kratos.ID(id), | ||
kratos.Name(Name), | ||
kratos.Version(Version), | ||
kratos.Metadata(map[string]string{}), | ||
kratos.Logger(logger), | ||
kratos.Server( | ||
gs, | ||
hs, | ||
ms, | ||
), | ||
), | ||
) | ||
providers, | ||
} | ||
} | ||
|
||
func main() { | ||
|
@@ -115,6 +134,10 @@ func main() { | |
} | ||
defer cleanup() | ||
|
||
for k := range app.Providers { | ||
_ = logger.Log(log.LevelInfo, "msg", "CAS backend provider loaded", "provider", k) | ||
} | ||
|
||
// start and wait for stop signal | ||
if err := app.Run(); err != nil { | ||
panic(err) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason now it complains about some of the sha256 digests that we are using during testing