首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将Visual代码扩展重新打包到带有自己的依赖项集的Che-Theia插件中

如何将Visual代码扩展重新打包到带有自己的依赖项集的Che-Theia插件中
EN

Stack Overflow用户
提问于 2021-01-27 12:28:15
回答 1查看 327关注 0票数 0

我正在尝试将Visual代码扩展重新打包到Eclipse中,作为Che-Theia插件。插入式从Ansible文件中提取源代码度量,如下所示:

它通过执行用Python编写的工具(即可能计量 )的命令行来做到这一点,该命令行必须安装在用户的环境中。因此,我不能将这种依赖添加到VSC扩展的package.json中。相反,用户必须将其安装在Eclipse工作区上。不过,我希望Eclipse用户在使用扩展时不需要安装依赖项。集装箱看起来是要走的路。

我有下面的Eclipse

Eclipse Che DevFile

代码语言:javascript
复制
apiVersion: 1.0.0
metadata:
  name: python-bd3zh
attributes:
  persistVolumes: 'false'
projects:
  - name: python-hello-world
    source:
      location: 'https://github.com/che-samples/python-hello-world.git'
      type: git
      branch: master
components:
  - type: chePlugin
    reference: 'https://raw.githubusercontent.com/radon-h2020/radon-plugin-registry/master/radon/radon-defect-predictor/latest/meta.yaml'
    alias: radon-dpt

日食文档说,“要将VS代码扩展重新打包为带有自己的依赖项集的Che-Theia插件,将依赖项打包到容器中。”容器可以添加到chePlugin引用的关键字下的元数据中

代码语言:javascript
复制
spec:
  containers:                                                   
    - image:                                                    
      memoryLimit:                                              
      memoryRequest:                                            
      cpuLimit:                                                 
      cpuRequest:

因此,我的插件元数据(meta.yaml)如下:

meta.yaml

代码语言:javascript
复制
apiVersion: v2
publisher: radon
name: radon-defect-predictor
version: 0.0.5
type: VS Code extension
displayName: RADON-h2020 Defect Predictor
title: A Defect Predictor for Infrastructure-as-Code by RADON
description: A customized extension for analyzing the defectiveness of IaC blueprints
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
repository: https://github.com/radon-h2020/radon-defect-prediction-plugin
category: Other
spec:
  containers:                                                   
    - image: stefadp/radon-dpt-plugin
  extensions:
    - https://raw.githubusercontent.com/radon-h2020/radon-defect-prediction-plugin/master/radon-defect-predictor-0.0.5.vsix

其中,映像stefadp/radon插件构建在以下Dockerfile之上:

Dockerfile

代码语言:javascript
复制
FROM ubuntu:latest

RUN apt-get update \
  && apt-get install -y python3-pip python3-dev \
  && cd /usr/local/bin \
  && ln -s /usr/bin/python3 python \
  && pip3 install --upgrade pip

RUN pip3 install ansiblemetrics

但是,当我在Eclipse中运行工作区时,我观察到以下错误:

代码语言:javascript
复制
pulling image "quay.io/eclipse/che-plugin-metadata-broker:v3.4.0"
Successfully pulled image "quay.io/eclipse/che-plugin-metadata-broker:v3.4.0"
Created container
Started container
Starting plugin metadata broker
List of plugins and editors to install
- radon/radon-defect-predictor/0.0.6 - A customized extension for analyzing the defectiveness of IaC blueprints
- eclipse/che-workspace-telemetry-woopra-plugin/0.0.1 - Telemetry plugin to send information to Woopra
- eclipse/che-machine-exec-plugin/7.24.2 - Che Plug-in with che-machine-exec service to provide creation terminal or tasks for Eclipse Che workspace containers.
- eclipse/che-theia/7.24.2 - Eclipse Theia
All plugin metadata has been successfully processed
pulling image "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.24.2"
Successfully pulled image "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.24.2"
Created container
Started container
pulling image "quay.io/eclipse/che-plugin-artifacts-broker:v3.4.0"
Successfully pulled image "quay.io/eclipse/che-plugin-artifacts-broker:v3.4.0"
Created container
Started container
Starting plugin artifacts broker
Cleaning /plugins dir
Processing plugin radon/radon-defect-predictor/0.0.6
  Installing plugin extension 1/1
    Downloading plugin from https://raw.githubusercontent.com/radon-h2020/radon-plugin-registry/master/radon/radon-defect-predictor/0.0.6/radon-defect-predictor-0.0.6.vsix
Saving log of installed plugins
All plugin artifacts have been successfully downloaded
pulling image "quay.io/eclipse/che-jwtproxy:0.10.0"
Successfully pulled image "quay.io/eclipse/che-jwtproxy:0.10.0"
Created container
Started container
pulling image "stefadp/radon-dpt-plugin"
Successfully pulled image "stefadp/radon-dpt-plugin"
Created container
Started container
pulling image "quay.io/eclipse/che-workspace-telemetry-woopra-plugin:latest"
Successfully pulled image "quay.io/eclipse/che-workspace-telemetry-woopra-plugin:latest"
Created container
Started container
pulling image "quay.io/eclipse/che-machine-exec:7.24.2"
Successfully pulled image "quay.io/eclipse/che-machine-exec:7.24.2"
Created container
Started container
pulling image "quay.io/eclipse/che-theia:7.24.2"

Error: Failed to run the workspace: "The following containers have terminated:
nt0: reason = 'Completed', exit code = 0, message = 'null'"

你有什么提示吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-27 17:06:09

您必须自定义您的码头形象,才能在侧面集装箱工作。作为一个例子,您可以查看sidecars:https://github.com/eclipse/che-plugin-registry/blob/master/CONTRIBUTE.md#sidecars中已在Che中使用的图像

尝试创建下一个结构:

代码语言:javascript
复制
radon
  etc
    entrypoint.sh
  Dockerfile

entrypoint.sh的内容如下:

代码语言:javascript
复制
#!/bin/sh
set -e
set -x

USER_ID=$(id -u)
export USER_ID
GROUP_ID=$(id -g)
export GROUP_ID

if ! whoami >/dev/null 2>&1; then
    echo "${USER_NAME:-user}:x:${USER_ID}:0:${USER_NAME:-user} user:${HOME}:/bin/sh" >> /etc/passwd
fi

# Grant access to projects volume in case of non root user with sudo rights
if [ "${USER_ID}" -ne 0 ] && command -v sudo >/dev/null 2>&1 && sudo -n true > /dev/null 2>&1; then
    sudo chown "${USER_ID}:${GROUP_ID}" /projects
fi

exec "$@"

Dockerfile是:

代码语言:javascript
复制
FROM ubuntu:latest

ENV HOME=/home/theia

RUN mkdir /projects ${HOME} && \
    # Change permissions to let any arbitrary user
    for f in "${HOME}" "/etc/passwd" "/projects"; do \
      echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \
      chmod -R g+rwX ${f}; \
    done

RUN apt-get update \
  && apt-get install -y python3-pip python3-dev \
  && cd /usr/local/bin \
  && ln -s /usr/bin/python3 python \
  && pip3 install --upgrade pip

RUN pip3 install ansiblemetrics

ADD etc/entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}

然后构建这个Dockerfile并在插件meta.yaml中使用它

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65919180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档