Skip to content

Commit

Permalink
Fix UPN parameter passing
Browse files Browse the repository at this point in the history
Signed-off-by: Sajay Antony <[email protected]>
  • Loading branch information
sajayantony committed May 11, 2023
1 parent f90de43 commit 6d2aeeb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/oras.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package obom
import (
"context"
"fmt"
"strings"

v1 "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras-go/v2"
Expand Down Expand Up @@ -75,19 +76,19 @@ func PushFiles(filename string, reference string, spdx_annotations map[string]st

// Check if registry has is localhost or starts with localhost:
reg := repo.Reference.Registry
if reg == "localhost" || reg[:10] == "localhost:" {
if strings.HasPrefix(reg, "localhost:") {
repo.PlainHTTP = true
}

// Note: The below code can be omitted if authentication is not required
// Check if username and passowrd are provided
if username == "" || password == "" {
if len(username) != 0 || len(password) != 0 {
repo.Client = &auth.Client{
Client: retry.DefaultClient,
Cache: auth.DefaultCache,
Credential: auth.StaticCredential(reg, auth.Credential{
Username: "username",
Password: "password",
Username: username,
Password: password,
}),
}
}
Expand Down

0 comments on commit 6d2aeeb

Please sign in to comment.