opa example
package kubernetes.validating.existence
# This definition checks if the costcenter label is not provided. Each rule definition
# contributes to the set of error messages.
#赋值语句
a := 1
a2 = 1
#
#比较语句
#example 虚拟文档 当一个key不存在的时候
deny[msg] {
# The `not` keyword turns an undefined statement into a true statement. If any
# of the keys are missing, this statement will be true.
not input.request.object.metadata.labels.costcenter
msg := "每个资源必须搭配一个costcenter标签"
}
#example 虚拟文档 当一个key存在,并且输出key值
deny[msg] {
# The `not` keyword turns an undefined statement into a true statement. If any
# of the keys are missing, this statement will be true.
input.request.kind.kind
msg := "每个资源必须搭配一个costcenter标签"
}
#example 允许规则
allow {
true
}
#检测镜像是否来自hooli.com
deny[msg] {
input.request.kind.kind == "Pod"
# some 关键字作用用于申明container本地变量
# in作用为循环 用于循环遍历containers
some container in input.request.object.spec.containers
not startswith(container.image, "hooli.com/")
msg := sprintf("Image '%v' comes from untrusted registry", [container.image])
}
#检测某个类型是否大于0
deny[msg] {
# The `not` keyword turns an undefined statement into a true statement. If any
# of the keys are missing, this statement will be true.
count(input.request.kind) > 0
msg := "Every resource must have a costcenter label"
}
#检测cpu
some container in input.spec.containers
not container.resources.requests.cpu
#根据yaml中的key读取出来value
keykubernetes.annotations["secxxxxx"]
#不能使用not来对true和false判断来取反,只能用于集合
例如
des[a]{
a xxx
}
但是不能
check{
}
not check
#使用in来判断某键下面是否有key值
"kube-apiserver" in kubernetes.containers[_].command[_]
spec:
containers:
- command:
- kube-apiserver
- --anonymous-auth=true
for循环的写法
some container in input.request.object.spec.containers
split(container.image,".")[1] == "123"
msg := sprintf("Image '%v' comes from untrusted registry", [container.image])
opa example相关推荐
- SAP UI5 初学者教程之二十八 - SAP UI5 应用的集成测试工具 OPA 介绍试读版
一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...
- SAP UI5 应用开发教程之二十八 - SAP UI5 应用的集成测试工具 OPA 介绍
本教程前一步骤,我们介绍了 SAP UI5 单元测试工具 QUnit 的使用方法.本步骤介绍测试金字塔模型中位于单元测试上层的集成测试在 SAP UI5 中的实现工具:OPA. 本步骤对应的源代码位于 ...
- OPA Quality Report in Jenkins Ben - 到哪里能看到我们的OPA Test在Jenkins Server上运行的情况
Created by Wang, Jerry, last modified on Jul 19, 2016 我们每次提交代码的时候触发的Voter Job都会跑一次OPA并且记录结果(前段时间可能DL ...
- SAP ui5 单元测试框架 - OPA
Sent: Monday, July 4, 2016 6:41 PM 本地eclipse复现错误的步骤如下: 修改cus.crm.lead项目的pom.xml的参数如下: 1.10.0-SNAPSHO ...
- Solution for Lead OPA test error ( add button clicked after cancel button )
改了Lead后遇到OPA的test failure: 问题的表现是我们的test code里点了cancel button之后,再点Add button,这行语句报错:在dialog里找不到这个期望的 ...
- why My Lead OPA test add Lead fails
When you perform OPA test for my lead application, test case "add Lead" via this url: It w ...
- k8s访问控制--理解RBAC和OPA
1. RBAC–基于角色的访问控制 1.1 Kubernetes基于意图的声明式API Kubernetes API的设计与大多数现代API不同.它是基于意图的,这意味着使用API的人考虑的是他们想要 ...
- 武夫提笔——席卷世界Nodejs之初步对比:与opa各占几分春色?
Node 近年来风卷残云,在世界各地风起云涌.进入新公司后,阴差阳错作为一个后端工程师开启了猛攻node的进程.不想,进展神速,现在已在node技术栈上开发出了公司的即时消息系统.在安营扎寨的那些日夜 ...
- 激光雷达技术路线:机械式、MEMS是主流,OPA、Flash、FMCW发展空间大
--激光雷达是通过发射激光束来探测物体与传感器之间精准距离的主动测量装置,包含发射单元.接收单元.扫描单元以及数据处理单元.激光雷达通过激光器和探测器组成的收发阵列,结合光束扫描,可以对广义机器人所处 ...
- UI5(十一)单元测试、与OPA的集成测试、Debugging 工具
单元测试 文件夹结构 我们在测试文件夹和模型子文件夹下添加一个新的文件夹单元,在其中放置单元测试.文件夹结构与应用程序结构相匹配,可以很容易地找到相应的单元测试 webapp/test/unit/mo ...
最新文章
- win10 hao123劫持html文件,Win10 edge主页被hao123劫持如何解决|edge主页被hao123劫持的解决方法...
- 【随笔】如何快速转载CSDN中的博客
- 线段树segment_tree go语言实现
- 【Python】20个Pandas数据实战案例,干货多多
- leetcode 160. 相交链表(双指针)
- 招聘贴---这个很重要嘛
- Session重点整理
- 计算机网络要点,计算机网络要点
- php工程师绩效考核表_如何对程序员绩效考核?
- Origin: 散点图+拟合置信区间
- Js~弹出框插件jquery.boxy
- Oracle分析函数-first_value()和last_value()
- 【laravel-admin】权限管理与实现原理
- 语义分割系列6-Unet++(pytorch实现)
- java android studio 安卓开发 - 使用java发送邮件
- 使用oracle函数 LISTAGG 函数报错。ORA-00923: 未找到要求的 FROM 关键字
- c语言题库16页,C语言题库(完整版)(16页)-原创力文档
- CNC操机的几个步骤
- KIBANA用户手册(一) DISCOVER-时间
- Linux----dos界面 | 图形化界面切换