Skip to content

Commit cd19ba3

Browse files
committed
nit
1 parent 81d1654 commit cd19ba3

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

components/dashboard/src/service/json-rpc-envvar-client.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
4747
req: PartialMessage<UpdateUserEnvironmentVariableRequest>,
4848
): Promise<UpdateUserEnvironmentVariableResponse> {
4949
if (!req.envVarId) {
50-
throw new ConnectError("id is not set", Code.InvalidArgument);
50+
throw new ConnectError("envVarId is required", Code.InvalidArgument);
5151
}
5252

5353
const response = new UpdateUserEnvironmentVariableResponse();
@@ -81,7 +81,7 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
8181
req: PartialMessage<CreateUserEnvironmentVariableRequest>,
8282
): Promise<CreateUserEnvironmentVariableResponse> {
8383
if (!req.name || !req.value || !req.repositoryPattern) {
84-
throw new ConnectError("invalid argument", Code.InvalidArgument);
84+
throw new ConnectError("name, value and repositoryPattern are required", Code.InvalidArgument);
8585
}
8686

8787
const response = new CreateUserEnvironmentVariableResponse();
@@ -112,7 +112,7 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
112112
req: PartialMessage<DeleteUserEnvironmentVariableRequest>,
113113
): Promise<DeleteUserEnvironmentVariableResponse> {
114114
if (!req.envVarId) {
115-
throw new ConnectError("invalid argument", Code.InvalidArgument);
115+
throw new ConnectError("envVarId is required", Code.InvalidArgument);
116116
}
117117

118118
const variable: UserEnvVarValue = {
@@ -132,7 +132,7 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
132132
req: PartialMessage<ListConfigurationEnvironmentVariablesRequest>,
133133
): Promise<ListConfigurationEnvironmentVariablesResponse> {
134134
if (!req.configurationId) {
135-
throw new ConnectError("configurationId is not set", Code.InvalidArgument);
135+
throw new ConnectError("configurationId is required", Code.InvalidArgument);
136136
}
137137

138138
const result = new ListConfigurationEnvironmentVariablesResponse();
@@ -146,10 +146,10 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
146146
req: PartialMessage<UpdateConfigurationEnvironmentVariableRequest>,
147147
): Promise<UpdateConfigurationEnvironmentVariableResponse> {
148148
if (!req.envVarId) {
149-
throw new ConnectError("envVarId is not set", Code.InvalidArgument);
149+
throw new ConnectError("envVarId is required", Code.InvalidArgument);
150150
}
151151
if (!req.configurationId) {
152-
throw new ConnectError("configurationId is not set", Code.InvalidArgument);
152+
throw new ConnectError("configurationId is required", Code.InvalidArgument);
153153
}
154154

155155
const response = new UpdateConfigurationEnvironmentVariableResponse();
@@ -183,7 +183,7 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
183183
req: PartialMessage<CreateConfigurationEnvironmentVariableRequest>,
184184
): Promise<CreateConfigurationEnvironmentVariableResponse> {
185185
if (!req.configurationId || !req.name || !req.value) {
186-
throw new ConnectError("invalid argument", Code.InvalidArgument);
186+
throw new ConnectError("configurationId, name and value are required", Code.InvalidArgument);
187187
}
188188

189189
const response = new CreateConfigurationEnvironmentVariableResponse();
@@ -212,7 +212,7 @@ export class JsonRpcEnvvarClient implements PromiseClient<typeof EnvironmentVari
212212
req: PartialMessage<DeleteConfigurationEnvironmentVariableRequest>,
213213
): Promise<DeleteConfigurationEnvironmentVariableResponse> {
214214
if (!req.envVarId) {
215-
throw new ConnectError("invalid argument", Code.InvalidArgument);
215+
throw new ConnectError("envVarId is required", Code.InvalidArgument);
216216
}
217217

218218
await getGitpodService().server.deleteProjectEnvironmentVariable(req.envVarId);

components/gitpod-db/src/typeorm/user-db-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export class TypeORMUserDBImpl extends TransactionalDBImpl<UserDB> implements Us
416416
const envVarRepo = ctx.entityManager.getRepository<DBUserEnvVar>(DBUserEnvVar);
417417

418418
await envVarRepo.update(
419-
{ id: envVar.id, userId },
419+
{ id: envVar.id, userId, deleted: false },
420420
filter(envVar, (_, v) => v !== null && v !== undefined),
421421
);
422422

components/gitpod-db/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
33
* Licensed under the GNU Affero General Public License (AGPL).
44
* See License.AGPL.txt in the project root for license information.
55
*/

components/server/src/api/envvar-service-api.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
import { inject, injectable } from "inversify";
3232
import { EnvVarService } from "../user/env-var-service";
3333
import { PublicAPIConverter } from "@gitpod/gitpod-protocol/lib/public-api-converter";
34-
import { ProjectEnvVarWithValue, UserEnvVar, UserEnvVarValue } from "@gitpod/gitpod-protocol";
34+
import { ProjectEnvVarWithValue, UserEnvVarValue } from "@gitpod/gitpod-protocol";
3535
import { WorkspaceService } from "../workspace/workspace-service";
3636
import { ctxUserId } from "../util/request-context";
3737
import { validate as uuidValidate } from "uuid";
@@ -97,7 +97,6 @@ export class EnvironmentVariableServiceAPI implements ServiceImpl<typeof Environ
9797
value: req.value,
9898
repositoryPattern: req.repositoryPattern,
9999
};
100-
variable.repositoryPattern = UserEnvVar.normalizeRepoPattern(variable.repositoryPattern);
101100

102101
const result = await this.envVarService.addUserEnvVar(ctxUserId(), ctxUserId(), variable);
103102
response.environmentVariable = this.apiConverter.toUserEnvironmentVariable(result);
@@ -154,8 +153,6 @@ export class EnvironmentVariableServiceAPI implements ServiceImpl<typeof Environ
154153
throw new ConnectError("envVarId is required", Code.InvalidArgument);
155154
}
156155

