百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

conftest

> 云原生
开源

使用开放策略代理Rego查询语言,针对结构化配置数据编写测试。

3.2K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

使用开放策略代理Rego查询语言,针对结构化配置数据编写测试。

Conftest

Conftest 帮助你针对结构化配置数据编写测试。使用 Conftest,你可以为你的 Kubernetes 配置、Tekton 管道定义、Terraform 代码、Serverless 配置或任何其他配置文件编写测试。

Conftest 使用 Open Policy Agent 中的 Rego 语言来编写断言。你可以在 Open Policy Agent 文档的 Policy Language 部分中了解更多关于 Rego 的信息。

以下是一个快速示例。将以下内容保存为 policy/deployment.rego:

rego
package main

deny contains msg if {
  input.kind == "Deployment"
  not input.spec.template.spec.securityContext.runAsNonRoot

  msg := "Containers must not run as root"
}

deny contains msg if {
  input.kind == "Deployment"
  not input.spec.selector.matchLabels.app

  msg := "Containers must provide app label for pod selectors"
}

假设你在 deployment.yaml 中有一个 Kubernetes 部署,你可以这样运行 Conftest:

bash
$ conftest test deployment.yaml
FAIL - deployment.yaml - Containers must not run as root
FAIL - deployment.yaml - Containers must provide app label for pod selectors

2 tests, 0 passed, 0 warnings, 2 failures, 0 exceptions

Conftest 并非专属于 Kubernetes。它可以让你轻松地为各种不同格式的配置文件编写测试。请参阅文档中的安装说明以及更多关于功能特性的详细信息。

想为 Conftest 做贡献吗?

  • 请参阅 DEVELOPMENT.md 来构建和测试 Conftest 本身。
  • 请参阅 CONTRIBUTING.md 来开始贡献。

如有讨论和问题,欢迎加入 Open Policy Agent Slack 的 #opa-conftest 频道。

Issues· 44 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gokubernetesopen-policy-agentopenpolicyagentrego

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类云原生
定价开源

> 相关工具

K
Kubernetes
容器编排事实标准
H
Helm
Kubernetes 包管理器
S
seaweedfs
SeaweedFS is a distributed storage system for object storage (S3), file systems, and Iceberg tables,