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
10 changes: 5 additions & 5 deletions common/cliutils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func TestReadJFrogApplicationKeyFromConfigOrEnv(t *testing.T) {

func TestShouldOfferConfig_AgentSkipsPrompt(t *testing.T) {
tests := []struct {
name string
ciEnv string
agentEnv string // CLAUDE_CODE_CHILD_SESSION to simulate an agent
wantOffer bool
wantErr bool
name string
ciEnv string
agentEnv string // CLAUDE_CODE_CHILD_SESSION to simulate an agent
wantOffer bool
wantErr bool
}{
{
name: "agent env set — no prompt",
Expand Down
22 changes: 11 additions & 11 deletions plugins/components/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ type Namespace struct {
}

type Command struct {
Name string
Description string
AIDescription string
Category string
Aliases []string
UsageOptions *UsageOptions
Arguments []Argument
Flags []Flag
EnvVars []EnvVar
Subcommands []Command
Action ActionFunc
Name string
Description string
AIDescription string
Category string
Aliases []string
UsageOptions *UsageOptions
Arguments []Argument
Flags []Flag
EnvVars []EnvVar
Subcommands []Command
Action ActionFunc
// Must not be set when Subcommands is non-empty; convertCommand rejects that combination.
SkipFlagParsing bool
Hidden bool
Expand Down
45 changes: 41 additions & 4 deletions utils/xray/xrayutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,57 @@ package xray

import (
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"

clientconfig "github.com/jfrog/jfrog-client-go/config"
"github.com/jfrog/jfrog-client-go/xray"
)

func CreateXrayServiceManager(serviceDetails *config.ServerDetails) (*xray.XrayServicesManager, error) {
xrayDetails, err := serviceDetails.CreateXrayAuthConfig()
// Options for creating an Xray service manager.
type XrayManagerOption func(f *xray.XrayServicesManager)

// Global reference to the project key, used for API endpoints that require it for authentication
func WithScopedProjectKey(projectKey string) XrayManagerOption {
return func(f *xray.XrayServicesManager) {
f.SetProjectKey(projectKey)
}
}

func CreateXrayServiceManager(serverDetails *config.ServerDetails, options ...XrayManagerOption) (manager *xray.XrayServicesManager, err error) {
certsPath, err := coreutils.GetJfrogCertsDir()
if err != nil {
return nil, err
return
}
xrayDetails, err := serverDetails.CreateXrayAuthConfig()
if err != nil {
return
}
serviceConfig, err := clientconfig.NewConfigBuilder().
SetServiceDetails(xrayDetails).
SetCertificatesPath(certsPath).
SetInsecureTls(serverDetails.InsecureTls).
Build()
if err != nil {
return
}
manager, err = xray.New(serviceConfig)
if err != nil {
return nil, err
}
return xray.New(serviceConfig)
for _, option := range options {
option(manager)
}
return
}

func CreateXrayServiceManagerAndGetVersion(serviceDetails *config.ServerDetails, options ...XrayManagerOption) (*xray.XrayServicesManager, string, error) {
xrayManager, err := CreateXrayServiceManager(serviceDetails, options...)
if err != nil {
return nil, "", err
}
xrayVersion, err := xrayManager.GetVersion()
if err != nil {
return nil, "", err
}
return xrayManager, xrayVersion, nil
}
Loading