157-
const response = new UpdateConfigurationEnvironmentVariableResponse();
158-
159156
const updatedProjectEnvVar = await this.envVarService.updateProjectEnvVar(ctxUserId(), req.configurationId, {
160157
id: req.envVarId,
161158
censored: req.admission
@@ -165,6 +162,7 @@ export class EnvironmentVariableServiceAPI implements ServiceImpl<typeof Environ
165162
: undefined,
166163
});
167164

165+
const response = new UpdateConfigurationEnvironmentVariableResponse();
168166
response.environmentVariable = this.apiConverter.toConfigurationEnvironmentVariable(updatedProjectEnvVar);
169167
return response;
170168
}
@@ -173,17 +171,16 @@ export class EnvironmentVariableServiceAPI implements ServiceImpl<typeof Environ
173171
req: CreateConfigurationEnvironmentVariableRequest,
174172
_: HandlerContext,
175173
): Promise<CreateConfigurationEnvironmentVariableResponse> {
176-
const response = new CreateConfigurationEnvironmentVariableResponse();
177-
178174
const variable: ProjectEnvVarWithValue = {
179175
name: req.name,
180176
value: req.value,
181177
censored: req.admission === EnvironmentVariableAdmission.PREBUILD ? true : false,
182178
};
183179

184180
const result = await this.envVarService.addProjectEnvVar(ctxUserId(), req.configurationId, variable);
185-
response.environmentVariable = this.apiConverter.toConfigurationEnvironmentVariable(result);
186181

182+
const response = new CreateConfigurationEnvironmentVariableResponse();
183+
response.environmentVariable = this.apiConverter.toConfigurationEnvironmentVariable(result);
187184
return response;
188185
}
189186

0 commit comments

Comments
 (0)