Adopt in create.go
This commit is contained in:
parent
43783a33a2
commit
d815d54bd2
1 changed files with 25 additions and 16 deletions
|
|
@ -141,17 +141,20 @@ func (a *App) Create(ctx context.Context, opts createOptions) error {
|
||||||
userInputs.Location = vscsLocation
|
userInputs.Location = vscsLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
a.StartProgressIndicatorWithLabel("Fetching repository")
|
var repository *api.Repository
|
||||||
repository, err := a.apiClient.GetRepository(ctx, userInputs.Repository)
|
err := a.RunWithProgress("Fetching repository", func() (err error) {
|
||||||
a.StopProgressIndicator()
|
repository, err = a.apiClient.GetRepository(ctx, userInputs.Repository)
|
||||||
|
return
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error getting repository: %w", err)
|
return fmt.Errorf("error getting repository: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.StartProgressIndicatorWithLabel("Validating repository for codespaces")
|
var billableOwner *api.User
|
||||||
billableOwner, err := a.apiClient.GetCodespaceBillableOwner(ctx, userInputs.Repository)
|
err = a.RunWithProgress("Validating repository for codespaces", func() (err error) {
|
||||||
a.StopProgressIndicator()
|
billableOwner, err = a.apiClient.GetCodespaceBillableOwner(ctx, userInputs.Repository)
|
||||||
|
return
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error checking codespace ownership: %w", err)
|
return fmt.Errorf("error checking codespace ownership: %w", err)
|
||||||
} else if billableOwner != nil && billableOwner.Type == "Organization" {
|
} else if billableOwner != nil && billableOwner.Type == "Organization" {
|
||||||
|
|
@ -188,9 +191,11 @@ func (a *App) Create(ctx context.Context, opts createOptions) error {
|
||||||
|
|
||||||
// now that we have repo+branch, we can list available devcontainer.json files (if any)
|
// now that we have repo+branch, we can list available devcontainer.json files (if any)
|
||||||
if opts.devContainerPath == "" {
|
if opts.devContainerPath == "" {
|
||||||
a.StartProgressIndicatorWithLabel("Fetching devcontainer.json files")
|
var devcontainers []api.DevContainerEntry
|
||||||
devcontainers, err := a.apiClient.ListDevContainers(ctx, repository.ID, branch, 100)
|
err = a.RunWithProgress("Fetching devcontainer.json files", func() (err error) {
|
||||||
a.StopProgressIndicator()
|
devcontainers, err = a.apiClient.ListDevContainers(ctx, repository.ID, branch, 100)
|
||||||
|
return
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error getting devcontainer.json paths: %w", err)
|
return fmt.Errorf("error getting devcontainer.json paths: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -253,9 +258,11 @@ func (a *App) Create(ctx context.Context, opts createOptions) error {
|
||||||
DisplayName: opts.displayName,
|
DisplayName: opts.displayName,
|
||||||
}
|
}
|
||||||
|
|
||||||
a.StartProgressIndicatorWithLabel("Creating codespace")
|
var codespace *api.Codespace
|
||||||
codespace, err := a.apiClient.CreateCodespace(ctx, createParams)
|
err = a.RunWithProgress("Creating codespace", func() (err error) {
|
||||||
a.StopProgressIndicator()
|
codespace, err = a.apiClient.CreateCodespace(ctx, createParams)
|
||||||
|
return
|
||||||
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var aerr api.AcceptPermissionsRequiredError
|
var aerr api.AcceptPermissionsRequiredError
|
||||||
|
|
@ -342,9 +349,11 @@ func (a *App) handleAdditionalPermissions(ctx context.Context, createParams *api
|
||||||
// we can continue with the create opting out of the additional permissions
|
// we can continue with the create opting out of the additional permissions
|
||||||
createParams.PermissionsOptOut = true
|
createParams.PermissionsOptOut = true
|
||||||
|
|
||||||
a.StartProgressIndicatorWithLabel("Creating codespace")
|
var codespace *api.Codespace
|
||||||
codespace, err := a.apiClient.CreateCodespace(ctx, createParams)
|
err := a.RunWithProgress("Creating codespace", func() (err error) {
|
||||||
a.StopProgressIndicator()
|
codespace, err = a.apiClient.CreateCodespace(ctx, createParams)
|
||||||
|
return
|
||||||
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error creating codespace: %w", err)
|
return nil, fmt.Errorf("error creating codespace: %w", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue