From 4c8638c072b3f1cc5be116ebcf1f538c174ef395 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Fri, 22 Oct 2021 13:37:25 +0000 Subject: [PATCH] [registry-facade] Add desktop_ide_ref --- .../registry-facade-api/go/imagespec.pb.go | 69 +++++++++++-------- .../registry-facade-api/go/provider.pb.go | 4 +- .../registry-facade-api/imagespec.proto | 2 + .../pkg/registry/layersource.go | 12 ++++ .../registry-facade/pkg/registry/registry.go | 9 +++ 5 files changed, 65 insertions(+), 31 deletions(-) diff --git a/components/registry-facade-api/go/imagespec.pb.go b/components/registry-facade-api/go/imagespec.pb.go index be45e4d54c09f8..337e6558db6fb9 100644 --- a/components/registry-facade-api/go/imagespec.pb.go +++ b/components/registry-facade-api/go/imagespec.pb.go @@ -4,8 +4,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.15.5 +// protoc-gen-go v1.27.1 +// protoc v3.17.3 // source: imagespec.proto package api @@ -36,6 +36,8 @@ type ImageSpec struct { IdeRef string `protobuf:"bytes,2,opt,name=ide_ref,json=ideRef,proto3" json:"ide_ref,omitempty"` // content_layer describe the last few layers which provide the workspace's content ContentLayer []*ContentLayer `protobuf:"bytes,3,rep,name=content_layer,json=contentLayer,proto3" json:"content_layer,omitempty"` + // desktop_ide_ref point to an image denotign the desktop IDE to use + DesktopIdeRef string `protobuf:"bytes,4,opt,name=desktop_ide_ref,json=desktopIdeRef,proto3" json:"desktop_ide_ref,omitempty"` } func (x *ImageSpec) Reset() { @@ -91,6 +93,13 @@ func (x *ImageSpec) GetContentLayer() []*ContentLayer { return nil } +func (x *ImageSpec) GetDesktopIdeRef() string { + if x != nil { + return x.DesktopIdeRef + } + return "" +} + // ContentLayer is a layer that provides a workspace's content type ContentLayer struct { state protoimpl.MessageState @@ -318,7 +327,7 @@ var File_imagespec_proto protoreflect.FileDescriptor var file_imagespec_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x66, 0x61, 0x63, 0x61, 0x64, - 0x65, 0x22, 0x82, 0x01, 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x53, 0x70, 0x65, 0x63, 0x12, + 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x53, 0x70, 0x65, 0x63, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x66, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x64, 0x65, @@ -326,32 +335,34 @@ var file_imagespec_proto_rawDesc = []byte{ 0x61, 0x79, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x22, 0x92, 0x01, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x3c, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x72, - 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x06, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x43, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x8a, 0x01, 0x0a, 0x12, - 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, - 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, - 0x64, 0x69, 0x66, 0x66, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, - 0x69, 0x66, 0x66, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x2e, 0x0a, 0x12, 0x44, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x18, - 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x31, 0x5a, 0x2f, 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, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2d, 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, + 0x70, 0x5f, 0x69, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x49, 0x64, 0x65, 0x52, 0x65, 0x66, 0x22, 0x92, + 0x01, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, + 0x3c, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x22, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, + 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, + 0x79, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x12, 0x3c, 0x0a, + 0x06, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, 0x2e, 0x44, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, + 0x72, 0x48, 0x00, 0x52, 0x06, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x73, + 0x70, 0x65, 0x63, 0x22, 0x8a, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, + 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, + 0x67, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x69, 0x66, 0x66, 0x5f, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x66, 0x66, 0x49, 0x64, 0x12, 0x1d, 0x0a, + 0x0a, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, + 0x22, 0x2e, 0x0a, 0x12, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x42, 0x31, 0x5a, 0x2f, 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, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2d, 0x66, 0x61, 0x63, 0x61, 0x64, 0x65, 0x2f, + 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/components/registry-facade-api/go/provider.pb.go b/components/registry-facade-api/go/provider.pb.go index b592c1ee5b9a85..b6e6e0abadd06f 100644 --- a/components/registry-facade-api/go/provider.pb.go +++ b/components/registry-facade-api/go/provider.pb.go @@ -4,8 +4,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.15.5 +// protoc-gen-go v1.27.1 +// protoc v3.17.3 // source: provider.proto package api diff --git a/components/registry-facade-api/imagespec.proto b/components/registry-facade-api/imagespec.proto index 6915179b1c6543..74fd67d3ef19fc 100644 --- a/components/registry-facade-api/imagespec.proto +++ b/components/registry-facade-api/imagespec.proto @@ -12,6 +12,8 @@ message ImageSpec { string ide_ref = 2; // content_layer describe the last few layers which provide the workspace's content repeated ContentLayer content_layer = 3; + // desktop_ide_ref point to an image denotign the desktop IDE to use + string desktop_ide_ref = 4; } // ContentLayer is a layer that provides a workspace's content diff --git a/components/registry-facade/pkg/registry/layersource.go b/components/registry-facade/pkg/registry/layersource.go index 29834d83156139..2ed98400d1ccc4 100644 --- a/components/registry-facade/pkg/registry/layersource.go +++ b/components/registry-facade/pkg/registry/layersource.go @@ -394,6 +394,9 @@ func (src *SpecMappedImagedSource) Envs(ctx context.Context, spec *api.ImageSpec if err != nil { return nil, err } + if lsrc == nil { + return []EnvModifier{}, nil + } return lsrc.Envs(ctx, spec) } @@ -403,6 +406,9 @@ func (src *SpecMappedImagedSource) GetLayer(ctx context.Context, spec *api.Image if err != nil { return nil, err } + if lsrc == nil { + return []AddonLayer{}, nil + } return lsrc.GetLayer(ctx, spec) } @@ -412,6 +418,9 @@ func (src *SpecMappedImagedSource) HasBlob(ctx context.Context, spec *api.ImageS if err != nil { return false } + if lsrc == nil { + return false + } return lsrc.HasBlob(ctx, spec, dgst) } @@ -431,6 +440,9 @@ func (src *SpecMappedImagedSource) getDelegate(ctx context.Context, spec *api.Im if err != nil { return nil, err } + if ref == "" { + return nil, nil + } if s, ok := src.cache.Get(ref); ok { return s.(LayerSource), nil diff --git a/components/registry-facade/pkg/registry/registry.go b/components/registry-facade/pkg/registry/registry.go index 7fae9ba6ee3ac6..5e16d6abe91457 100644 --- a/components/registry-facade/pkg/registry/registry.go +++ b/components/registry-facade/pkg/registry/registry.go @@ -105,6 +105,15 @@ func NewRegistry(cfg config.Config, newResolver ResolverProvider, reg prometheus } layerSources = append(layerSources, ideLayerSource) + desktopIdeRefSource := func(s *api.ImageSpec) (ref string, err error) { + return s.DesktopIdeRef, nil + } + desktopIdeLayerSource, err := NewSpecMappedImageSource(newResolver, desktopIdeRefSource) + if err != nil { + return nil, err + } + layerSources = append(layerSources, desktopIdeLayerSource) + log.Info("preparing static layer") staticLayer := NewRevisioningLayerSource(CompositeLayerSource{}) layerSources = append(layerSources, staticLayer)