Skip to content

Commit

Permalink
Merge branch 'main' into ft/org-restrict-arbitrary-starts
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek authored Sep 25, 2024
2 parents e4cdfa3 + d1e314b commit 597b5a2
Show file tree
Hide file tree
Showing 63 changed files with 783 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ RUN curl -fsSL "https://get.sdkman.io" | bash \
# above, we are adding the sdkman init to .bashrc (executing sdkman-init.sh does that), because one is executed on interactive shells, the other for non-interactive shells (e.g. plugin-host)
ENV GRADLE_USER_HOME=/workspace/.gradle/

ENV NODE_VERSION=18.18.2
ENV NODE_VERSION=18.20.4

ENV PNPM_HOME=/root/.pnpm
ENV PATH=/root/.nvm/versions/node/v${NODE_VERSION}/bin:/root/.yarn/bin:${PNPM_HOME}:$PATH
Expand Down
14 changes: 7 additions & 7 deletions WORKSPACE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ defaultArgs:
codeWebExtensionCommit: 7ff72a2938a7a06cbdf3964590f7e9b7525958f3
xtermCommit: 8f10c5febf0162a3c2309076302f770fbad38fde
noVerifyJBPlugin: false
intellijDownloadUrl: "https://download.jetbrains.com/idea/ideaIU-2024.2.1.tar.gz"
golandDownloadUrl: "https://download.jetbrains.com/go/goland-2024.2.1.1.tar.gz"
pycharmDownloadUrl: "https://download.jetbrains.com/python/pycharm-professional-2024.2.1.tar.gz"
intellijDownloadUrl: "https://download.jetbrains.com/idea/ideaIU-2024.2.2.tar.gz"
golandDownloadUrl: "https://download.jetbrains.com/go/goland-2024.2.2.tar.gz"
pycharmDownloadUrl: "https://download.jetbrains.com/python/pycharm-professional-2024.2.2.tar.gz"
phpstormDownloadUrl: "https://download.jetbrains.com/webide/PhpStorm-2024.2.1.tar.gz"
rubymineDownloadUrl: "https://download.jetbrains.com/ruby/RubyMine-2024.2.1.tar.gz"
webstormDownloadUrl: "https://download.jetbrains.com/webstorm/WebStorm-2024.2.1.tar.gz"
rubymineDownloadUrl: "https://download.jetbrains.com/ruby/RubyMine-2024.2.2.tar.gz"
webstormDownloadUrl: "https://download.jetbrains.com/webstorm/WebStorm-2024.2.2.tar.gz"
riderDownloadUrl: "https://download.jetbrains.com/rider/JetBrains.Rider-2024.1.4.tar.gz"
clionDownloadUrl: "https://download.jetbrains.com/cpp/CLion-2024.2.1.tar.gz"
rustroverDownloadUrl: "https://download.jetbrains.com/rustrover/RustRover-2024.2.tar.gz"
clionDownloadUrl: "https://download.jetbrains.com/cpp/CLion-2024.2.2.tar.gz"
rustroverDownloadUrl: "https://download.jetbrains.com/rustrover/RustRover-2024.2.1.tar.gz"
jbBackendVersion: "latest"
dockerVersion: "20.10.24"
dockerComposeVersion: "2.27.0-gitpod.0"
Expand Down
2 changes: 1 addition & 1 deletion components/blobserve/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.

FROM cgr.dev/chainguard/wolfi-base:latest@sha256:0f1d81605bda6e2388c3c7f731700d8c12e17259d58ffba11f36ddc81d9c0a76
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:7574456f268bc839ac78828865087c04a4297ca226b0eb5d051d4222e7690081

# Ensure latest packages are present, like security updates.
RUN apk upgrade --no-cache \
Expand Down
2 changes: 1 addition & 1 deletion components/content-service/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.

FROM cgr.dev/chainguard/wolfi-base:latest@sha256:0f1d81605bda6e2388c3c7f731700d8c12e17259d58ffba11f36ddc81d9c0a76
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:7574456f268bc839ac78828865087c04a4297ca226b0eb5d051d4222e7690081

# Ensure latest packages are present, like security updates.
RUN apk upgrade --no-cache \
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.

