Skip to content

Commit

Permalink
Use workspace state in import command
Browse files Browse the repository at this point in the history
  • Loading branch information
asafyehezkel committed Jan 12, 2025
1 parent 3b8e1c3 commit db835f6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/models/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package models

import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/tensorleap/leap-cli/pkg/auth"
"github.com/tensorleap/leap-cli/pkg/model"
"github.com/tensorleap/leap-cli/pkg/project"
"github.com/tensorleap/leap-cli/pkg/workspace"
)

func NewImportCmd() *cobra.Command {
Expand Down Expand Up @@ -46,6 +48,21 @@ func NewImportCmd() *cobra.Command {
return err
}

workspaceConfig, err := workspace.GetWorkspaceConfig()
if !os.IsNotExist(err) && err != nil {
return err
}

if workspaceConfig != nil {
if len(projectId) == 0 {
projectId = workspaceConfig.ProjectId
}

if len(codeIntegrationId) == 0 {
codeIntegrationId = workspaceConfig.CodeIntegrationId
}
}

if len(projectId) == 0 {
projects, err := project.GetProjects(ctx)
if err != nil {
Expand Down

0 comments on commit db835f6

Please sign in to comment.