Skip to content
Closed
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
2 changes: 1 addition & 1 deletion app/cli/cmd/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func wrappedArtifactConn(cpConn *grpc.ClientConn, role pb.CASCredentialsServiceG
}

if apiInsecure() {
logger.Warn().Msg("API contacted in insecure mode")
Logger.Warn().Msg("API contacted in insecure mode")
}

var opts = []grpcconn.Option{
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/attached_integration_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func newAttachedIntegrationDeleteCmd() *cobra.Command {
return err
}

logger.Info().Msg("integration detached!")
Logger.Info().Msg("integration detached!")
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/attestation_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func newAttestationAddCmd() *cobra.Command {
return err
}

logger.Info().Msg("material added to attestation")
Logger.Info().Msg("material added to attestation")

policies, err := a.GetPolicyEvaluations(cmd.Context(), attestationID)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions app/cli/cmd/attestation_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func newAttestationInitCmd() *cobra.Command {
cfg, path, err := loadDotChainloopConfigWithParentTraversal()
// we do gracefully load, if not found, or any other error we continue
if err != nil {
logger.Debug().Msgf("failed to load chainloop config: %s", err)
Logger.Debug().Msgf("failed to load chainloop config: %s", err)
return nil
}

logger.Debug().Msgf("loaded version %s from config file %s", cfg.ProjectVersion, path)
Logger.Debug().Msgf("loaded version %s from config file %s", cfg.ProjectVersion, path)

projectVersion = cfg.ProjectVersion
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func newAttestationInitCmd() *cobra.Command {
return newGracefulError(err)
}

logger.Info().Msg("Attestation initialized! now you can check its status or add materials to it")
Logger.Info().Msg("Attestation initialized! now you can check its status or add materials to it")

// Show the status information
statusAction, err := action.NewAttestationStatus(&action.AttestationStatusOpts{ActionsOpts: ActionOpts, UseAttestationRemoteState: useAttestationRemoteState, LocalStatePath: attestationLocalStatePath})
Expand All @@ -123,11 +123,11 @@ func newAttestationInitCmd() *cobra.Command {
}

if res.DryRun {
logger.Info().Msg("The attestation is being crafted in dry-run mode. It will not get stored once rendered")
Logger.Info().Msg("The attestation is being crafted in dry-run mode. It will not get stored once rendered")
}

if projectName == "" {
logger.Warn().Msg("DEPRECATION WARNING: --project not set, this will be required in the near future")
Logger.Warn().Msg("DEPRECATION WARNING: --project not set, this will be required in the near future")
}

return output.EncodeOutput(flagOutputFormat, res, fullStatusTable)
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/attestation_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func newAttestationPushCmd() *cobra.Command {
// and fail the command if needed
if res.Status.MustBlockOnPolicyViolations {
if bypassPolicyCheck {
logger.Warn().Msg(exceptionBypassPolicyCheck)
Logger.Warn().Msg(exceptionBypassPolicyCheck)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/attestation_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func newAttestationResetCmd() *cobra.Command {
msg = "Attestation marked as failed"
}

logger.Info().Msg(msg)
Logger.Info().Msg(msg)

return nil
},
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/auth_delete_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func newAuthDeleteAccountCmd() *cobra.Command {
return err
}

logger.Info().Msg("Account deleted :(")
Logger.Info().Msg("Account deleted :(")
return nil
},
}
Expand Down
8 changes: 4 additions & 4 deletions app/cli/cmd/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func interactiveAuth(forceHeadless bool) error {

err = openbrowser(serverLoginURL.String())
if err != nil {
logger.Debug().Err(err).Msg("falling back to manual login")
Logger.Debug().Err(err).Msg("falling back to manual login")
return headlessAuth(serverLoginURL)
}

Expand All @@ -90,7 +90,7 @@ func interactiveAuth(forceHeadless bool) error {
// Run server in background
http.HandleFunc(callbackURL.Path, a.handleCallback)
go func() {
logger.Info().Msg("waiting for the authentication to be completed, please check your browser")
Logger.Info().Msg("waiting for the authentication to be completed, please check your browser")

server := &http.Server{ReadHeaderTimeout: time.Second}

Expand Down Expand Up @@ -132,7 +132,7 @@ func headlessAuth(loginURL *url.URL) error {
}

fmt.Println("")
logger.Info().Msg("login successful!")
Logger.Info().Msg("login successful!")

return nil
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func (a *app) handleCallback(w http.ResponseWriter, r *http.Request) {
return
}

logger.Info().Msg("login successful!")
Logger.Info().Msg("login successful!")
fmt.Fprintln(w, "login successful, you can now close this window and go back to the terminal")
}

Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/casbackend_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newCASBackendDeleteCmd() *cobra.Command {
return err
}

logger.Info().Msg("Backend deleted")
Logger.Info().Msg("Backend deleted")

return nil
},
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var (
// It supports both .yaml and .yml extensions
func loadDotChainloopConfigWithParentTraversal() (*DotChainloopConfig, string, error) {
searchPaths := getConfigSearchPaths()
logger.Debug().Msgf("searching %s.[yaml|yml] file in %q", dotChainloopConfigFilename, searchPaths)
Logger.Debug().Msgf("searching %s.[yaml|yml] file in %q", dotChainloopConfigFilename, searchPaths)

for _, currentDir := range searchPaths {
for _, ext := range []string{".yaml", ".yml"} {
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/config_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newConfigResetCmd() *cobra.Command {
configFile := viper.ConfigFileUsed()
err := os.Remove(configFile)
cobra.CheckErr(err)
logger.Info().Str("file", configFile).Msg("Config file removed")
Logger.Info().Str("file", configFile).Msg("Config file removed")
},
}

Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ func runWithBackoffRetry(fn func() error) error {
},
backoff.NewExponentialBackOff(backoff.WithMaxElapsedTime(3*time.Minute)),
func(err error, delay time.Duration) {
logger.Err(err).Msgf("retrying in %s", delay)
Logger.Err(err).Msgf("retrying in %s", delay)
})
}
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_apitoken_revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newAPITokenRevokeCmd() *cobra.Command {
return fmt.Errorf("revoking API token: %w", err)
}

logger.Info().Msg("API token revoked!")
Logger.Info().Msg("API token revoked!")
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newOrganizationCreateCmd() *cobra.Command {
return fmt.Errorf("writing config file: %w", err)
}

logger.Info().Msgf("Organization %q created!", org.Name)
Logger.Info().Msgf("Organization %q created!", org.Name)
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newOrganizationDeleteCmd() *cobra.Command {
return fmt.Errorf("writing config file: %w", err)
}

logger.Info().Str("organization", orgName).Msg("Organization deleted")
Logger.Info().Str("organization", orgName).Msg("Organization deleted")
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_invitation_revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func newOrganizationInvitationRevokeCmd() *cobra.Command {
return err
}

logger.Info().Msg("Invitation Revoked!")
Logger.Info().Msg("Invitation Revoked!")
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_leave.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func newOrganizationLeaveCmd() *cobra.Command {
return fmt.Errorf("writing config file: %w", err)
}

logger.Info().Msg("Membership deleted")
Logger.Info().Msg("Membership deleted")
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_member_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newOrganizationMemberDeleteCmd() *cobra.Command {
return err
}

logger.Info().Msg("Member deleted")
Logger.Info().Msg("Member deleted")
return nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions app/cli/cmd/organization_member_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func newOrganizationMemberList() *cobra.Command {
if pgResponse.TotalPages >= paginationOpts.Page {
inPage := min(paginationOpts.Limit, len(res.Memberships))
lowerBound := (paginationOpts.Page - 1) * paginationOpts.Limit
logger.Info().Msg(fmt.Sprintf("Showing [%d-%d] out of %d", lowerBound+1, lowerBound+inPage, pgResponse.TotalCount))
Logger.Info().Msg(fmt.Sprintf("Showing [%d-%d] out of %d", lowerBound+1, lowerBound+inPage, pgResponse.TotalCount))
}

if pgResponse.TotalCount > pgResponse.Page*pgResponse.PageSize {
logger.Info().Msg(fmt.Sprintf("Next page available: %d", pgResponse.Page+1))
Logger.Info().Msg(fmt.Sprintf("Next page available: %d", pgResponse.Page+1))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func newOrganizationSet() *cobra.Command {
}
}

logger.Info().Msg("Organization switched!")
Logger.Info().Msg("Organization switched!")
return output.EncodeOutput(flagOutputFormat, []*action.MembershipItem{membership}, orgMembershipTableOutput)
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/organization_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newOrganizationUpdateCmd() *cobra.Command {
return err
}

logger.Info().Msg("Organization updated!")
Logger.Info().Msg("Organization updated!")
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/policy_develop_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ By default, it creates chainloop-policy.yaml and chainloop-policy.rego files.`,
return newGracefulError(err)
}

logger.Info().Msg("Initialized policy files")
Logger.Info().Msg("Initialized policy files")

return nil
},
Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/policy_develop_lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func newPolicyDevelopLintCmd() *cobra.Command {
}

if result.Valid {
logger.Info().Msg("policy is valid!")
Logger.Info().Msg("policy is valid!")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/registered_integration_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newRegisteredIntegrationDeleteCmd() *cobra.Command {
return err
}

logger.Info().Msg("Integration deregistered!")
Logger.Info().Msg("Integration deregistered!")
return nil
},
}
Expand Down
30 changes: 15 additions & 15 deletions app/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ import (
)

var (
Logger zerolog.Logger
flagCfgFile string
flagDebug bool
flagOutputFormat string
ActionOpts *action.ActionsOpts
logger zerolog.Logger
defaultCPAPI = "api.cp.chainloop.dev:443"
defaultCASAPI = "api.cas.chainloop.dev:443"
apiToken string
Expand Down Expand Up @@ -76,7 +76,7 @@ func Execute(rootCmd *cobra.Command) error {
// The local file is pointing to the wrong organization, we remove it
if v1.IsUserNotMemberOfOrgErrorNotInOrg(err) {
if err := setLocalOrganization(""); err != nil {
logger.Debug().Err(err).Msg("failed to remove organization from config")
Logger.Debug().Err(err).Msg("failed to remove organization from config")
}
}

Expand All @@ -94,15 +94,15 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
var err error
logger, err = initLogger(l)
Logger, err = initLogger(l)
if err != nil {
return err
}

logger.Debug().Str("path", viper.ConfigFileUsed()).Msg("using config file")
Logger.Debug().Str("path", viper.ConfigFileUsed()).Msg("using config file")

if apiInsecure() {
logger.Warn().Msg("API contacted in insecure mode")
Logger.Warn().Msg("API contacted in insecure mode")
}

authToken, isUserToken, err := loadAuthToken(cmd)
Expand All @@ -128,7 +128,7 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
return err
}

currentContext, err := action.NewConfigCurrentContext(newActionOpts(logger, conn, authToken)).Run()
currentContext, err := action.NewConfigCurrentContext(newActionOpts(Logger, conn, authToken)).Run()
if err == nil && currentContext.CurrentMembership != nil {
if err := setLocalOrganization(currentContext.CurrentMembership.Org.Name); err != nil {
return fmt.Errorf("writing config file: %w", err)
Expand All @@ -154,10 +154,10 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
return err
}

ActionOpts = newActionOpts(logger, conn, authToken)
ActionOpts = newActionOpts(Logger, conn, authToken)

if !isTelemetryDisabled() {
logger.Debug().Msg("Telemetry enabled, to disable it use DO_NOT_TRACK=1")
Logger.Debug().Msg("Telemetry enabled, to disable it use DO_NOT_TRACK=1")

telemetryWg.Add(1)
go func() {
Expand All @@ -174,13 +174,13 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
// Once we have the token type we can send it to the telemetry service by injecting it on the context
authToken, err := token.Parse(authToken)
if err != nil {
logger.Debug().Err(err).Msg("parsing token for telemetry")
Logger.Debug().Err(err).Msg("parsing token for telemetry")
return
}

err = recordCommand(cmd, authToken)
if err != nil {
logger.Debug().Err(err).Msg("sending command to telemetry")
Logger.Debug().Err(err).Msg("sending command to telemetry")
}
close(done)
}()
Expand Down Expand Up @@ -247,9 +247,9 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {

// Load plugins for root command and subcommands (except completion and help)
if len(os.Args) == 1 || (len(os.Args) > 1 && os.Args[1] != "completion" && os.Args[1] != "help") {
pluginManager = plugins.NewManager(&logger)
pluginManager = plugins.NewManager(&Logger)
if err := loadAllPlugins(rootCmd); err != nil {
logger.Error().Err(err).Msg("Failed to load plugins, continuing with built-in commands only")
Logger.Error().Err(err).Msg("Failed to load plugins, continuing with built-in commands only")
}
}

Expand Down Expand Up @@ -372,13 +372,13 @@ func loadAuthToken(cmd *cobra.Command) (string, bool, error) {

// Now we check explicitly provided API token via the flag
if apiToken != "" {
logger.Info().Msg("API token provided to the command line")
Logger.Info().Msg("API token provided to the command line")
return apiToken, false, nil
}

// If both the user authentication and the API token en var are set, we default to user authentication
if userToken != "" && apiTokenFromVar != "" {
logger.Warn().Msgf("Both user credentials and $%s set. Ignoring $%s.", tokenEnvVarName, tokenEnvVarName)
Logger.Warn().Msgf("Both user credentials and $%s set. Ignoring $%s.", tokenEnvVarName, tokenEnvVarName)
return userToken, true, nil
} else if apiTokenFromVar != "" {
return apiTokenFromVar, false, nil
Expand All @@ -400,7 +400,7 @@ var (
func recordCommand(executedCmd *cobra.Command, authInfo *token.ParsedToken) error {
telemetryClient, err := posthog.NewClient(posthogAPIKey, posthogEndpoint)
if err != nil {
logger.Debug().Err(err).Msgf("creating telemetry client: %v", err)
Logger.Debug().Err(err).Msgf("creating telemetry client: %v", err)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion app/cli/cmd/workflow_contract_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ or update it if it already exists.`,
return err
}

logger.Info().Msg("Contract applied!")
Logger.Info().Msg("Contract applied!")
return output.EncodeOutput(flagOutputFormat, res, contractItemTableOutput)
},
}
Expand Down
Loading
Loading