Skip to content
Open
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: 4 additions & 0 deletions app/cli/cmd/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func wrappedArtifactConn(cpConn *grpc.ClientConn, role pb.CASCredentialsServiceG
grpcconn.WithCLIVersion(fullVersion()),
}

if maxRecv := apiMaxRecvMsgSize(); maxRecv > 0 {
opts = append(opts, grpcconn.WithMaxRecvMsgSize(maxRecv))
}

if caValue := viper.GetString(confOptions.CASCA.viperKey); caValue != "" {
if _, err := os.Stat(caValue); err == nil {
opts = append(opts, grpcconn.WithCAFile(caValue))
Expand Down
8 changes: 6 additions & 2 deletions app/cli/cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 The Chainloop Authors.
// Copyright 2024-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,7 @@ import (

// Map of all the possible configuration options that we expect viper to handle
var confOptions = struct {
authToken, controlplaneAPI, CASAPI, controlplaneCA, CASCA, insecure, organization, platformAPI *confOpt
authToken, controlplaneAPI, CASAPI, controlplaneCA, CASCA, insecure, organization, platformAPI, maxRecvMsgSize *confOpt
}{
insecure: &confOpt{
viperKey: "api-insecure",
Expand Down Expand Up @@ -54,6 +54,10 @@ var confOptions = struct {
viperKey: "organization",
flagName: "org",
},
maxRecvMsgSize: &confOpt{
viperKey: "api-max-recv-msg-size",
flagName: "max-recv-msg-size",
},
}

type confOpt struct {
Expand Down
15 changes: 15 additions & 0 deletions app/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
grpcconn.WithCLIVersion(fullVersion()),
}

if maxRecv := apiMaxRecvMsgSize(); maxRecv > 0 {
opts = append(opts, grpcconn.WithMaxRecvMsgSize(maxRecv))
}

if caValue := viper.GetString(confOptions.controlplaneCA.viperKey); caValue != "" {
// Check if the value is a file path, if it is we read the content and encode it to base64, if not we assume it's the content already
if _, err := os.Stat(caValue); err == nil {
Expand Down Expand Up @@ -265,6 +269,11 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
cobra.CheckErr(viper.BindPFlag(confOptions.insecure.viperKey, rootCmd.PersistentFlags().Lookup("insecure")))
cobra.CheckErr(viper.BindEnv(confOptions.insecure.viperKey, CalculateEnvVarName(confOptions.insecure.viperKey)))

// Override the gRPC client-side max receive message size in bytes (0 = use default)
rootCmd.PersistentFlags().Int(confOptions.maxRecvMsgSize.flagName, 0, fmt.Sprintf("Max size in bytes for incoming gRPC messages (0 = default %d) ($%s)", grpcconn.DefaultMaxRecvMsgSize, CalculateEnvVarName(confOptions.maxRecvMsgSize.viperKey)))
cobra.CheckErr(viper.BindPFlag(confOptions.maxRecvMsgSize.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.maxRecvMsgSize.flagName)))
cobra.CheckErr(viper.BindEnv(confOptions.maxRecvMsgSize.viperKey, CalculateEnvVarName(confOptions.maxRecvMsgSize.viperKey)))

rootCmd.PersistentFlags().BoolVar(&flagDebug, "debug", false, "Enable debug/verbose logging mode")
rootCmd.PersistentFlags().StringVarP(&flagOutputFormat, "output", "o", "table", "Output format, valid options are json and table")

Expand Down Expand Up @@ -499,6 +508,12 @@ func apiInsecure() bool {
return viper.GetBool(confOptions.insecure.viperKey)
}

// apiMaxRecvMsgSize returns the configured gRPC max receive message size for
// the CLI's outbound connections, in bytes. 0 means "use grpcconn's default".
func apiMaxRecvMsgSize() int {
return viper.GetInt(confOptions.maxRecvMsgSize.viperKey)
}

// setLocalOrganization updates the local organization configuration
func setLocalOrganization(orgName string) error {
viper.Set(confOptions.organization.viperKey, orgName)
Expand Down
Loading
Loading