diff --git a/components/dashboard/src/service/json-rpc-envvar-client.ts b/components/dashboard/src/service/json-rpc-envvar-client.ts new file mode 100644 index 00000000000000..922fc9a57cf9aa --- /dev/null +++ b/components/dashboard/src/service/json-rpc-envvar-client.ts @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2023 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License.AGPL.txt in the project root for license information. + */ + +import { Code, ConnectError, PromiseClient } from "@connectrpc/connect"; +import { PartialMessage } from "@bufbuild/protobuf"; +import { EnvironmentVariableService } from "@gitpod/public-api/lib/gitpod/v1/envvar_connect"; +import { + ListEnvironmentVariablesRequest, + ListEnvironmentVariablesResponse, + UpdateEnvironmentVariableRequest, + UpdateEnvironmentVariableResponse, + DeleteEnvironmentVariableRequest, + DeleteEnvironmentVariableResponse, +} from "@gitpod/public-api/lib/gitpod/v1/envvar_pb"; +import { converter } from "./public-api"; +import { getGitpodService } from "./service"; +import { UserEnvVar, UserEnvVarValue } from "@gitpod/gitpod-protocol"; + +export class JsonRpcEnvvarClient implements PromiseClient { + async listEnvironmentVariables( + req: PartialMessage, + ): Promise { + const userEnvVars = await getGitpodService().server.getAllEnvVars(); + const result = new ListEnvironmentVariablesResponse(); + result.environmentVariables = userEnvVars.map((i) => converter.toUserEnvironmentVariable(i)); + return result; + } + + async updateEnvironmentVariable( + req: PartialMessage, + ): Promise { + await getGitpodService().server.setEnvVar({ + name: req.envvarName || "", + value: req.envvarValue || "", + repositoryPattern: req.envvarRepositoryPattern || "", + }); + + req.envvarRepositoryPattern = UserEnvVar.normalizeRepoPattern(req.envvarRepositoryPattern || ""); + const updatedUserEnvVars = await getGitpodService().server.getAllEnvVars(); + const updatedUserEnvVar = updatedUserEnvVars.find( + (v) => v.name === req.envvarName && v.repositoryPattern === req.envvarRepositoryPattern, + ); + if (!updatedUserEnvVar) { + throw new ConnectError("env variable not found", Code.Internal); + } + + const response = new UpdateEnvironmentVariableResponse(); + response.environmentVariable = converter.toUserEnvironmentVariable(updatedUserEnvVar); + return response; + } + + async deleteEnvironmentVariable( + req: PartialMessage, + ): Promise { + const variable: UserEnvVarValue = { + name: req.envvarName || "", + value: "", + repositoryPattern: req.envvarRepositoryPattern || "", + }; + await getGitpodService().server.deleteEnvVar(variable); + + const response = new DeleteEnvironmentVariableResponse(); + return response; + } +} diff --git a/components/dashboard/src/service/public-api.ts b/components/dashboard/src/service/public-api.ts index f327a89ad40b20..1580b688516520 100644 --- a/components/dashboard/src/service/public-api.ts +++ b/components/dashboard/src/service/public-api.ts @@ -25,6 +25,8 @@ import { JsonRpcOrganizationClient } from "./json-rpc-organization-client"; import { JsonRpcWorkspaceClient } from "./json-rpc-workspace-client"; import { JsonRpcAuthProviderClient } from "./json-rpc-authprovider-client"; import { AuthProviderService } from "@gitpod/public-api/lib/gitpod/v1/authprovider_connect"; +import { EnvironmentVariableService } from "@gitpod/public-api/lib/gitpod/v1/envvar_connect"; +import { JsonRpcEnvvarClient } from "./json-rpc-envvar-client"; const transport = createConnectTransport({ baseUrl: `${window.location.protocol}//${window.location.host}/public-api`, @@ -53,6 +55,8 @@ export const configurationClient = createServiceClient(ConfigurationService); export const authProviderClient = createServiceClient(AuthProviderService, new JsonRpcAuthProviderClient()); +export const envvarClient = createServiceClient(EnvironmentVariableService, new JsonRpcEnvvarClient()); + export async function listAllProjects(opts: { orgId: string }): Promise { let pagination = { page: 1, diff --git a/components/dashboard/src/user-settings/EnvironmentVariables.tsx b/components/dashboard/src/user-settings/EnvironmentVariables.tsx index d8fecacd6a0fa8..6868573ccdc0d3 100644 --- a/components/dashboard/src/user-settings/EnvironmentVariables.tsx +++ b/components/dashboard/src/user-settings/EnvironmentVariables.tsx @@ -9,11 +9,11 @@ import { useCallback, useEffect, useRef, useState } from "react"; import ConfirmationModal from "../components/ConfirmationModal"; import { Item, ItemField, ItemsList } from "../components/ItemsList"; import Modal, { ModalBody, ModalFooter, ModalHeader } from "../components/Modal"; -import { getGitpodService } from "../service/service"; import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu"; import { EnvironmentVariableEntry } from "./EnvironmentVariableEntry"; import { Button } from "../components/Button"; import { Heading2, Subheading } from "../components/typography/headings"; +import { envvarClient } from "../service/public-api"; interface EnvVarModalProps { envVar: UserEnvVarValue; @@ -150,9 +150,9 @@ export default function EnvVars() { const [isAddEnvVarModalVisible, setAddEnvVarModalVisible] = useState(false); const [isDeleteEnvVarModalVisible, setDeleteEnvVarModalVisible] = useState(false); const update = async () => { - await getGitpodService() - .server.getAllEnvVars() - .then((r) => setEnvVars(r.sort(sortEnvVars))); + await envvarClient + .listEnvironmentVariables({}) + .then((r) => setEnvVars(r.environmentVariables.sort(sortEnvVars))); }; useEffect(() => { @@ -178,12 +178,19 @@ export default function EnvVars() { }; const save = async (variable: UserEnvVarValue) => { - await getGitpodService().server.setEnvVar(variable); + await envvarClient.updateEnvironmentVariable({ + envvarName: variable.name, + envvarValue: variable.value, + envvarRepositoryPattern: variable.repositoryPattern, + }); await update(); }; const deleteVariable = async (variable: UserEnvVarValue) => { - await getGitpodService().server.deleteEnvVar(variable); + await envvarClient.deleteEnvironmentVariable({ + envvarName: variable.name, + envvarRepositoryPattern: variable.repositoryPattern, + }); await update(); }; diff --git a/components/gitpod-protocol/src/public-api-converter.ts b/components/gitpod-protocol/src/public-api-converter.ts index 6f39e48f5d57e0..f3df03673a252c 100644 --- a/components/gitpod-protocol/src/public-api-converter.ts +++ b/components/gitpod-protocol/src/public-api-converter.ts @@ -38,6 +38,7 @@ import { WorkspacePort_Protocol, WorkspaceStatus, } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb"; +import { UserEnvironmentVariable } from "@gitpod/public-api/lib/gitpod/v1/envvar_pb"; import { ContextURL } from "./context-url"; import { ApplicationError, ErrorCode, ErrorCodes } from "./messaging/error"; import { @@ -50,6 +51,7 @@ import { WithPrebuild, WorkspaceContext, WorkspaceInfo, + UserEnvVarValue, } from "./protocol"; import { OrgMemberInfo, @@ -104,7 +106,7 @@ export class PublicAPIConverter { status.admission = this.toAdmission(arg.workspace.shareable); status.gitStatus = this.toGitStatus(arg.workspace); workspace.status = status; - workspace.additionalEnvironmentVariables = this.toEnvironmentVariables(arg.workspace.context); + workspace.additionalEnvironmentVariables = this.toWorkspaceEnvironmentVariables(arg.workspace.context); if (arg.latestInstance) { return this.toWorkspace(arg.latestInstance, workspace); @@ -221,17 +223,26 @@ export class PublicAPIConverter { return new ApplicationError(code, reason.message, new TrustedValue(data)); } - toEnvironmentVariables(context: WorkspaceContext): WorkspaceEnvironmentVariable[] { + toWorkspaceEnvironmentVariables(context: WorkspaceContext): WorkspaceEnvironmentVariable[] { if (WithEnvvarsContext.is(context)) { - return context.envvars.map((envvar) => this.toEnvironmentVariable(envvar)); + return context.envvars.map((envvar) => this.toWorkspaceEnvironmentVariable(envvar)); } return []; } - toEnvironmentVariable(envVar: EnvVarWithValue): WorkspaceEnvironmentVariable { + toWorkspaceEnvironmentVariable(envVar: EnvVarWithValue): WorkspaceEnvironmentVariable { const result = new WorkspaceEnvironmentVariable(); result.name = envVar.name; - envVar.value = envVar.value; + result.value = envVar.value; + return result; + } + + toUserEnvironmentVariable(envVar: UserEnvVarValue): UserEnvironmentVariable { + const result = new UserEnvironmentVariable(); + result.id = envVar.id || ""; + result.name = envVar.name; + result.value = envVar.value; + result.repositoryPattern = envVar.repositoryPattern; return result; } diff --git a/components/public-api/gitpod/v1/envvar.proto b/components/public-api/gitpod/v1/envvar.proto new file mode 100644 index 00000000000000..691d7e8a7bbedc --- /dev/null +++ b/components/public-api/gitpod/v1/envvar.proto @@ -0,0 +1,59 @@ +syntax = "proto3"; + +package gitpod.v1; + +option go_package = "github.com/gitpod-io/gitpod/components/public-api/go/v1"; + +service EnvironmentVariableService { + // ListEnvironmentVariables returns all environment variables for the + // authenticated user. + // + // +return NOT_FOUND User does not have access to a workspace with the given + // ID +return NOT_FOUND Workspace does not exist + rpc ListEnvironmentVariables(ListEnvironmentVariablesRequest) + returns (ListEnvironmentVariablesResponse) {} + + // UpdateEnvironmentVariable updates an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + rpc UpdateEnvironmentVariable(UpdateEnvironmentVariableRequest) + returns (UpdateEnvironmentVariableResponse) {} + + // DeleteEnvironmentVariable deletes an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + rpc DeleteEnvironmentVariable(DeleteEnvironmentVariableRequest) + returns (DeleteEnvironmentVariableResponse) {} +} + +message UserEnvironmentVariable { + string id = 1; + string name = 2; + string value = 3; + string repository_pattern = 4; +} + +message ListEnvironmentVariablesRequest { optional string workspace_id = 1; } + +message ListEnvironmentVariablesResponse { + repeated UserEnvironmentVariable environment_variables = 1; +} + +message UpdateEnvironmentVariableRequest { + optional string envvar_name = 1; + optional string envvar_value = 2; + optional string envvar_repository_pattern = 3; +} + +message UpdateEnvironmentVariableResponse { + UserEnvironmentVariable environment_variable = 1; +} + +message DeleteEnvironmentVariableRequest { + string envvar_name = 1; + string envvar_repository_pattern = 2; +} + +message DeleteEnvironmentVariableResponse {} diff --git a/components/public-api/go/v1/envvar.pb.go b/components/public-api/go/v1/envvar.pb.go new file mode 100644 index 00000000000000..4c77b9e9574c45 --- /dev/null +++ b/components/public-api/go/v1/envvar.pb.go @@ -0,0 +1,636 @@ +// Copyright (c) 2023 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License.AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: gitpod/v1/envvar.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UserEnvironmentVariable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` + RepositoryPattern string `protobuf:"bytes,4,opt,name=repository_pattern,json=repositoryPattern,proto3" json:"repository_pattern,omitempty"` +} + +func (x *UserEnvironmentVariable) Reset() { + *x = UserEnvironmentVariable{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserEnvironmentVariable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserEnvironmentVariable) ProtoMessage() {} + +func (x *UserEnvironmentVariable) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserEnvironmentVariable.ProtoReflect.Descriptor instead. +func (*UserEnvironmentVariable) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{0} +} + +func (x *UserEnvironmentVariable) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UserEnvironmentVariable) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UserEnvironmentVariable) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *UserEnvironmentVariable) GetRepositoryPattern() string { + if x != nil { + return x.RepositoryPattern + } + return "" +} + +type ListEnvironmentVariablesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + WorkspaceId *string `protobuf:"bytes,1,opt,name=workspace_id,json=workspaceId,proto3,oneof" json:"workspace_id,omitempty"` +} + +func (x *ListEnvironmentVariablesRequest) Reset() { + *x = ListEnvironmentVariablesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListEnvironmentVariablesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListEnvironmentVariablesRequest) ProtoMessage() {} + +func (x *ListEnvironmentVariablesRequest) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListEnvironmentVariablesRequest.ProtoReflect.Descriptor instead. +func (*ListEnvironmentVariablesRequest) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{1} +} + +func (x *ListEnvironmentVariablesRequest) GetWorkspaceId() string { + if x != nil && x.WorkspaceId != nil { + return *x.WorkspaceId + } + return "" +} + +type ListEnvironmentVariablesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EnvironmentVariables []*UserEnvironmentVariable `protobuf:"bytes,1,rep,name=environment_variables,json=environmentVariables,proto3" json:"environment_variables,omitempty"` +} + +func (x *ListEnvironmentVariablesResponse) Reset() { + *x = ListEnvironmentVariablesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListEnvironmentVariablesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListEnvironmentVariablesResponse) ProtoMessage() {} + +func (x *ListEnvironmentVariablesResponse) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListEnvironmentVariablesResponse.ProtoReflect.Descriptor instead. +func (*ListEnvironmentVariablesResponse) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{2} +} + +func (x *ListEnvironmentVariablesResponse) GetEnvironmentVariables() []*UserEnvironmentVariable { + if x != nil { + return x.EnvironmentVariables + } + return nil +} + +type UpdateEnvironmentVariableRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EnvvarName *string `protobuf:"bytes,1,opt,name=envvar_name,json=envvarName,proto3,oneof" json:"envvar_name,omitempty"` + EnvvarValue *string `protobuf:"bytes,2,opt,name=envvar_value,json=envvarValue,proto3,oneof" json:"envvar_value,omitempty"` + EnvvarRepositoryPattern *string `protobuf:"bytes,3,opt,name=envvar_repository_pattern,json=envvarRepositoryPattern,proto3,oneof" json:"envvar_repository_pattern,omitempty"` +} + +func (x *UpdateEnvironmentVariableRequest) Reset() { + *x = UpdateEnvironmentVariableRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateEnvironmentVariableRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateEnvironmentVariableRequest) ProtoMessage() {} + +func (x *UpdateEnvironmentVariableRequest) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateEnvironmentVariableRequest.ProtoReflect.Descriptor instead. +func (*UpdateEnvironmentVariableRequest) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{3} +} + +func (x *UpdateEnvironmentVariableRequest) GetEnvvarName() string { + if x != nil && x.EnvvarName != nil { + return *x.EnvvarName + } + return "" +} + +func (x *UpdateEnvironmentVariableRequest) GetEnvvarValue() string { + if x != nil && x.EnvvarValue != nil { + return *x.EnvvarValue + } + return "" +} + +func (x *UpdateEnvironmentVariableRequest) GetEnvvarRepositoryPattern() string { + if x != nil && x.EnvvarRepositoryPattern != nil { + return *x.EnvvarRepositoryPattern + } + return "" +} + +type UpdateEnvironmentVariableResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EnvironmentVariable *UserEnvironmentVariable `protobuf:"bytes,1,opt,name=environment_variable,json=environmentVariable,proto3" json:"environment_variable,omitempty"` +} + +func (x *UpdateEnvironmentVariableResponse) Reset() { + *x = UpdateEnvironmentVariableResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateEnvironmentVariableResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateEnvironmentVariableResponse) ProtoMessage() {} + +func (x *UpdateEnvironmentVariableResponse) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateEnvironmentVariableResponse.ProtoReflect.Descriptor instead. +func (*UpdateEnvironmentVariableResponse) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{4} +} + +func (x *UpdateEnvironmentVariableResponse) GetEnvironmentVariable() *UserEnvironmentVariable { + if x != nil { + return x.EnvironmentVariable + } + return nil +} + +type DeleteEnvironmentVariableRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EnvvarName string `protobuf:"bytes,1,opt,name=envvar_name,json=envvarName,proto3" json:"envvar_name,omitempty"` + EnvvarRepositoryPattern string `protobuf:"bytes,2,opt,name=envvar_repository_pattern,json=envvarRepositoryPattern,proto3" json:"envvar_repository_pattern,omitempty"` +} + +func (x *DeleteEnvironmentVariableRequest) Reset() { + *x = DeleteEnvironmentVariableRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteEnvironmentVariableRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteEnvironmentVariableRequest) ProtoMessage() {} + +func (x *DeleteEnvironmentVariableRequest) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteEnvironmentVariableRequest.ProtoReflect.Descriptor instead. +func (*DeleteEnvironmentVariableRequest) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{5} +} + +func (x *DeleteEnvironmentVariableRequest) GetEnvvarName() string { + if x != nil { + return x.EnvvarName + } + return "" +} + +func (x *DeleteEnvironmentVariableRequest) GetEnvvarRepositoryPattern() string { + if x != nil { + return x.EnvvarRepositoryPattern + } + return "" +} + +type DeleteEnvironmentVariableResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteEnvironmentVariableResponse) Reset() { + *x = DeleteEnvironmentVariableResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_gitpod_v1_envvar_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteEnvironmentVariableResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteEnvironmentVariableResponse) ProtoMessage() {} + +func (x *DeleteEnvironmentVariableResponse) ProtoReflect() protoreflect.Message { + mi := &file_gitpod_v1_envvar_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteEnvironmentVariableResponse.ProtoReflect.Descriptor instead. +func (*DeleteEnvironmentVariableResponse) Descriptor() ([]byte, []int) { + return file_gitpod_v1_envvar_proto_rawDescGZIP(), []int{6} +} + +var File_gitpod_v1_envvar_proto protoreflect.FileDescriptor + +var file_gitpod_v1_envvar_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x6e, 0x76, 0x76, + 0x61, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, + 0x2e, 0x76, 0x31, 0x22, 0x82, 0x01, 0x0a, 0x17, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e, 0x76, 0x69, + 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x22, 0x5a, 0x0a, 0x1f, 0x4c, 0x69, 0x73, 0x74, + 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0c, 0x77, + 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x00, 0x52, 0x0b, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, + 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x22, 0x7b, 0x0a, 0x20, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x76, 0x69, + 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x57, 0x0a, 0x15, 0x65, 0x6e, 0x76, 0x69, + 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, + 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, + 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x14, 0x65, 0x6e, 0x76, + 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, + 0x73, 0x22, 0xf0, 0x01, 0x0a, 0x20, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, + 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0a, 0x65, + 0x6e, 0x76, 0x76, 0x61, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x26, 0x0a, 0x0c, + 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x01, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x88, 0x01, 0x01, 0x12, 0x3f, 0x0a, 0x19, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, 0x5f, 0x72, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, + 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x17, 0x65, 0x6e, 0x76, 0x76, 0x61, + 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x61, 0x74, 0x74, 0x65, + 0x72, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, + 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x1c, 0x0a, 0x1a, 0x5f, 0x65, 0x6e, 0x76, 0x76, 0x61, + 0x72, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x74, + 0x74, 0x65, 0x72, 0x6e, 0x22, 0x7a, 0x0a, 0x21, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, + 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, 0x14, 0x65, 0x6e, 0x76, + 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, + 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, + 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x13, 0x65, 0x6e, 0x76, + 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, + 0x22, 0x7f, 0x0a, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, + 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x76, 0x76, 0x61, + 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x19, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, 0x5f, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, + 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x65, 0x6e, 0x76, 0x76, 0x61, 0x72, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, + 0x6e, 0x22, 0x23, 0x0a, 0x21, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, + 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x87, 0x03, 0x0a, 0x1a, 0x45, 0x6e, 0x76, 0x69, 0x72, + 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x75, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x76, + 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, + 0x73, 0x12, 0x2a, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, + 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, + 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, + 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x78, 0x0a, 0x19, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, + 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2b, 0x2e, 0x67, 0x69, 0x74, 0x70, + 0x6f, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, + 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, + 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, + 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x78, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0x12, 0x2b, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x76, 0x31, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, + 0x74, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x2c, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, + 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, + 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, + 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_gitpod_v1_envvar_proto_rawDescOnce sync.Once + file_gitpod_v1_envvar_proto_rawDescData = file_gitpod_v1_envvar_proto_rawDesc +) + +func file_gitpod_v1_envvar_proto_rawDescGZIP() []byte { + file_gitpod_v1_envvar_proto_rawDescOnce.Do(func() { + file_gitpod_v1_envvar_proto_rawDescData = protoimpl.X.CompressGZIP(file_gitpod_v1_envvar_proto_rawDescData) + }) + return file_gitpod_v1_envvar_proto_rawDescData +} + +var file_gitpod_v1_envvar_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_gitpod_v1_envvar_proto_goTypes = []interface{}{ + (*UserEnvironmentVariable)(nil), // 0: gitpod.v1.UserEnvironmentVariable + (*ListEnvironmentVariablesRequest)(nil), // 1: gitpod.v1.ListEnvironmentVariablesRequest + (*ListEnvironmentVariablesResponse)(nil), // 2: gitpod.v1.ListEnvironmentVariablesResponse + (*UpdateEnvironmentVariableRequest)(nil), // 3: gitpod.v1.UpdateEnvironmentVariableRequest + (*UpdateEnvironmentVariableResponse)(nil), // 4: gitpod.v1.UpdateEnvironmentVariableResponse + (*DeleteEnvironmentVariableRequest)(nil), // 5: gitpod.v1.DeleteEnvironmentVariableRequest + (*DeleteEnvironmentVariableResponse)(nil), // 6: gitpod.v1.DeleteEnvironmentVariableResponse +} +var file_gitpod_v1_envvar_proto_depIdxs = []int32{ + 0, // 0: gitpod.v1.ListEnvironmentVariablesResponse.environment_variables:type_name -> gitpod.v1.UserEnvironmentVariable + 0, // 1: gitpod.v1.UpdateEnvironmentVariableResponse.environment_variable:type_name -> gitpod.v1.UserEnvironmentVariable + 1, // 2: gitpod.v1.EnvironmentVariableService.ListEnvironmentVariables:input_type -> gitpod.v1.ListEnvironmentVariablesRequest + 3, // 3: gitpod.v1.EnvironmentVariableService.UpdateEnvironmentVariable:input_type -> gitpod.v1.UpdateEnvironmentVariableRequest + 5, // 4: gitpod.v1.EnvironmentVariableService.DeleteEnvironmentVariable:input_type -> gitpod.v1.DeleteEnvironmentVariableRequest + 2, // 5: gitpod.v1.EnvironmentVariableService.ListEnvironmentVariables:output_type -> gitpod.v1.ListEnvironmentVariablesResponse + 4, // 6: gitpod.v1.EnvironmentVariableService.UpdateEnvironmentVariable:output_type -> gitpod.v1.UpdateEnvironmentVariableResponse + 6, // 7: gitpod.v1.EnvironmentVariableService.DeleteEnvironmentVariable:output_type -> gitpod.v1.DeleteEnvironmentVariableResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_gitpod_v1_envvar_proto_init() } +func file_gitpod_v1_envvar_proto_init() { + if File_gitpod_v1_envvar_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_gitpod_v1_envvar_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserEnvironmentVariable); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gitpod_v1_envvar_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListEnvironmentVariablesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gitpod_v1_envvar_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListEnvironmentVariablesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gitpod_v1_envvar_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateEnvironmentVariableRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gitpod_v1_envvar_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateEnvironmentVariableResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gitpod_v1_envvar_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteEnvironmentVariableRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gitpod_v1_envvar_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteEnvironmentVariableResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_gitpod_v1_envvar_proto_msgTypes[1].OneofWrappers = []interface{}{} + file_gitpod_v1_envvar_proto_msgTypes[3].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_gitpod_v1_envvar_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_gitpod_v1_envvar_proto_goTypes, + DependencyIndexes: file_gitpod_v1_envvar_proto_depIdxs, + MessageInfos: file_gitpod_v1_envvar_proto_msgTypes, + }.Build() + File_gitpod_v1_envvar_proto = out.File + file_gitpod_v1_envvar_proto_rawDesc = nil + file_gitpod_v1_envvar_proto_goTypes = nil + file_gitpod_v1_envvar_proto_depIdxs = nil +} diff --git a/components/public-api/go/v1/envvar_grpc.pb.go b/components/public-api/go/v1/envvar_grpc.pb.go new file mode 100644 index 00000000000000..f54b75d175804b --- /dev/null +++ b/components/public-api/go/v1/envvar_grpc.pb.go @@ -0,0 +1,208 @@ +// Copyright (c) 2023 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License.AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: gitpod/v1/envvar.proto + +package v1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// EnvironmentVariableServiceClient is the client API for EnvironmentVariableService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type EnvironmentVariableServiceClient interface { + // ListEnvironmentVariables returns all environment variables for the + // authenticated user. + // + // +return NOT_FOUND User does not have access to a workspace with the given + // ID +return NOT_FOUND Workspace does not exist + ListEnvironmentVariables(ctx context.Context, in *ListEnvironmentVariablesRequest, opts ...grpc.CallOption) (*ListEnvironmentVariablesResponse, error) + // UpdateEnvironmentVariable updates an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + UpdateEnvironmentVariable(ctx context.Context, in *UpdateEnvironmentVariableRequest, opts ...grpc.CallOption) (*UpdateEnvironmentVariableResponse, error) + // DeleteEnvironmentVariable deletes an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + DeleteEnvironmentVariable(ctx context.Context, in *DeleteEnvironmentVariableRequest, opts ...grpc.CallOption) (*DeleteEnvironmentVariableResponse, error) +} + +type environmentVariableServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewEnvironmentVariableServiceClient(cc grpc.ClientConnInterface) EnvironmentVariableServiceClient { + return &environmentVariableServiceClient{cc} +} + +func (c *environmentVariableServiceClient) ListEnvironmentVariables(ctx context.Context, in *ListEnvironmentVariablesRequest, opts ...grpc.CallOption) (*ListEnvironmentVariablesResponse, error) { + out := new(ListEnvironmentVariablesResponse) + err := c.cc.Invoke(ctx, "/gitpod.v1.EnvironmentVariableService/ListEnvironmentVariables", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *environmentVariableServiceClient) UpdateEnvironmentVariable(ctx context.Context, in *UpdateEnvironmentVariableRequest, opts ...grpc.CallOption) (*UpdateEnvironmentVariableResponse, error) { + out := new(UpdateEnvironmentVariableResponse) + err := c.cc.Invoke(ctx, "/gitpod.v1.EnvironmentVariableService/UpdateEnvironmentVariable", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *environmentVariableServiceClient) DeleteEnvironmentVariable(ctx context.Context, in *DeleteEnvironmentVariableRequest, opts ...grpc.CallOption) (*DeleteEnvironmentVariableResponse, error) { + out := new(DeleteEnvironmentVariableResponse) + err := c.cc.Invoke(ctx, "/gitpod.v1.EnvironmentVariableService/DeleteEnvironmentVariable", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// EnvironmentVariableServiceServer is the server API for EnvironmentVariableService service. +// All implementations must embed UnimplementedEnvironmentVariableServiceServer +// for forward compatibility +type EnvironmentVariableServiceServer interface { + // ListEnvironmentVariables returns all environment variables for the + // authenticated user. + // + // +return NOT_FOUND User does not have access to a workspace with the given + // ID +return NOT_FOUND Workspace does not exist + ListEnvironmentVariables(context.Context, *ListEnvironmentVariablesRequest) (*ListEnvironmentVariablesResponse, error) + // UpdateEnvironmentVariable updates an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + UpdateEnvironmentVariable(context.Context, *UpdateEnvironmentVariableRequest) (*UpdateEnvironmentVariableResponse, error) + // DeleteEnvironmentVariable deletes an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + DeleteEnvironmentVariable(context.Context, *DeleteEnvironmentVariableRequest) (*DeleteEnvironmentVariableResponse, error) + mustEmbedUnimplementedEnvironmentVariableServiceServer() +} + +// UnimplementedEnvironmentVariableServiceServer must be embedded to have forward compatible implementations. +type UnimplementedEnvironmentVariableServiceServer struct { +} + +func (UnimplementedEnvironmentVariableServiceServer) ListEnvironmentVariables(context.Context, *ListEnvironmentVariablesRequest) (*ListEnvironmentVariablesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEnvironmentVariables not implemented") +} +func (UnimplementedEnvironmentVariableServiceServer) UpdateEnvironmentVariable(context.Context, *UpdateEnvironmentVariableRequest) (*UpdateEnvironmentVariableResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateEnvironmentVariable not implemented") +} +func (UnimplementedEnvironmentVariableServiceServer) DeleteEnvironmentVariable(context.Context, *DeleteEnvironmentVariableRequest) (*DeleteEnvironmentVariableResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteEnvironmentVariable not implemented") +} +func (UnimplementedEnvironmentVariableServiceServer) mustEmbedUnimplementedEnvironmentVariableServiceServer() { +} + +// UnsafeEnvironmentVariableServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EnvironmentVariableServiceServer will +// result in compilation errors. +type UnsafeEnvironmentVariableServiceServer interface { + mustEmbedUnimplementedEnvironmentVariableServiceServer() +} + +func RegisterEnvironmentVariableServiceServer(s grpc.ServiceRegistrar, srv EnvironmentVariableServiceServer) { + s.RegisterService(&EnvironmentVariableService_ServiceDesc, srv) +} + +func _EnvironmentVariableService_ListEnvironmentVariables_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListEnvironmentVariablesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EnvironmentVariableServiceServer).ListEnvironmentVariables(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitpod.v1.EnvironmentVariableService/ListEnvironmentVariables", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EnvironmentVariableServiceServer).ListEnvironmentVariables(ctx, req.(*ListEnvironmentVariablesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _EnvironmentVariableService_UpdateEnvironmentVariable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateEnvironmentVariableRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EnvironmentVariableServiceServer).UpdateEnvironmentVariable(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitpod.v1.EnvironmentVariableService/UpdateEnvironmentVariable", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EnvironmentVariableServiceServer).UpdateEnvironmentVariable(ctx, req.(*UpdateEnvironmentVariableRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _EnvironmentVariableService_DeleteEnvironmentVariable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteEnvironmentVariableRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EnvironmentVariableServiceServer).DeleteEnvironmentVariable(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitpod.v1.EnvironmentVariableService/DeleteEnvironmentVariable", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EnvironmentVariableServiceServer).DeleteEnvironmentVariable(ctx, req.(*DeleteEnvironmentVariableRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// EnvironmentVariableService_ServiceDesc is the grpc.ServiceDesc for EnvironmentVariableService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var EnvironmentVariableService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "gitpod.v1.EnvironmentVariableService", + HandlerType: (*EnvironmentVariableServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListEnvironmentVariables", + Handler: _EnvironmentVariableService_ListEnvironmentVariables_Handler, + }, + { + MethodName: "UpdateEnvironmentVariable", + Handler: _EnvironmentVariableService_UpdateEnvironmentVariable_Handler, + }, + { + MethodName: "DeleteEnvironmentVariable", + Handler: _EnvironmentVariableService_DeleteEnvironmentVariable_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "gitpod/v1/envvar.proto", +} diff --git a/components/public-api/go/v1/v1connect/envvar.connect.go b/components/public-api/go/v1/v1connect/envvar.connect.go new file mode 100644 index 00000000000000..1e9c63639d6366 --- /dev/null +++ b/components/public-api/go/v1/v1connect/envvar.connect.go @@ -0,0 +1,163 @@ +// Copyright (c) 2023 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License.AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: gitpod/v1/envvar.proto + +package v1connect + +import ( + context "context" + errors "errors" + connect_go "github.com/bufbuild/connect-go" + v1 "github.com/gitpod-io/gitpod/components/public-api/go/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect_go.IsAtLeastVersion0_1_0 + +const ( + // EnvironmentVariableServiceName is the fully-qualified name of the EnvironmentVariableService + // service. + EnvironmentVariableServiceName = "gitpod.v1.EnvironmentVariableService" +) + +// EnvironmentVariableServiceClient is a client for the gitpod.v1.EnvironmentVariableService +// service. +type EnvironmentVariableServiceClient interface { + // ListEnvironmentVariables returns all environment variables for the + // authenticated user. + // + // +return NOT_FOUND User does not have access to a workspace with the given + // ID +return NOT_FOUND Workspace does not exist + ListEnvironmentVariables(context.Context, *connect_go.Request[v1.ListEnvironmentVariablesRequest]) (*connect_go.Response[v1.ListEnvironmentVariablesResponse], error) + // UpdateEnvironmentVariable updates an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + UpdateEnvironmentVariable(context.Context, *connect_go.Request[v1.UpdateEnvironmentVariableRequest]) (*connect_go.Response[v1.UpdateEnvironmentVariableResponse], error) + // DeleteEnvironmentVariable deletes an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + DeleteEnvironmentVariable(context.Context, *connect_go.Request[v1.DeleteEnvironmentVariableRequest]) (*connect_go.Response[v1.DeleteEnvironmentVariableResponse], error) +} + +// NewEnvironmentVariableServiceClient constructs a client for the +// gitpod.v1.EnvironmentVariableService service. By default, it uses the Connect protocol with the +// binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the +// gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewEnvironmentVariableServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) EnvironmentVariableServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &environmentVariableServiceClient{ + listEnvironmentVariables: connect_go.NewClient[v1.ListEnvironmentVariablesRequest, v1.ListEnvironmentVariablesResponse]( + httpClient, + baseURL+"/gitpod.v1.EnvironmentVariableService/ListEnvironmentVariables", + opts..., + ), + updateEnvironmentVariable: connect_go.NewClient[v1.UpdateEnvironmentVariableRequest, v1.UpdateEnvironmentVariableResponse]( + httpClient, + baseURL+"/gitpod.v1.EnvironmentVariableService/UpdateEnvironmentVariable", + opts..., + ), + deleteEnvironmentVariable: connect_go.NewClient[v1.DeleteEnvironmentVariableRequest, v1.DeleteEnvironmentVariableResponse]( + httpClient, + baseURL+"/gitpod.v1.EnvironmentVariableService/DeleteEnvironmentVariable", + opts..., + ), + } +} + +// environmentVariableServiceClient implements EnvironmentVariableServiceClient. +type environmentVariableServiceClient struct { + listEnvironmentVariables *connect_go.Client[v1.ListEnvironmentVariablesRequest, v1.ListEnvironmentVariablesResponse] + updateEnvironmentVariable *connect_go.Client[v1.UpdateEnvironmentVariableRequest, v1.UpdateEnvironmentVariableResponse] + deleteEnvironmentVariable *connect_go.Client[v1.DeleteEnvironmentVariableRequest, v1.DeleteEnvironmentVariableResponse] +} + +// ListEnvironmentVariables calls gitpod.v1.EnvironmentVariableService.ListEnvironmentVariables. +func (c *environmentVariableServiceClient) ListEnvironmentVariables(ctx context.Context, req *connect_go.Request[v1.ListEnvironmentVariablesRequest]) (*connect_go.Response[v1.ListEnvironmentVariablesResponse], error) { + return c.listEnvironmentVariables.CallUnary(ctx, req) +} + +// UpdateEnvironmentVariable calls gitpod.v1.EnvironmentVariableService.UpdateEnvironmentVariable. +func (c *environmentVariableServiceClient) UpdateEnvironmentVariable(ctx context.Context, req *connect_go.Request[v1.UpdateEnvironmentVariableRequest]) (*connect_go.Response[v1.UpdateEnvironmentVariableResponse], error) { + return c.updateEnvironmentVariable.CallUnary(ctx, req) +} + +// DeleteEnvironmentVariable calls gitpod.v1.EnvironmentVariableService.DeleteEnvironmentVariable. +func (c *environmentVariableServiceClient) DeleteEnvironmentVariable(ctx context.Context, req *connect_go.Request[v1.DeleteEnvironmentVariableRequest]) (*connect_go.Response[v1.DeleteEnvironmentVariableResponse], error) { + return c.deleteEnvironmentVariable.CallUnary(ctx, req) +} + +// EnvironmentVariableServiceHandler is an implementation of the +// gitpod.v1.EnvironmentVariableService service. +type EnvironmentVariableServiceHandler interface { + // ListEnvironmentVariables returns all environment variables for the + // authenticated user. + // + // +return NOT_FOUND User does not have access to a workspace with the given + // ID +return NOT_FOUND Workspace does not exist + ListEnvironmentVariables(context.Context, *connect_go.Request[v1.ListEnvironmentVariablesRequest]) (*connect_go.Response[v1.ListEnvironmentVariablesResponse], error) + // UpdateEnvironmentVariable updates an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + UpdateEnvironmentVariable(context.Context, *connect_go.Request[v1.UpdateEnvironmentVariableRequest]) (*connect_go.Response[v1.UpdateEnvironmentVariableResponse], error) + // DeleteEnvironmentVariable deletes an environment variable for the + // authenticated user. + // + // workspace_id +return NOT_FOUND Workspace does not exist + DeleteEnvironmentVariable(context.Context, *connect_go.Request[v1.DeleteEnvironmentVariableRequest]) (*connect_go.Response[v1.DeleteEnvironmentVariableResponse], error) +} + +// NewEnvironmentVariableServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewEnvironmentVariableServiceHandler(svc EnvironmentVariableServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { + mux := http.NewServeMux() + mux.Handle("/gitpod.v1.EnvironmentVariableService/ListEnvironmentVariables", connect_go.NewUnaryHandler( + "/gitpod.v1.EnvironmentVariableService/ListEnvironmentVariables", + svc.ListEnvironmentVariables, + opts..., + )) + mux.Handle("/gitpod.v1.EnvironmentVariableService/UpdateEnvironmentVariable", connect_go.NewUnaryHandler( + "/gitpod.v1.EnvironmentVariableService/UpdateEnvironmentVariable", + svc.UpdateEnvironmentVariable, + opts..., + )) + mux.Handle("/gitpod.v1.EnvironmentVariableService/DeleteEnvironmentVariable", connect_go.NewUnaryHandler( + "/gitpod.v1.EnvironmentVariableService/DeleteEnvironmentVariable", + svc.DeleteEnvironmentVariable, + opts..., + )) + return "/gitpod.v1.EnvironmentVariableService/", mux +} + +// UnimplementedEnvironmentVariableServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedEnvironmentVariableServiceHandler struct{} + +func (UnimplementedEnvironmentVariableServiceHandler) ListEnvironmentVariables(context.Context, *connect_go.Request[v1.ListEnvironmentVariablesRequest]) (*connect_go.Response[v1.ListEnvironmentVariablesResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("gitpod.v1.EnvironmentVariableService.ListEnvironmentVariables is not implemented")) +} + +func (UnimplementedEnvironmentVariableServiceHandler) UpdateEnvironmentVariable(context.Context, *connect_go.Request[v1.UpdateEnvironmentVariableRequest]) (*connect_go.Response[v1.UpdateEnvironmentVariableResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("gitpod.v1.EnvironmentVariableService.UpdateEnvironmentVariable is not implemented")) +} + +func (UnimplementedEnvironmentVariableServiceHandler) DeleteEnvironmentVariable(context.Context, *connect_go.Request[v1.DeleteEnvironmentVariableRequest]) (*connect_go.Response[v1.DeleteEnvironmentVariableResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("gitpod.v1.EnvironmentVariableService.DeleteEnvironmentVariable is not implemented")) +} diff --git a/components/public-api/go/v1/v1connect/envvar.proxy.connect.go b/components/public-api/go/v1/v1connect/envvar.proxy.connect.go new file mode 100644 index 00000000000000..a5a13c803abc4e --- /dev/null +++ b/components/public-api/go/v1/v1connect/envvar.proxy.connect.go @@ -0,0 +1,50 @@ +// Copyright (c) 2023 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License.AGPL.txt in the project root for license information. + +// Code generated by protoc-proxy-gen. DO NOT EDIT. + +package v1connect + +import ( + context "context" + connect_go "github.com/bufbuild/connect-go" + v1 "github.com/gitpod-io/gitpod/components/public-api/go/v1" +) + +var _ EnvironmentVariableServiceHandler = (*ProxyEnvironmentVariableServiceHandler)(nil) + +type ProxyEnvironmentVariableServiceHandler struct { + Client v1.EnvironmentVariableServiceClient + UnimplementedEnvironmentVariableServiceHandler +} + +func (s *ProxyEnvironmentVariableServiceHandler) ListEnvironmentVariables(ctx context.Context, req *connect_go.Request[v1.ListEnvironmentVariablesRequest]) (*connect_go.Response[v1.ListEnvironmentVariablesResponse], error) { + resp, err := s.Client.ListEnvironmentVariables(ctx, req.Msg) + if err != nil { + // TODO(milan): Convert to correct status code + return nil, err + } + + return connect_go.NewResponse(resp), nil +} + +func (s *ProxyEnvironmentVariableServiceHandler) UpdateEnvironmentVariable(ctx context.Context, req *connect_go.Request[v1.UpdateEnvironmentVariableRequest]) (*connect_go.Response[v1.UpdateEnvironmentVariableResponse], error) { + resp, err := s.Client.UpdateEnvironmentVariable(ctx, req.Msg) + if err != nil { + // TODO(milan): Convert to correct status code + return nil, err + } + + return connect_go.NewResponse(resp), nil +} + +func (s *ProxyEnvironmentVariableServiceHandler) DeleteEnvironmentVariable(ctx context.Context, req *connect_go.Request[v1.DeleteEnvironmentVariableRequest]) (*connect_go.Response[v1.DeleteEnvironmentVariableResponse], error) { + resp, err := s.Client.DeleteEnvironmentVariable(ctx, req.Msg) + if err != nil { + // TODO(milan): Convert to correct status code + return nil, err + } + + return connect_go.NewResponse(resp), nil +} diff --git a/components/public-api/typescript/src/gitpod/v1/envvar_connect.ts b/components/public-api/typescript/src/gitpod/v1/envvar_connect.ts new file mode 100644 index 00000000000000..69445ea1d684c0 --- /dev/null +++ b/components/public-api/typescript/src/gitpod/v1/envvar_connect.ts @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2023 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License.AGPL.txt in the project root for license information. + */ + +// @generated by protoc-gen-connect-es v1.1.2 with parameter "target=ts" +// @generated from file gitpod/v1/envvar.proto (package gitpod.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { DeleteEnvironmentVariableRequest, DeleteEnvironmentVariableResponse, ListEnvironmentVariablesRequest, ListEnvironmentVariablesResponse, UpdateEnvironmentVariableRequest, UpdateEnvironmentVariableResponse } from "./envvar_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service gitpod.v1.EnvironmentVariableService + */ +export const EnvironmentVariableService = { + typeName: "gitpod.v1.EnvironmentVariableService", + methods: { + /** + * ListEnvironmentVariables returns all environment variables for the + * authenticated user. + * + * +return NOT_FOUND User does not have access to a workspace with the given + * ID +return NOT_FOUND Workspace does not exist + * + * @generated from rpc gitpod.v1.EnvironmentVariableService.ListEnvironmentVariables + */ + listEnvironmentVariables: { + name: "ListEnvironmentVariables", + I: ListEnvironmentVariablesRequest, + O: ListEnvironmentVariablesResponse, + kind: MethodKind.Unary, + }, + /** + * UpdateEnvironmentVariable updates an environment variable for the + * authenticated user. + * + * workspace_id +return NOT_FOUND Workspace does not exist + * + * @generated from rpc gitpod.v1.EnvironmentVariableService.UpdateEnvironmentVariable + */ + updateEnvironmentVariable: { + name: "UpdateEnvironmentVariable", + I: UpdateEnvironmentVariableRequest, + O: UpdateEnvironmentVariableResponse, + kind: MethodKind.Unary, + }, + /** + * DeleteEnvironmentVariable deletes an environment variable for the + * authenticated user. + * + * workspace_id +return NOT_FOUND Workspace does not exist + * + * @generated from rpc gitpod.v1.EnvironmentVariableService.DeleteEnvironmentVariable + */ + deleteEnvironmentVariable: { + name: "DeleteEnvironmentVariable", + I: DeleteEnvironmentVariableRequest, + O: DeleteEnvironmentVariableResponse, + kind: MethodKind.Unary, + }, + } +} as const; diff --git a/components/public-api/typescript/src/gitpod/v1/envvar_pb.ts b/components/public-api/typescript/src/gitpod/v1/envvar_pb.ts new file mode 100644 index 00000000000000..75c515a7a822b7 --- /dev/null +++ b/components/public-api/typescript/src/gitpod/v1/envvar_pb.ts @@ -0,0 +1,302 @@ +/** + * Copyright (c) 2023 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License.AGPL.txt in the project root for license information. + */ + +// @generated by protoc-gen-es v1.3.3 with parameter "target=ts" +// @generated from file gitpod/v1/envvar.proto (package gitpod.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message gitpod.v1.UserEnvironmentVariable + */ +export class UserEnvironmentVariable extends Message { + /** + * @generated from field: string id = 1; + */ + id = ""; + + /** + * @generated from field: string name = 2; + */ + name = ""; + + /** + * @generated from field: string value = 3; + */ + value = ""; + + /** + * @generated from field: string repository_pattern = 4; + */ + repositoryPattern = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.UserEnvironmentVariable"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "repository_pattern", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UserEnvironmentVariable { + return new UserEnvironmentVariable().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UserEnvironmentVariable { + return new UserEnvironmentVariable().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UserEnvironmentVariable { + return new UserEnvironmentVariable().fromJsonString(jsonString, options); + } + + static equals(a: UserEnvironmentVariable | PlainMessage | undefined, b: UserEnvironmentVariable | PlainMessage | undefined): boolean { + return proto3.util.equals(UserEnvironmentVariable, a, b); + } +} + +/** + * @generated from message gitpod.v1.ListEnvironmentVariablesRequest + */ +export class ListEnvironmentVariablesRequest extends Message { + /** + * @generated from field: optional string workspace_id = 1; + */ + workspaceId?: string; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.ListEnvironmentVariablesRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "workspace_id", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ListEnvironmentVariablesRequest { + return new ListEnvironmentVariablesRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ListEnvironmentVariablesRequest { + return new ListEnvironmentVariablesRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ListEnvironmentVariablesRequest { + return new ListEnvironmentVariablesRequest().fromJsonString(jsonString, options); + } + + static equals(a: ListEnvironmentVariablesRequest | PlainMessage | undefined, b: ListEnvironmentVariablesRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(ListEnvironmentVariablesRequest, a, b); + } +} + +/** + * @generated from message gitpod.v1.ListEnvironmentVariablesResponse + */ +export class ListEnvironmentVariablesResponse extends Message { + /** + * @generated from field: repeated gitpod.v1.UserEnvironmentVariable environment_variables = 1; + */ + environmentVariables: UserEnvironmentVariable[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.ListEnvironmentVariablesResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "environment_variables", kind: "message", T: UserEnvironmentVariable, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ListEnvironmentVariablesResponse { + return new ListEnvironmentVariablesResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ListEnvironmentVariablesResponse { + return new ListEnvironmentVariablesResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ListEnvironmentVariablesResponse { + return new ListEnvironmentVariablesResponse().fromJsonString(jsonString, options); + } + + static equals(a: ListEnvironmentVariablesResponse | PlainMessage | undefined, b: ListEnvironmentVariablesResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(ListEnvironmentVariablesResponse, a, b); + } +} + +/** + * @generated from message gitpod.v1.UpdateEnvironmentVariableRequest + */ +export class UpdateEnvironmentVariableRequest extends Message { + /** + * @generated from field: optional string envvar_name = 1; + */ + envvarName?: string; + + /** + * @generated from field: optional string envvar_value = 2; + */ + envvarValue?: string; + + /** + * @generated from field: optional string envvar_repository_pattern = 3; + */ + envvarRepositoryPattern?: string; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.UpdateEnvironmentVariableRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "envvar_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + { no: 2, name: "envvar_value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + { no: 3, name: "envvar_repository_pattern", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateEnvironmentVariableRequest { + return new UpdateEnvironmentVariableRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateEnvironmentVariableRequest { + return new UpdateEnvironmentVariableRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdateEnvironmentVariableRequest { + return new UpdateEnvironmentVariableRequest().fromJsonString(jsonString, options); + } + + static equals(a: UpdateEnvironmentVariableRequest | PlainMessage | undefined, b: UpdateEnvironmentVariableRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdateEnvironmentVariableRequest, a, b); + } +} + +/** + * @generated from message gitpod.v1.UpdateEnvironmentVariableResponse + */ +export class UpdateEnvironmentVariableResponse extends Message { + /** + * @generated from field: gitpod.v1.UserEnvironmentVariable environment_variable = 1; + */ + environmentVariable?: UserEnvironmentVariable; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.UpdateEnvironmentVariableResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "environment_variable", kind: "message", T: UserEnvironmentVariable }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateEnvironmentVariableResponse { + return new UpdateEnvironmentVariableResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateEnvironmentVariableResponse { + return new UpdateEnvironmentVariableResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdateEnvironmentVariableResponse { + return new UpdateEnvironmentVariableResponse().fromJsonString(jsonString, options); + } + + static equals(a: UpdateEnvironmentVariableResponse | PlainMessage | undefined, b: UpdateEnvironmentVariableResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdateEnvironmentVariableResponse, a, b); + } +} + +/** + * @generated from message gitpod.v1.DeleteEnvironmentVariableRequest + */ +export class DeleteEnvironmentVariableRequest extends Message { + /** + * @generated from field: string envvar_name = 1; + */ + envvarName = ""; + + /** + * @generated from field: string envvar_repository_pattern = 2; + */ + envvarRepositoryPattern = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.DeleteEnvironmentVariableRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "envvar_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "envvar_repository_pattern", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeleteEnvironmentVariableRequest { + return new DeleteEnvironmentVariableRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeleteEnvironmentVariableRequest { + return new DeleteEnvironmentVariableRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeleteEnvironmentVariableRequest { + return new DeleteEnvironmentVariableRequest().fromJsonString(jsonString, options); + } + + static equals(a: DeleteEnvironmentVariableRequest | PlainMessage | undefined, b: DeleteEnvironmentVariableRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(DeleteEnvironmentVariableRequest, a, b); + } +} + +/** + * @generated from message gitpod.v1.DeleteEnvironmentVariableResponse + */ +export class DeleteEnvironmentVariableResponse extends Message { + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "gitpod.v1.DeleteEnvironmentVariableResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeleteEnvironmentVariableResponse { + return new DeleteEnvironmentVariableResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeleteEnvironmentVariableResponse { + return new DeleteEnvironmentVariableResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeleteEnvironmentVariableResponse { + return new DeleteEnvironmentVariableResponse().fromJsonString(jsonString, options); + } + + static equals(a: DeleteEnvironmentVariableResponse | PlainMessage | undefined, b: DeleteEnvironmentVariableResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(DeleteEnvironmentVariableResponse, a, b); + } +} diff --git a/components/server/src/api/envvar-service-api.ts b/components/server/src/api/envvar-service-api.ts new file mode 100644 index 00000000000000..e81eb8ebbf5c23 --- /dev/null +++ b/components/server/src/api/envvar-service-api.ts @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2023 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License.AGPL.txt in the project root for license information. + */ + +import { Code, ConnectError, HandlerContext, ServiceImpl } from "@connectrpc/connect"; +import { EnvironmentVariableService as EnvironmentVariableServiceInterface } from "@gitpod/public-api/lib/gitpod/v1/envvar_connect"; +import { + ListEnvironmentVariablesRequest, + ListEnvironmentVariablesResponse, + UpdateEnvironmentVariableRequest, + UpdateEnvironmentVariableResponse, + DeleteEnvironmentVariableRequest, + DeleteEnvironmentVariableResponse, +} from "@gitpod/public-api/lib/gitpod/v1/envvar_pb"; +import { inject, injectable } from "inversify"; +import { EnvVarService } from "../user/env-var-service"; +import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter"; +import { UserEnvVar, UserEnvVarValue } from "@gitpod/gitpod-protocol"; + +@injectable() +export class EnvironmentVariableServiceAPI implements ServiceImpl { + @inject(EnvVarService) + private readonly envVarService: EnvVarService; + + @inject(PublicAPIConverter) + private readonly apiConverter: PublicAPIConverter; + + async listEnvironmentVariables( + req: ListEnvironmentVariablesRequest, + context: HandlerContext, + ): Promise { + // if (req.workspaceId) { + // const envVars = await this.envVarService.listUserEnvVars(context.user.id, context.user.id); + // } + + const userEnvVars = await this.envVarService.listUserEnvVars(context.user.id, context.user.id); + const response = new ListEnvironmentVariablesResponse(); + response.environmentVariables = userEnvVars.map((i) => this.apiConverter.toUserEnvironmentVariable(i)); + return response; + } + + async updateEnvironmentVariable( + req: UpdateEnvironmentVariableRequest, + context: HandlerContext, + ): Promise { + const variable: UserEnvVarValue = { + name: req.envvarName || "", + value: req.envvarValue || "", + repositoryPattern: req.envvarRepositoryPattern || "", + }; + const userEnvVars = await this.envVarService.listUserEnvVars(context.user.id, context.user.id); + if (userEnvVars.find((v) => v.name == req.envvarName && v.repositoryPattern == req.envvarRepositoryPattern)) { + await this.envVarService.updateUserEnvVar(context.user.id, context.user.id, variable); + } else { + await this.envVarService.addUserEnvVar(context.user.id, context.user.id, variable); + } + + req.envvarRepositoryPattern = UserEnvVar.normalizeRepoPattern(variable.repositoryPattern); + const updatedUserEnvVars = await this.envVarService.listUserEnvVars(context.user.id, context.user.id); + const updatedUserEnvVar = updatedUserEnvVars.find( + (v) => v.name === req.envvarName && v.repositoryPattern === req.envvarRepositoryPattern, + ); + if (!updatedUserEnvVar) { + throw new ConnectError("env variable not found", Code.Internal); + } + + const response = new UpdateEnvironmentVariableResponse(); + response.environmentVariable = this.apiConverter.toUserEnvironmentVariable(updatedUserEnvVar); + return response; + } + + async deleteEnvironmentVariable( + req: DeleteEnvironmentVariableRequest, + context: HandlerContext, + ): Promise { + const variable: UserEnvVarValue = { + name: req.envvarName, + value: "", + repositoryPattern: req.envvarRepositoryPattern, + }; + await this.envVarService.deleteUserEnvVar(context.user.id, context.user.id, variable); + + const response = new DeleteEnvironmentVariableResponse(); + return response; + } +} diff --git a/components/server/src/api/server.ts b/components/server/src/api/server.ts index 26710e7938e062..0f86846bad0396 100644 --- a/components/server/src/api/server.ts +++ b/components/server/src/api/server.ts @@ -19,6 +19,7 @@ import { OrganizationService } from "@gitpod/public-api/lib/gitpod/v1/organizati import { WorkspaceService } from "@gitpod/public-api/lib/gitpod/v1/workspace_connect"; import { ConfigurationService } from "@gitpod/public-api/lib/gitpod/v1/configuration_connect"; import { AuthProviderService } from "@gitpod/public-api/lib/gitpod/v1/authprovider_connect"; +import { EnvironmentVariableService } from "@gitpod/public-api/lib/gitpod/v1/envvar_connect"; import express from "express"; import * as http from "http"; import { decorate, inject, injectable, interfaces } from "inversify"; @@ -43,6 +44,7 @@ import { APIUserService as UserServiceAPI } from "./user"; import { WorkspaceServiceAPI } from "./workspace-service-api"; import { ConfigurationServiceAPI } from "./configuration-service-api"; import { AuthProviderServiceAPI } from "./auth-provider-service-api"; +import { EnvironmentVariableServiceAPI } from "./envvar-service-api"; import { Unauthenticated } from "./unauthenticated"; decorate(injectable(), PublicAPIConverter); @@ -59,6 +61,7 @@ export class API { @inject(OrganizationServiceAPI) private readonly organizationServiceApi: OrganizationServiceAPI; @inject(ConfigurationServiceAPI) private readonly configurationServiceApi: ConfigurationServiceAPI; @inject(AuthProviderServiceAPI) private readonly authProviderServiceApi: AuthProviderServiceAPI; + @inject(EnvironmentVariableServiceAPI) private readonly envvarServiceApi: EnvironmentVariableServiceAPI; @inject(StatsServiceAPI) private readonly tatsServiceApi: StatsServiceAPI; @inject(HelloServiceAPI) private readonly helloServiceApi: HelloServiceAPI; @inject(SessionHandler) private readonly sessionHandler: SessionHandler; @@ -111,6 +114,7 @@ export class API { service(OrganizationService, this.organizationServiceApi), service(ConfigurationService, this.configurationServiceApi), service(AuthProviderService, this.authProviderServiceApi), + service(EnvironmentVariableService, this.envvarServiceApi), ]) { router.service(type, new Proxy(impl, this.interceptService(type))); }