代码之家  ›  专栏  ›  技术社区  ›  Abdennour TOUMI

芭蕾舞演员与库伯内特斯在视觉代码中的“未定义包”

  •  1
  • Abdennour TOUMI  · 技术社区  · 7 年前

    Ballerina extension 已在可视化代码中成功安装。 我也配置了 ballerina.home 指向已安装的包

    ballerina.home = "/Library/Ballerina/ballerina-0.975.1"
    

    可视化代码正在正确生成。不过,当我介绍 @kubernetes:* 注释:

    import ballerina/http;
    import ballerina/log;
    
    @kubernetes:Deployment {
        enableLiveness: true,
        image: "ballerina/ballerina-platform",
        name: "ballerina-abdennour-demo"
    }
    
    @kubernetes:Service {
        serviceType: "NodePort",
        name: "ballerina-abdennour-demo"
    
    }
    service<http:Service> hello bind { port: 9090 } {
        sayHello (endpoint caller, http:Request request) {
            http:Response res = new;
            res.setPayload("Hello World from Ballerina Service");
            caller ->respond(res) but { error e => log:printError("Error sending response", err = e)};
    
        }
    }
    

    VisualCode报告错误:

    undefined package "kubernetes"
    undefined annotation "Deployment"
    

    不过,我已经启动并运行minikube,我不知道是否需要另一个扩展,所以VisualCode可以检测正在运行的集群?

    还是缺少一个包,应该安装在Ballerina SDK/平台中?

    更新

    我在跑步 ballerina build file.bal ,我可以看到以下错误:

    enter image description here

    有什么想法吗?

    2 回复  |  直到 7 年前
        1
  •  4
  •   Abdennour TOUMI    7 年前

    解决了的!只需添加 import 文件开头的指令

    import ballerinax/kubernetes;
    

    注意,是的 ballerinax/kubernetes 而不是 ballerina/kubernetes (添加 x )

        2
  •  2
  •   mdaniel    7 年前

    The fine manual 非常清楚地表明,必须像导入其他任何包一样导入kubernetes包。我同意这对他们来说是一个错误信息,所以请在他们的回购协议中提交一个错误来解释如何改进你的体验