本站支持搜索的镜像仓库:Docker Hub、gcr.io、ghcr.io、quay.io、k8s.gcr.io、registry.gcr.io、elastic.co、mcr.microsoft.com
SkyWalking Eyes 是一个功能全面的许可证工具,旨在帮助开发团队确保源代码的许可证合规性。它能够检查源代码文件中的许可证头是否正确,自动修复缺失或不正确的许可证头,并解析项目依赖项的许可证信息,进行兼容性检查。该工具支持多种使用方式,包括 GitHub Actions 集成、Docker 镜像运行以及本地编译执行,适用于各类开源和商业项目的许可证管理流程。
在 GitHub Actions 工作流中添加步骤,实现代码提交时自动检查许可证头:
- name: 检查许可证头 uses: apache/skywalking-eyes@main # 建议使用具体版本号而非main分支 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 如需在PR上评论检查结果则必须设置 # with: # 可选:设置日志级别,默认info # log: debug # 可选:指定配置文件路径,默认.licenserc.yaml # config: .licenserc.yaml
在项目根目录创建 .licenserc.yaml 配置文件,Apache 软件基金会项目可使用以下基础配置:
header: license: spdx-id: Apache-2.0 copyright-owner: Apache Software Foundation paths-ignore: - 'dist' - 'licenses' - '**/*.md' - 'LICENSE' - 'NOTICE' comment: on-failure
完整配置说明参见 配置部分。
使用 Docker 镜像执行许可证头检查和修复:
# 检查许可证头 docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header check # 修复许可证头 docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix
对于希望测试 main 分支最新代码的用户和开发者,每个 main 分支提交会发布镜像到 GitHub Container Registry,标记为提交 SHA 值,最新提交同时标记为 latest。
注意:这些镜像非 Apache 官方发布版本。官方发布请参考 下载页面 获取二进制文件,或 Docker Hub 获取官方镜像。
# 检查许可证头(最新代码镜像) docker run -it --rm -v $(pwd):/github/workspace ghcr.io/apache/skywalking-eyes/license-eye header check # 修复许可证头(最新代码镜像) docker run -it --rm -v $(pwd):/github/workspace ghcr.io/apache/skywalking-eyes/license-eye header fix
手动编译并使用:
# 克隆仓库 git clone [***] cd skywalking-eyes # 编译 make build
bin/darwin/license-eye -c test/testdata/.licenserc_for_test_check.yaml header check INFO 从文件加载配置: test/testdata/.licenserc_for_test_check.yaml INFO 共检查30个文件,有效: 12, 无效: 12, 忽略: 6, 已修复: 0 ERROR 以下文件缺少有效的许可证头: test/testdata/include_test/without_license/testcase.go test/testdata/include_test/without_license/testcase.graphql ... exit status 1
bin/darwin/license-eye -c test/testdata/.licenserc_for_test_fix.yaml header fix INFO 从文件加载配置: test/testdata/.licenserc_for_test_fix.yaml INFO 共检查20个文件,有效: 10, 无效: 10, 忽略: 0, 已修复: 10
辅助人工审计依赖项许可证,命令始终返回0:
bin/darwin/license-eye -c test/testdata/.licenserc_for_test_check.yaml dep resolve INFO 未设置GITHUB_TOKEN,license-eye不会在PR上评论 INFO 从文件加载配置: test/testdata/.licenserc_for_test_check.yaml WARNING 无法解析依赖项许可证: gopkg.in/yaml.v3 cannot identify license content 依赖项 | 许可证 ------------------------------------------- | ------------ github.com/bmatcuk/doublestar/v2 | MIT github.com/sirupsen/logrus | MIT ... gopkg.in/yaml.v3 | Unknown ERROR 无法识别以下包的许可证: gopkg.in/yaml.v3
自动检查依赖项许可证兼容性,发现不兼容许可证时返回1:
bin/darwin/license-eye -c test/testdata/.licenserc_for_test_check.yaml dep check INFO 未设置GITHUB_TOKEN,license-eye不会在PR上评论 INFO 从文件加载配置: .licenserc.yaml WARNING 无法解析依赖项许可证 <github.com/gogo/protobuf>: cannot identify license content ... ERROR 以下许可证与主许可证Apache-2.0不兼容: License: Unknown Dependency: github.com/gogo/protobuf ... exit status 1
完整配置文件示例:
header: # <1> license: spdx-id: Apache-2.0 # <2> copyright-owner: Apache Software Foundation # <3> content: | # <4> Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [***] Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. pattern: | # <5> Licensed to the Apache Software Foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The Apache Software Foundation licenses this file to you under the Apache License, Version 2.0 \(the "License"\); you may not use this file except in compliance with the License. You may obtain a copy of the License at [***] Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. paths: # <6> - '**' paths-ignore: # <7> - 'dist' - 'licenses' - '**/*.md' - '**/testdata/**' - '**/go.mod' - '**/go.sum' - 'LICENSE' - 'NOTICE' - '**/assets/languages.yaml' - '**/assets/assets.gen.go' comment: on-failure # <8> dependency: # <9> files: # <10> - go.mod
header 部分:源代码许可证头的配置。license.spdx-id:许可证的 SPDX ID,使用标准SPDX许可证时可简化配置,无需复制完整许可证内容,fix命令会使用此许可证模板插入头信息。license.copyright-owner:版权所有者,用于替换SPDX许可证模板中的[owner]占位符。license.content:自定义许可证文本,当不使用标准许可证时可在此粘贴,fix命令会使用此内容插入头信息。若同时指定content和spdx-id,content优先级更高。license.pattern:可选正则表达式,当许可证头与content或SPDX标准文本不完全一致时,用于匹配许可证文本。paths:需要检查(和修复)的路径列表,默认['**'],支持**/*.md、**/bin/**等格式。paths-ignore:忽略检查的路径列表,默认包含.git目录和.gitignore中的内容。comment:PR评论触发条件,可选on-failure(失败时)、always(始终)或never(从不)。除never外,需设置GITHUB_TOKEN环境变量。dependency部分:依赖项许可证解析的配置。dependency.files:声明项目依赖的文件列表,如Go项目的go.mod、Maven项目的pom.xml等,相对路径相对于.licenserc.yaml。注意:当
spdx-id为Apache-2.0且所有者为Apache Software Foundation时,内容将使用ASF专用许可证文本;其他情况使用标准许可证文本。
header check 命令理论上支持所有文件类型,header fix 命令支持的文件类型可在 languages.yaml 中查看。若语言配置中comment_style_id非空且在 comment styles文件 中定义,则支持fix命令。
Apache License 2.0
skywalking 频道,链接失效时可在 Apache INFRA WIKI 获取最新邀请链接。免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录方式配置轩辕镜像加速服务,包含7个详细步骤
在 Linux 系统上配置轩辕镜像源,支持主流发行版
在 Docker Desktop 中配置轩辕镜像加速,适用于桌面系统
在 Docker Compose 中使用轩辕镜像加速,支持容器编排
在 k8s 中配置 containerd 使用轩辕镜像加速
在宝塔面板中配置轩辕镜像加速,提升服务器管理效率
在 Synology 群晖NAS系统中配置轩辕镜像加速
在飞牛fnOS系统中配置轩辕镜像加速
在极空间NAS中配置轩辕镜像加速
在爱快ikuai系统中配置轩辕镜像加速
在绿联NAS系统中配置轩辕镜像加速
在威联通NAS系统中配置轩辕镜像加速
在 Podman 中配置轩辕镜像加速,支持多系统
配置轩辕镜像加速9大主流镜像仓库,包含详细配置步骤
无需登录即可使用轩辕镜像加速服务,更加便捷高效
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429