linting: address slice-append issues found by gocritic

cli/command/trust/inspect.go:74:33: appendAssign: append result not assigned to the same slice (gocritic)
    			signatureRows[idx].Signers = append(sig.Signers, releasedRoleName)
    			                             ^
    cli/command/task/print.go:92:7: appendAssign: append result not assigned to the same slice (gocritic)
    	t := append(tasks[:0:0], tasks...)
    	     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-11-20 14:26:41 +01:00
parent a2c9f3c6ce
commit 3f0c189e48
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 3 additions and 2 deletions

View File

@ -89,7 +89,8 @@ func Print(ctx context.Context, dockerCli command.Cli, tasks []swarm.Task, resol
// Task-names are not unique in cases where "tasks" contains previous/rotated tasks. // Task-names are not unique in cases where "tasks" contains previous/rotated tasks.
func generateTaskNames(ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver) ([]swarm.Task, error) { func generateTaskNames(ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver) ([]swarm.Task, error) {
// Use a copy of the tasks list, to not modify the original slice // Use a copy of the tasks list, to not modify the original slice
t := append(tasks[:0:0], tasks...) // see https://github.com/go101/go101/wiki/How-to-efficiently-clone-a-slice%3F
t := append(tasks[:0:0], tasks...) //nolint:gocritic // ignore appendAssign: append result not assigned to the same slice
for i, task := range t { for i, task := range t {
serviceName, err := resolver.Resolve(ctx, swarm.Service{}, task.ServiceID) serviceName, err := resolver.Resolve(ctx, swarm.Service{}, task.ServiceID)

View File

@ -71,7 +71,7 @@ func getRepoTrustInfo(cli command.Cli, remote string) ([]byte, error) {
// process the signatures to include repo admin if signed by the base targets role // process the signatures to include repo admin if signed by the base targets role
for idx, sig := range signatureRows { for idx, sig := range signatureRows {
if len(sig.Signers) == 0 { if len(sig.Signers) == 0 {
signatureRows[idx].Signers = append(sig.Signers, releasedRoleName) signatureRows[idx].Signers = []string{releasedRoleName}
} }
} }