mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
@ -2,7 +2,6 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -16,10 +15,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cloud.google.com/go/compute/metadata"
|
"cloud.google.com/go/compute/metadata"
|
||||||
"github.com/coder/retry"
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/natefinch/lumberjack.v2"
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
|
||||||
|
"github.com/coder/retry"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"cdr.dev/slog"
|
"cdr.dev/slog"
|
||||||
@ -66,8 +66,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
Handler: func(inv *serpent.Invocation) error {
|
Handler: func(inv *serpent.Invocation) error {
|
||||||
ctx, cancel := context.WithCancelCause(inv.Context())
|
ctx, cancel := context.WithCancelCause(inv.Context())
|
||||||
defer func() {
|
defer func() {
|
||||||
fmt.Printf(">>>>>CANCELING CONTEXT")
|
cancel(xerrors.New("defer"))
|
||||||
cancel(errors.New("defer"))
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -1070,7 +1070,7 @@ func (api *API) workspaceAgentReinit(rw http.ResponseWriter, r *http.Request) {
|
|||||||
workspace, err := api.Database.GetWorkspaceByAgentID(ctx, workspaceAgent.ID)
|
workspace, err := api.Database.GetWorkspaceByAgentID(ctx, workspaceAgent.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "failed to retrieve workspace from agent token", slog.Error(err))
|
log.Error(ctx, "failed to retrieve workspace from agent token", slog.Error(err))
|
||||||
httpapi.InternalServerError(rw, errors.New("failed to determine workspace from agent token"))
|
httpapi.InternalServerError(rw, xerrors.New("failed to determine workspace from agent token"))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info(ctx, "agent waiting for reinit instruction")
|
log.Info(ctx, "agent waiting for reinit instruction")
|
||||||
@ -1094,7 +1094,7 @@ func (api *API) workspaceAgentReinit(rw http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "failed to subscribe to prebuild claimed channel", slog.Error(err))
|
log.Error(ctx, "failed to subscribe to prebuild claimed channel", slog.Error(err))
|
||||||
httpapi.InternalServerError(rw, errors.New("failed to subscribe to prebuild claimed channel"))
|
httpapi.InternalServerError(rw, xerrors.New("failed to subscribe to prebuild claimed channel"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cancelSub()
|
defer cancelSub()
|
||||||
|
@ -15,6 +15,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/coder/terraform-provider-coder/provider"
|
||||||
|
|
||||||
"github.com/hashicorp/go-version"
|
"github.com/hashicorp/go-version"
|
||||||
tfjson "github.com/hashicorp/terraform-json"
|
tfjson "github.com/hashicorp/terraform-json"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
import {action} from "@storybook/addon-actions";
|
import { action } from "@storybook/addon-actions";
|
||||||
import type {Meta, StoryObj} from "@storybook/react";
|
import type { Meta, StoryObj } from "@storybook/react";
|
||||||
import {within } from "@testing-library/react";
|
import { within } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import {chromatic} from "testHelpers/chromatic";
|
import { chromatic } from "testHelpers/chromatic";
|
||||||
import {
|
import {
|
||||||
mockApiError,
|
MockTemplate,
|
||||||
MockTemplate,
|
MockTemplateVersionParameter1,
|
||||||
MockTemplateVersionParameter1,
|
MockTemplateVersionParameter2,
|
||||||
MockTemplateVersionParameter2,
|
MockTemplateVersionParameter3,
|
||||||
MockTemplateVersionParameter3,
|
MockUser,
|
||||||
MockUser,
|
mockApiError,
|
||||||
} from "testHelpers/entities";
|
} from "testHelpers/entities";
|
||||||
import {CreateWorkspacePageView} from "./CreateWorkspacePageView";
|
import { CreateWorkspacePageView } from "./CreateWorkspacePageView";
|
||||||
|
|
||||||
const meta: Meta<typeof CreateWorkspacePageView> = {
|
const meta: Meta<typeof CreateWorkspacePageView> = {
|
||||||
title: "pages/CreateWorkspacePage",
|
title: "pages/CreateWorkspacePage",
|
||||||
parameters: {chromatic},
|
parameters: { chromatic },
|
||||||
component: CreateWorkspacePageView,
|
component: CreateWorkspacePageView,
|
||||||
args: {
|
args: {
|
||||||
defaultName: "",
|
defaultName: "",
|
||||||
defaultOwner: MockUser,
|
defaultOwner: MockUser,
|
||||||
autofillParameters: [],
|
autofillParameters: [],
|
||||||
template: MockTemplate,
|
template: MockTemplate,
|
||||||
parameters: [],
|
parameters: [],
|
||||||
externalAuth: [],
|
externalAuth: [],
|
||||||
hasAllRequiredExternalAuth: true,
|
hasAllRequiredExternalAuth: true,
|
||||||
mode: "form",
|
mode: "form",
|
||||||
permissions: {
|
permissions: {
|
||||||
createWorkspaceForUser: true,
|
createWorkspaceForUser: true,
|
||||||
},
|
},
|
||||||
onCancel: action("onCancel"),
|
onCancel: action("onCancel"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
@ -39,115 +39,115 @@ type Story = StoryObj<typeof CreateWorkspacePageView>;
|
|||||||
export const NoParameters: Story = {};
|
export const NoParameters: Story = {};
|
||||||
|
|
||||||
export const CreateWorkspaceError: Story = {
|
export const CreateWorkspaceError: Story = {
|
||||||
args: {
|
args: {
|
||||||
error: mockApiError({
|
error: mockApiError({
|
||||||
message:
|
message:
|
||||||
'Workspace "test" already exists in the "docker-amd64" template.',
|
'Workspace "test" already exists in the "docker-amd64" template.',
|
||||||
validations: [
|
validations: [
|
||||||
{
|
{
|
||||||
field: "name",
|
field: "name",
|
||||||
detail: "This value is already in use and should be unique.",
|
detail: "This value is already in use and should be unique.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SpecificVersion: Story = {
|
export const SpecificVersion: Story = {
|
||||||
args: {
|
args: {
|
||||||
versionId: "specific-version",
|
versionId: "specific-version",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Duplicate: Story = {
|
export const Duplicate: Story = {
|
||||||
args: {
|
args: {
|
||||||
mode: "duplicate",
|
mode: "duplicate",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Parameters: Story = {
|
export const Parameters: Story = {
|
||||||
args: {
|
args: {
|
||||||
parameters: [
|
parameters: [
|
||||||
MockTemplateVersionParameter1,
|
MockTemplateVersionParameter1,
|
||||||
MockTemplateVersionParameter2,
|
MockTemplateVersionParameter2,
|
||||||
MockTemplateVersionParameter3,
|
MockTemplateVersionParameter3,
|
||||||
{
|
{
|
||||||
name: "Region",
|
name: "Region",
|
||||||
required: false,
|
required: false,
|
||||||
description: "",
|
description: "",
|
||||||
description_plaintext: "",
|
description_plaintext: "",
|
||||||
type: "string",
|
type: "string",
|
||||||
mutable: false,
|
mutable: false,
|
||||||
default_value: "",
|
default_value: "",
|
||||||
icon: "/emojis/1f30e.png",
|
icon: "/emojis/1f30e.png",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: "Pittsburgh",
|
name: "Pittsburgh",
|
||||||
description: "",
|
description: "",
|
||||||
value: "us-pittsburgh",
|
value: "us-pittsburgh",
|
||||||
icon: "/emojis/1f1fa-1f1f8.png",
|
icon: "/emojis/1f1fa-1f1f8.png",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Helsinki",
|
name: "Helsinki",
|
||||||
description: "",
|
description: "",
|
||||||
value: "eu-helsinki",
|
value: "eu-helsinki",
|
||||||
icon: "/emojis/1f1eb-1f1ee.png",
|
icon: "/emojis/1f1eb-1f1ee.png",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Sydney",
|
name: "Sydney",
|
||||||
description: "",
|
description: "",
|
||||||
value: "ap-sydney",
|
value: "ap-sydney",
|
||||||
icon: "/emojis/1f1e6-1f1fa.png",
|
icon: "/emojis/1f1e6-1f1fa.png",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
ephemeral: false,
|
ephemeral: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
autofillParameters: [
|
autofillParameters: [
|
||||||
{
|
{
|
||||||
name: "first_parameter",
|
name: "first_parameter",
|
||||||
value: "Cool suggestion",
|
value: "Cool suggestion",
|
||||||
source: "user_history",
|
source: "user_history",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "third_parameter",
|
name: "third_parameter",
|
||||||
value: "aaaa",
|
value: "aaaa",
|
||||||
source: "url",
|
source: "url",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PresetsButNoneSelected: Story = {
|
export const PresetsButNoneSelected: Story = {
|
||||||
args: {
|
args: {
|
||||||
presets: [
|
presets: [
|
||||||
{
|
{
|
||||||
ID: "preset-1",
|
ID: "preset-1",
|
||||||
Name: "Preset 1",
|
Name: "Preset 1",
|
||||||
Parameters: [
|
Parameters: [
|
||||||
{
|
{
|
||||||
Name: MockTemplateVersionParameter1.name,
|
Name: MockTemplateVersionParameter1.name,
|
||||||
Value: "preset 1 override",
|
Value: "preset 1 override",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "preset-2",
|
ID: "preset-2",
|
||||||
Name: "Preset 2",
|
Name: "Preset 2",
|
||||||
Parameters: [
|
Parameters: [
|
||||||
{
|
{
|
||||||
Name: MockTemplateVersionParameter2.name,
|
Name: MockTemplateVersionParameter2.name,
|
||||||
Value: "42",
|
Value: "42",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
parameters: [
|
parameters: [
|
||||||
MockTemplateVersionParameter1,
|
MockTemplateVersionParameter1,
|
||||||
MockTemplateVersionParameter2,
|
MockTemplateVersionParameter2,
|
||||||
MockTemplateVersionParameter3,
|
MockTemplateVersionParameter3,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PresetSelected: Story = {
|
export const PresetSelected: Story = {
|
||||||
@ -160,100 +160,100 @@ export const PresetSelected: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ExternalAuth: Story = {
|
export const ExternalAuth: Story = {
|
||||||
args: {
|
args: {
|
||||||
externalAuth: [
|
externalAuth: [
|
||||||
{
|
{
|
||||||
id: "github",
|
id: "github",
|
||||||
type: "github",
|
type: "github",
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/github.svg",
|
display_icon: "/icon/github.svg",
|
||||||
display_name: "GitHub",
|
display_name: "GitHub",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "gitlab",
|
id: "gitlab",
|
||||||
type: "gitlab",
|
type: "gitlab",
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/gitlab.svg",
|
display_icon: "/icon/gitlab.svg",
|
||||||
display_name: "GitLab",
|
display_name: "GitLab",
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
hasAllRequiredExternalAuth: false,
|
hasAllRequiredExternalAuth: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ExternalAuthError: Story = {
|
export const ExternalAuthError: Story = {
|
||||||
args: {
|
args: {
|
||||||
error: true,
|
error: true,
|
||||||
externalAuth: [
|
externalAuth: [
|
||||||
{
|
{
|
||||||
id: "github",
|
id: "github",
|
||||||
type: "github",
|
type: "github",
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/github.svg",
|
display_icon: "/icon/github.svg",
|
||||||
display_name: "GitHub",
|
display_name: "GitHub",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "gitlab",
|
id: "gitlab",
|
||||||
type: "gitlab",
|
type: "gitlab",
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/gitlab.svg",
|
display_icon: "/icon/gitlab.svg",
|
||||||
display_name: "GitLab",
|
display_name: "GitLab",
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
hasAllRequiredExternalAuth: false,
|
hasAllRequiredExternalAuth: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ExternalAuthAllRequiredConnected: Story = {
|
export const ExternalAuthAllRequiredConnected: Story = {
|
||||||
args: {
|
args: {
|
||||||
externalAuth: [
|
externalAuth: [
|
||||||
{
|
{
|
||||||
id: "github",
|
id: "github",
|
||||||
type: "github",
|
type: "github",
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/github.svg",
|
display_icon: "/icon/github.svg",
|
||||||
display_name: "GitHub",
|
display_name: "GitHub",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "gitlab",
|
id: "gitlab",
|
||||||
type: "gitlab",
|
type: "gitlab",
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/gitlab.svg",
|
display_icon: "/icon/gitlab.svg",
|
||||||
display_name: "GitLab",
|
display_name: "GitLab",
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ExternalAuthAllConnected: Story = {
|
export const ExternalAuthAllConnected: Story = {
|
||||||
args: {
|
args: {
|
||||||
externalAuth: [
|
externalAuth: [
|
||||||
{
|
{
|
||||||
id: "github",
|
id: "github",
|
||||||
type: "github",
|
type: "github",
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/github.svg",
|
display_icon: "/icon/github.svg",
|
||||||
display_name: "GitHub",
|
display_name: "GitHub",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "gitlab",
|
id: "gitlab",
|
||||||
type: "gitlab",
|
type: "gitlab",
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
authenticate_url: "",
|
authenticate_url: "",
|
||||||
display_icon: "/icon/gitlab.svg",
|
display_icon: "/icon/gitlab.svg",
|
||||||
display_name: "GitLab",
|
display_name: "GitLab",
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -262,7 +262,10 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
form.setFieldValue("template_version_preset_id", option?.value)
|
form.setFieldValue(
|
||||||
|
"template_version_preset_id",
|
||||||
|
option?.value,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
placeholder="Select a preset"
|
placeholder="Select a preset"
|
||||||
selectedOption={presetOptions[selectedPresetIndex]}
|
selectedOption={presetOptions[selectedPresetIndex]}
|
||||||
|
Reference in New Issue
Block a user