Skip to content

Commit f591de8

Browse files
Furistoflaming-codes
authored andcommitted
Make some workspace metadata properties optional
1 parent c121fa5 commit f591de8

File tree

8 files changed

+277
-232
lines changed

8 files changed

+277
-232
lines changed

components/ws-manager-api/core.proto

+4-4
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,11 @@ message WorkspaceMetadata {
467467
// This is primarily intended for annotating headless workspace loads.
468468
map<string, string> annotations = 4;
469469

470-
// team the workspace belongs to
471-
string team = 5;
470+
// team the workspace belongs to, if the workspace is not associated with a team, this property will be empty
471+
optional string team = 5;
472472

473-
// project the workspace belongs to
474-
string project = 6;
473+
// project the workspace belongs to, if the workspace is not associated with a project, this property will be empty
474+
optional string project = 6;
475475
}
476476

477477
// WorkspaceRuntimeInfo details the workspace's runtime, e.g. executing system, node other information

components/ws-manager-api/go/core.pb.go

+209-212
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ws-manager-api/go/core_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ws-manager-api/typescript/src/core_pb.d.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,15 @@ export class WorkspaceMetadata extends jspb.Message {
838838

839839
getAnnotationsMap(): jspb.Map<string, string>;
840840
clearAnnotationsMap(): void;
841-
getTeam(): string;
841+
842+
hasTeam(): boolean;
843+
clearTeam(): void;
844+
getTeam(): string | undefined;
842845
setTeam(value: string): WorkspaceMetadata;
843-
getProject(): string;
846+
847+
hasProject(): boolean;
848+
clearProject(): void;
849+
getProject(): string | undefined;
844850
setProject(value: string): WorkspaceMetadata;
845851

846852
serializeBinary(): Uint8Array;
@@ -860,8 +866,8 @@ export namespace WorkspaceMetadata {
860866
startedAt?: google_protobuf_timestamp_pb.Timestamp.AsObject,
861867

862868
annotationsMap: Array<[string, string]>,
863-
team: string,
864-
project: string,
869+
team?: string,
870+
project?: string,
865871
}
866872
}
867873

components/ws-manager-api/typescript/src/core_pb.js

+42-6
Original file line numberDiff line numberDiff line change
@@ -6833,15 +6833,15 @@ proto.wsman.WorkspaceMetadata.serializeBinaryToWriter = function(message, writer
68336833
if (f && f.getLength() > 0) {
68346834
f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
68356835
}
6836-
f = message.getTeam();
6837-
if (f.length > 0) {
6836+
f = /** @type {string} */ (jspb.Message.getField(message, 5));
6837+
if (f != null) {
68386838
writer.writeString(
68396839
5,
68406840
f
68416841
);
68426842
}
6843-
f = message.getProject();
6844-
if (f.length > 0) {
6843+
f = /** @type {string} */ (jspb.Message.getField(message, 6));
6844+
if (f != null) {
68456845
writer.writeString(
68466846
6,
68476847
f
@@ -6959,7 +6959,25 @@ proto.wsman.WorkspaceMetadata.prototype.getTeam = function() {
69596959
* @return {!proto.wsman.WorkspaceMetadata} returns this
69606960
*/
69616961
proto.wsman.WorkspaceMetadata.prototype.setTeam = function(value) {
6962-
return jspb.Message.setProto3StringField(this, 5, value);
6962+
return jspb.Message.setField(this, 5, value);
6963+
};
6964+
6965+
6966+
/**
6967+
* Clears the field making it undefined.
6968+
* @return {!proto.wsman.WorkspaceMetadata} returns this
6969+
*/
6970+
proto.wsman.WorkspaceMetadata.prototype.clearTeam = function() {
6971+
return jspb.Message.setField(this, 5, undefined);
6972+
};
6973+
6974+
6975+
/**
6976+
* Returns whether this field is set.
6977+
* @return {boolean}
6978+
*/
6979+
proto.wsman.WorkspaceMetadata.prototype.hasTeam = function() {
6980+
return jspb.Message.getField(this, 5) != null;
69636981
};
69646982

69656983

@@ -6977,7 +6995,25 @@ proto.wsman.WorkspaceMetadata.prototype.getProject = function() {
69776995
* @return {!proto.wsman.WorkspaceMetadata} returns this
69786996
*/
69796997
proto.wsman.WorkspaceMetadata.prototype.setProject = function(value) {
6980-
return jspb.Message.setProto3StringField(this, 6, value);
6998+
return jspb.Message.setField(this, 6, value);
6999+
};
7000+
7001+
7002+
/**
7003+
* Clears the field making it undefined.
7004+
* @return {!proto.wsman.WorkspaceMetadata} returns this
7005+
*/
7006+
proto.wsman.WorkspaceMetadata.prototype.clearProject = function() {
7007+
return jspb.Message.setField(this, 6, undefined);
7008+
};
7009+
7010+
7011+
/**
7012+
* Returns whether this field is set.
7013+
* @return {boolean}
7014+
*/
7015+
proto.wsman.WorkspaceMetadata.prototype.hasProject = function() {
7016+
return jspb.Message.getField(this, 6) != null;
69817017
};
69827018

69837019

components/ws-manager/pkg/manager/create.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,8 @@ func (m *Manager) newStartWorkspaceContext(ctx context.Context, req *api.StartWo
898898
wsk8s.WorkspaceIDLabel: req.Id,
899899
wsk8s.OwnerLabel: req.Metadata.Owner,
900900
wsk8s.MetaIDLabel: req.Metadata.MetaId,
901-
wsk8s.ProjectLabel: req.Metadata.Project,
902-
wsk8s.TeamLabel: req.Metadata.Team,
901+
wsk8s.ProjectLabel: req.Metadata.GetProject(),
902+
wsk8s.TeamLabel: req.Metadata.GetTeam(),
903903
wsk8s.TypeLabel: workspaceType,
904904
headlessLabel: fmt.Sprintf("%v", headless),
905905
markerLabel: "true",

components/ws-manager/pkg/manager/create_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import (
2121
config "github.com/gitpod-io/gitpod/ws-manager/api/config"
2222
)
2323

24+
var (
25+
team = "awesome"
26+
project = "gitpod"
27+
)
28+
2429
func TestCreateDefiniteWorkspacePod(t *testing.T) {
2530
type WorkspaceClass struct {
2631
DefaultTemplate *corev1.Pod `json:"defaultTemplate,omitempty"`
@@ -135,9 +140,10 @@ func TestCreateDefiniteWorkspacePod(t *testing.T) {
135140
Metadata: &api.WorkspaceMetadata{
136141
Owner: "tester",
137142
MetaId: "foobar",
138-
Team: "awesome",
139-
Project: "gitpod",
143+
Team: &team,
144+
Project: &project,
140145
},
146+
141147
ServicePrefix: "foobarservice",
142148
Spec: &spec,
143149
}

components/ws-manager/pkg/manager/manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (m *Manager) Close() {
151151

152152
// StartWorkspace creates a new running workspace within the manager's cluster
153153
func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceRequest) (res *api.StartWorkspaceResponse, err error) {
154-
owi := log.LogContext(req.Metadata.Owner, req.Metadata.MetaId, req.Id, req.Metadata.Project, req.Metadata.Team)
154+
owi := log.LogContext(req.Metadata.Owner, req.Metadata.MetaId, req.Id, req.Metadata.GetProject(), req.Metadata.GetTeam())
155155
clog := log.WithFields(owi)
156156
span, ctx := tracing.FromContext(ctx, "StartWorkspace")
157157
tracing.LogRequestSafe(span, req)

0 commit comments

Comments
 (0)