From 9df08f76d794fc1c56bd65fa9bea7283358760a8 Mon Sep 17 00:00:00 2001 From: Danny Kopping Date: Tue, 18 Feb 2025 08:19:39 +0000 Subject: [PATCH] make lint; make fmt Signed-off-by: Danny Kopping --- cli/agent.go | 7 +- coderd/workspaceagents.go | 4 +- provisioner/terraform/executor.go | 2 + .../CreateWorkspacePageView.stories.tsx | 424 +++++++++--------- .../CreateWorkspacePageView.tsx | 5 +- 5 files changed, 223 insertions(+), 219 deletions(-) diff --git a/cli/agent.go b/cli/agent.go index acdcd2c9d3..6de6168a69 100644 --- a/cli/agent.go +++ b/cli/agent.go @@ -2,7 +2,6 @@ package cli import ( "context" - "errors" "fmt" "io" "net/http" @@ -16,10 +15,11 @@ import ( "time" "cloud.google.com/go/compute/metadata" - "github.com/coder/retry" "golang.org/x/xerrors" "gopkg.in/natefinch/lumberjack.v2" + "github.com/coder/retry" + "github.com/prometheus/client_golang/prometheus" "cdr.dev/slog" @@ -66,8 +66,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command { Handler: func(inv *serpent.Invocation) error { ctx, cancel := context.WithCancelCause(inv.Context()) defer func() { - fmt.Printf(">>>>>CANCELING CONTEXT") - cancel(errors.New("defer")) + cancel(xerrors.New("defer")) }() var ( diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index 2bae75b02a..24222295dc 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -1070,7 +1070,7 @@ func (api *API) workspaceAgentReinit(rw http.ResponseWriter, r *http.Request) { workspace, err := api.Database.GetWorkspaceByAgentID(ctx, workspaceAgent.ID) if err != nil { 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") @@ -1094,7 +1094,7 @@ func (api *API) workspaceAgentReinit(rw http.ResponseWriter, r *http.Request) { }) if err != nil { 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 } defer cancelSub() diff --git a/provisioner/terraform/executor.go b/provisioner/terraform/executor.go index 2ce1381aa2..99ec99856c 100644 --- a/provisioner/terraform/executor.go +++ b/provisioner/terraform/executor.go @@ -15,6 +15,8 @@ import ( "sync" "time" + "github.com/coder/terraform-provider-coder/provider" + "github.com/hashicorp/go-version" tfjson "github.com/hashicorp/terraform-json" "go.opentelemetry.io/otel/attribute" diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx index 8480ba08ac..6f0647c9f2 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx @@ -1,36 +1,36 @@ -import {action} from "@storybook/addon-actions"; -import type {Meta, StoryObj} from "@storybook/react"; -import {within } from "@testing-library/react"; +import { action } from "@storybook/addon-actions"; +import type { Meta, StoryObj } from "@storybook/react"; +import { within } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import {chromatic} from "testHelpers/chromatic"; +import { chromatic } from "testHelpers/chromatic"; import { - mockApiError, - MockTemplate, - MockTemplateVersionParameter1, - MockTemplateVersionParameter2, - MockTemplateVersionParameter3, - MockUser, + MockTemplate, + MockTemplateVersionParameter1, + MockTemplateVersionParameter2, + MockTemplateVersionParameter3, + MockUser, + mockApiError, } from "testHelpers/entities"; -import {CreateWorkspacePageView} from "./CreateWorkspacePageView"; +import { CreateWorkspacePageView } from "./CreateWorkspacePageView"; const meta: Meta = { - title: "pages/CreateWorkspacePage", - parameters: {chromatic}, - component: CreateWorkspacePageView, - args: { - defaultName: "", - defaultOwner: MockUser, - autofillParameters: [], - template: MockTemplate, - parameters: [], - externalAuth: [], - hasAllRequiredExternalAuth: true, - mode: "form", - permissions: { - createWorkspaceForUser: true, - }, - onCancel: action("onCancel"), - }, + title: "pages/CreateWorkspacePage", + parameters: { chromatic }, + component: CreateWorkspacePageView, + args: { + defaultName: "", + defaultOwner: MockUser, + autofillParameters: [], + template: MockTemplate, + parameters: [], + externalAuth: [], + hasAllRequiredExternalAuth: true, + mode: "form", + permissions: { + createWorkspaceForUser: true, + }, + onCancel: action("onCancel"), + }, }; export default meta; @@ -39,115 +39,115 @@ type Story = StoryObj; export const NoParameters: Story = {}; export const CreateWorkspaceError: Story = { - args: { - error: mockApiError({ - message: - 'Workspace "test" already exists in the "docker-amd64" template.', - validations: [ - { - field: "name", - detail: "This value is already in use and should be unique.", - }, - ], - }), - }, + args: { + error: mockApiError({ + message: + 'Workspace "test" already exists in the "docker-amd64" template.', + validations: [ + { + field: "name", + detail: "This value is already in use and should be unique.", + }, + ], + }), + }, }; export const SpecificVersion: Story = { - args: { - versionId: "specific-version", - }, + args: { + versionId: "specific-version", + }, }; export const Duplicate: Story = { - args: { - mode: "duplicate", - }, + args: { + mode: "duplicate", + }, }; export const Parameters: Story = { - args: { - parameters: [ - MockTemplateVersionParameter1, - MockTemplateVersionParameter2, - MockTemplateVersionParameter3, - { - name: "Region", - required: false, - description: "", - description_plaintext: "", - type: "string", - mutable: false, - default_value: "", - icon: "/emojis/1f30e.png", - options: [ - { - name: "Pittsburgh", - description: "", - value: "us-pittsburgh", - icon: "/emojis/1f1fa-1f1f8.png", - }, - { - name: "Helsinki", - description: "", - value: "eu-helsinki", - icon: "/emojis/1f1eb-1f1ee.png", - }, - { - name: "Sydney", - description: "", - value: "ap-sydney", - icon: "/emojis/1f1e6-1f1fa.png", - }, - ], - ephemeral: false, - }, - ], - autofillParameters: [ - { - name: "first_parameter", - value: "Cool suggestion", - source: "user_history", - }, - { - name: "third_parameter", - value: "aaaa", - source: "url", - }, - ], - }, + args: { + parameters: [ + MockTemplateVersionParameter1, + MockTemplateVersionParameter2, + MockTemplateVersionParameter3, + { + name: "Region", + required: false, + description: "", + description_plaintext: "", + type: "string", + mutable: false, + default_value: "", + icon: "/emojis/1f30e.png", + options: [ + { + name: "Pittsburgh", + description: "", + value: "us-pittsburgh", + icon: "/emojis/1f1fa-1f1f8.png", + }, + { + name: "Helsinki", + description: "", + value: "eu-helsinki", + icon: "/emojis/1f1eb-1f1ee.png", + }, + { + name: "Sydney", + description: "", + value: "ap-sydney", + icon: "/emojis/1f1e6-1f1fa.png", + }, + ], + ephemeral: false, + }, + ], + autofillParameters: [ + { + name: "first_parameter", + value: "Cool suggestion", + source: "user_history", + }, + { + name: "third_parameter", + value: "aaaa", + source: "url", + }, + ], + }, }; export const PresetsButNoneSelected: Story = { - args: { - presets: [ - { - ID: "preset-1", - Name: "Preset 1", - Parameters: [ - { - Name: MockTemplateVersionParameter1.name, - Value: "preset 1 override", - } - ] - }, - { - ID: "preset-2", - Name: "Preset 2", - Parameters: [ - { - Name: MockTemplateVersionParameter2.name, - Value: "42", - } - ] - }, - ], - parameters: [ - MockTemplateVersionParameter1, - MockTemplateVersionParameter2, - MockTemplateVersionParameter3, - ], - }, + args: { + presets: [ + { + ID: "preset-1", + Name: "Preset 1", + Parameters: [ + { + Name: MockTemplateVersionParameter1.name, + Value: "preset 1 override", + }, + ], + }, + { + ID: "preset-2", + Name: "Preset 2", + Parameters: [ + { + Name: MockTemplateVersionParameter2.name, + Value: "42", + }, + ], + }, + ], + parameters: [ + MockTemplateVersionParameter1, + MockTemplateVersionParameter2, + MockTemplateVersionParameter3, + ], + }, }; export const PresetSelected: Story = { @@ -160,100 +160,100 @@ export const PresetSelected: Story = { }; export const ExternalAuth: Story = { - args: { - externalAuth: [ - { - id: "github", - type: "github", - authenticated: false, - authenticate_url: "", - display_icon: "/icon/github.svg", - display_name: "GitHub", - }, - { - id: "gitlab", - type: "gitlab", - authenticated: true, - authenticate_url: "", - display_icon: "/icon/gitlab.svg", - display_name: "GitLab", - optional: true, - }, - ], - hasAllRequiredExternalAuth: false, - }, + args: { + externalAuth: [ + { + id: "github", + type: "github", + authenticated: false, + authenticate_url: "", + display_icon: "/icon/github.svg", + display_name: "GitHub", + }, + { + id: "gitlab", + type: "gitlab", + authenticated: true, + authenticate_url: "", + display_icon: "/icon/gitlab.svg", + display_name: "GitLab", + optional: true, + }, + ], + hasAllRequiredExternalAuth: false, + }, }; export const ExternalAuthError: Story = { - args: { - error: true, - externalAuth: [ - { - id: "github", - type: "github", - authenticated: false, - authenticate_url: "", - display_icon: "/icon/github.svg", - display_name: "GitHub", - }, - { - id: "gitlab", - type: "gitlab", - authenticated: false, - authenticate_url: "", - display_icon: "/icon/gitlab.svg", - display_name: "GitLab", - optional: true, - }, - ], - hasAllRequiredExternalAuth: false, - }, + args: { + error: true, + externalAuth: [ + { + id: "github", + type: "github", + authenticated: false, + authenticate_url: "", + display_icon: "/icon/github.svg", + display_name: "GitHub", + }, + { + id: "gitlab", + type: "gitlab", + authenticated: false, + authenticate_url: "", + display_icon: "/icon/gitlab.svg", + display_name: "GitLab", + optional: true, + }, + ], + hasAllRequiredExternalAuth: false, + }, }; export const ExternalAuthAllRequiredConnected: Story = { - args: { - externalAuth: [ - { - id: "github", - type: "github", - authenticated: true, - authenticate_url: "", - display_icon: "/icon/github.svg", - display_name: "GitHub", - }, - { - id: "gitlab", - type: "gitlab", - authenticated: false, - authenticate_url: "", - display_icon: "/icon/gitlab.svg", - display_name: "GitLab", - optional: true, - }, - ], - }, + args: { + externalAuth: [ + { + id: "github", + type: "github", + authenticated: true, + authenticate_url: "", + display_icon: "/icon/github.svg", + display_name: "GitHub", + }, + { + id: "gitlab", + type: "gitlab", + authenticated: false, + authenticate_url: "", + display_icon: "/icon/gitlab.svg", + display_name: "GitLab", + optional: true, + }, + ], + }, }; export const ExternalAuthAllConnected: Story = { - args: { - externalAuth: [ - { - id: "github", - type: "github", - authenticated: true, - authenticate_url: "", - display_icon: "/icon/github.svg", - display_name: "GitHub", - }, - { - id: "gitlab", - type: "gitlab", - authenticated: true, - authenticate_url: "", - display_icon: "/icon/gitlab.svg", - display_name: "GitLab", - optional: true, - }, - ], - }, + args: { + externalAuth: [ + { + id: "github", + type: "github", + authenticated: true, + authenticate_url: "", + display_icon: "/icon/github.svg", + display_name: "GitHub", + }, + { + id: "gitlab", + type: "gitlab", + authenticated: true, + authenticate_url: "", + display_icon: "/icon/gitlab.svg", + display_name: "GitLab", + optional: true, + }, + ], + }, }; diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx index c8949c8e5a..c4f7be1d08 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx @@ -262,7 +262,10 @@ export const CreateWorkspacePageView: FC = ({ ), ); - form.setFieldValue("template_version_preset_id", option?.value) + form.setFieldValue( + "template_version_preset_id", + option?.value, + ); }} placeholder="Select a preset" selectedOption={presetOptions[selectedPresetIndex]}