Skip to content

Conversation

@wangxiaoxuan273
Copy link
Contributor

Resolves #662

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>

"github.com/notaryproject/notation-go/log"
"github.com/notaryproject/notation/internal/trace"
executableTrace "github.com/oras-project/oras-credentials-go/trace"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When renaming an imported package, the local name should follow the same guidelines as package names (lower case, no under_scores or mixedCaps). (https://go.dev/blog/package-names)

Suggested change
executableTrace "github.com/oras-project/oras-credentials-go/trace"
executabletrace "github.com/oras-project/oras-credentials-go/trace"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about calling it credentialstrace?

Copy link
Contributor Author

@wangxiaoxuan273 wangxiaoxuan273 Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the package name to credentialstrace.

logger.Info("started executing credential helper program %s with action %s", executableName, action)
},
ExecuteDone: func(executableName, action string, err error) {
logger.Info("finished executing credential helper program %s with action %s and erro %v", executableName, action, err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Info("finished executing credential helper program %s with action %s and erro %v", executableName, action, err)
logger.Info("finished executing credential helper program %s with action %s and error %w", executableName, action, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed accordingly.

logger := log.GetLogger(ctx)
ctx = executableTrace.WithExecutableTrace(ctx, &executableTrace.ExecutableTrace{
ExecuteStart: func(executableName, action string) {
logger.Info("started executing credential helper program %s with action %s", executableName, action)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be Info level or debug level? The process for accessing credential information is too detailed for a Notation user, and it is not the main logic of Notation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to debug level.

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2023

Codecov Report

Merging #744 (0e8c8d2) into main (354e74f) will increase coverage by 0.32%.
The diff coverage is 90.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #744      +/-   ##
==========================================
+ Coverage   63.66%   63.98%   +0.32%     
==========================================
  Files          40       40              
  Lines        2232     2252      +20     
==========================================
+ Hits         1421     1441      +20     
+ Misses        690      689       -1     
- Partials      121      122       +1     
Impacted Files Coverage Δ
cmd/notation/cert/show.go 31.66% <0.00%> (ø)
cmd/notation/inspect.go 68.63% <ø> (ø)
cmd/notation/list.go 72.82% <ø> (ø)
cmd/notation/login.go 25.89% <ø> (ø)
cmd/notation/key.go 58.33% <66.66%> (ø)
cmd/notation/cert/list.go 52.43% <100.00%> (ø)
cmd/notation/logout.go 50.00% <100.00%> (ø)
cmd/notation/sign.go 79.38% <100.00%> (ø)
cmd/notation/verify.go 85.71% <100.00%> (ø)
internal/cmd/options.go 73.52% <100.00%> (-26.48%) ⬇️

... and 28 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


"github.com/notaryproject/notation-go/log"
"github.com/notaryproject/notation/internal/trace"
executabletrace "github.com/oras-project/oras-credentials-go/trace"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name executabletrace looks like it traces any kind of executables, while it just traces executables for credentials usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the package name to credentialstrace.

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
go.sum Outdated
Comment on lines 26 to 27
github.com/oras-project/oras-credentials-go v0.2.1-0.20230714083315-2afb422fe225 h1:0T0CYijlSdn0ariTr48cRn6YDl445VZf3yqCqJKksqo=
github.com/oras-project/oras-credentials-go v0.2.1-0.20230714083315-2afb422fe225/go.mod h1:fFCebDQo0Do+gnM96uV9YUnRay0pwuRQupypvofsp4s=
Copy link
Contributor

@Wwwsylvia Wwwsylvia Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran go mod tidy.

}

// SetLoggerLevel sets up the logger based on common options.
func (opts *LoggingFlagOpts) SetLoggerLevel(ctx context.Context) context.Context {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question: Do we need to rename this function given that it now does more than setting logger level? 🤔 @JeyJeyGao

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the function to InitializaLogger.

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
ghost
ghost previously approved these changes Jul 20, 2023
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

JeyJeyGao
JeyJeyGao previously approved these changes Jul 20, 2023
Copy link
Contributor

@JeyJeyGao JeyJeyGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm not a maintainer.

shizhMSFT
shizhMSFT previously approved these changes Jul 20, 2023
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

priteshbandi
priteshbandi previously approved these changes Jul 21, 2023
Copy link
Contributor

@priteshbandi priteshbandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if err != nil {
logger.Errorf("finished executing credential helper program %s with action %s and got error %w", executableName, action, err)
} else {
logger.Debugf("finished executing credential helper program %s with action %s", executableName, action)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debugf("finished executing credential helper program %s with action %s", executableName, action)
logger.Debugf("successfully finished executing credential helper program %s with action %s", executableName, action)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed accordingly

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@wangxiaoxuan273 wangxiaoxuan273 dismissed stale reviews from priteshbandi, shizhMSFT, JeyJeyGao, and ghost via 0e8c8d2 July 21, 2023 06:14
Copy link
Contributor

@priteshbandi priteshbandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shizhMSFT shizhMSFT merged commit 161c972 into notaryproject:main Jul 21, 2023
@shizhMSFT shizhMSFT mentioned this pull request Jul 31, 2023
6 tasks
7h3-3mp7y-m4n pushed a commit to 7h3-3mp7y-m4n/notation that referenced this pull request Mar 29, 2025
Resolves notaryproject#662

---------

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
FeynmanZhou pushed a commit to FeynmanZhou/notation that referenced this pull request May 15, 2025
Resolves notaryproject#662

---------

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trace the execution of executables

6 participants