FROM cgr.dev/chainguard/wolfi-base:latest@sha256:0f1d81605bda6e2388c3c7f731700d8c12e17259d58ffba11f36ddc81d9c0a76 as compress
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:7574456f268bc839ac78828865087c04a4297ca226b0eb5d051d4222e7690081 as compress

RUN apk add brotli gzip

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ export const ConfigurationDetailPrebuilds: FC<Props> = ({ configuration }) => {
<>
<ConfigurationSettingsField>
<Heading3>Prebuilds</Heading3>
<Subheading className="max-w-lg">Prebuilds reduce wait time for new workspaces.</Subheading>
<Subheading className="max-w-lg">
Prebuilds reduce wait time for new workspaces.{" "}
<a
href="https://www.gitpod.io/docs/configure/repositories/prebuilds"
target="_blank"
rel="noreferrer"
className="gp-link"
>
Learn more
</a>
</Subheading>

<SwitchInputField
className="mt-6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EnablePrebuildsError: FC<Props> = ({ error, onReconnect }) => {
// We need to authorize with the provider to acquire the correct scopes to install webhooks
if (error instanceof ApplicationError && error.code === ErrorCodes.NOT_AUTHENTICATED) {
return (
<RepositoryUnauthroizedErrorMessage
<RepositoryUnauthorizedErrorMessage
error={error.data as RepositoryUnauthorizedError}
onReconnect={onReconnect}
/>
Expand Down Expand Up @@ -63,11 +63,11 @@ const GenericErrorMessage: FC<GenericErrorMessageProps> = ({ message }) => {
);
};

type RepositoryUnauthroizedErrorMessageProps = {
type RepositoryUnauthorizedErrorMessageProps = {
error: RepositoryUnauthorizedError;
onReconnect: () => void;
};
const RepositoryUnauthroizedErrorMessage: FC<RepositoryUnauthroizedErrorMessageProps> = ({ error, onReconnect }) => {
const RepositoryUnauthorizedErrorMessage: FC<RepositoryUnauthorizedErrorMessageProps> = ({ error, onReconnect }) => {
const { toast } = useToast();

const authorizeWithProvider = useCallback(async () => {
Expand Down Expand Up @@ -106,7 +106,7 @@ const RepositoryUnauthroizedErrorMessage: FC<RepositoryUnauthroizedErrorMessageP
</span>
) : (
<span>
Unable to enable prebuilds. This could be because you don’t have admin/write premissions for
Unable to enable prebuilds. This could be because you don’t have admin/write permissions for
this repo or it could be an invalid token. Please try to reconnect. If the problem persists, you
can contact support.
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { FC, FormEvent, useCallback, useMemo, useState } from "react";
import { ConfigurationSettingsField } from "../ConfigurationSettingsField";
import { Heading3, Subheading } from "@podkit/typography/Headings";
import { Text } from "@podkit/typography/Text";
import { InputField } from "../../../components/forms/InputField";
import { PartialConfiguration, useConfigurationMutation } from "../../../data/configurations/configuration-queries";
import { useToast } from "../../../components/toasts/Toasts";
Expand All @@ -28,6 +29,8 @@ import { trackEvent } from "../../../Analytics";
import dayjs from "dayjs";
import { SwitchInputField } from "@podkit/switch/Switch";
import { useFeatureFlag } from "../../../data/featureflag-query";
import { TextMuted } from "@podkit/typography/TextMuted";
import { InfoIcon } from "lucide-react";

const DEFAULT_PREBUILD_COMMIT_INTERVAL = 20;

Expand Down Expand Up @@ -224,6 +227,22 @@ export const PrebuildSettingsForm: FC<Props> = ({ configuration }) => {
</InputField>
)}

<div className="mt-4">
<Text className="font-semibold text-md text-pk-content-secondary">Prebuild trigger strategy</Text>
<TextMuted className="text-sm mt-1 flex flex-row gap-1 items-center">
{configuration.prebuildSettings?.triggerStrategy === PrebuildTriggerStrategy.ACTIVITY_BASED
? "Activity-based"
: "Webhook-based"}
<a
href="https://www.gitpod.io/docs/configure/repositories/prebuilds#triggers"
target="_blank"
rel="noreferrer"
>
<InfoIcon size={14} />
</a>
</TextMuted>
</div>

<Heading3 className="mt-8">Machine type</Heading3>
<Subheading>Choose the workspace machine type for your prebuilds.</Subheading>

Expand Down
2 changes: 1 addition & 1 deletion components/ee/agent-smith/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



FROM cgr.dev/chainguard/wolfi-base:latest@sha256:0f1d81605bda6e2388c3c7f731700d8c12e17259d58ffba11f36ddc81d9c0a76
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:7574456f268bc839ac78828865087c04a4297ca226b0eb5d051d4222e7690081

RUN apk add --no-cache git bash ca-certificates
COPY components-ee-agent-smith--app/agent-smith /app/
Expand Down
104 changes: 66 additions & 38 deletions components/gitpod-cli/cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cmd

import (
"bufio"
"bytes"
"context"
"encoding/json"
"fmt"
Expand All @@ -16,6 +17,7 @@ import (
"path/filepath"
"strings"
"time"
"unicode/utf8"

"github.com/gitpod-io/gitpod/common-go/log"
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/supervisor"
Expand Down Expand Up @@ -564,59 +566,85 @@ func pipeTask(ctx context.Context, task *api.TaskStatus, supervisor *supervisor.
}
}

func listenTerminal(ctx context.Context, task *api.TaskStatus, supervisor *supervisor.SupervisorClient, runLog *logrus.Entry) error {
listen, err := supervisor.Terminal.Listen(ctx, &api.ListenTerminalRequest{
Alias: task.Terminal,
})
if err != nil {
return err
}
// TerminalReader is an interface for anything that can receive terminal data (this is abstracted for use in testing)
type TerminalReader interface {
Recv() ([]byte, error)
}

pr, pw := io.Pipe()
defer pr.Close()
defer pw.Close()
type LinePrinter func(string)

scanner := bufio.NewScanner(pr)
const maxTokenSize = 1 * 1024 * 1024 // 1 MB
buf := make([]byte, maxTokenSize)
scanner.Buffer(buf, maxTokenSize)
// processTerminalOutput reads from a TerminalReader, processes the output, and calls the provided LinePrinter for each complete line.
// It handles UTF-8 decoding of characters split across chunks and control characters (\n \r \b).
func processTerminalOutput(reader TerminalReader, printLine LinePrinter) error {
var buffer, line bytes.Buffer

go func() {
defer pw.Close()
for {
resp, err := listen.Recv()
if err != nil {
_ = pw.CloseWithError(err)
return
}
flushLine := func() {
if line.Len() > 0 {
printLine(line.String())
line.Reset()
}
}

title := resp.GetTitle()
if title != "" {
task.Presentation.Name = title
for {
data, err := reader.Recv()
if err != nil {
if err == io.EOF {
flushLine()
return nil
}
return err
}

buffer.Write(data)

exitCode := resp.GetExitCode()
if exitCode != 0 {
runLog.Infof("%s: exited with code %d", task.Presentation.Name, exitCode)
for {
r, size := utf8.DecodeRune(buffer.Bytes())
if r == utf8.RuneError && size == 0 {
break // incomplete character at the end
}

data := resp.GetData()
if len(data) > 0 {
_, err := pw.Write(data)
if err != nil {
_ = pw.CloseWithError(err)
return
char := buffer.Next(size)

switch r {
case '\r':
flushLine()
case '\n':
flushLine()
case '\b':
if line.Len() > 0 {
line.Truncate(line.Len() - 1)
}
default:
line.Write(char)
}
}
}()
}
}

for scanner.Scan() {
line := scanner.Text()
func listenTerminal(ctx context.Context, task *api.TaskStatus, supervisor *supervisor.SupervisorClient, runLog *logrus.Entry) error {
listen, err := supervisor.Terminal.Listen(ctx, &api.ListenTerminalRequest{Alias: task.Terminal})
if err != nil {
return err
}

terminalReader := &TerminalReaderAdapter{listen}
printLine := func(line string) {
runLog.Infof("%s: %s", task.Presentation.Name, line)
}

return scanner.Err()
return processTerminalOutput(terminalReader, printLine)
}

type TerminalReaderAdapter struct {
client api.TerminalService_ListenClient
}

func (t *TerminalReaderAdapter) Recv() ([]byte, error) {
resp, err := t.client.Recv()
if err != nil {
return nil, err
}
return resp.GetData(), nil
}

var validateOpts struct {
Expand Down
Loading

0 comments on commit 597b5a2

Please sign in to comment.