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相关推荐

  1. SAP UI5 初学者教程之二十八 - SAP UI5 应用的集成测试工具 OPA 介绍试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  2. SAP UI5 应用开发教程之二十八 - SAP UI5 应用的集成测试工具 OPA 介绍

    本教程前一步骤,我们介绍了 SAP UI5 单元测试工具 QUnit 的使用方法.本步骤介绍测试金字塔模型中位于单元测试上层的集成测试在 SAP UI5 中的实现工具:OPA. 本步骤对应的源代码位于 ...

  3. OPA Quality Report in Jenkins Ben - 到哪里能看到我们的OPA Test在Jenkins Server上运行的情况

    Created by Wang, Jerry, last modified on Jul 19, 2016 我们每次提交代码的时候触发的Voter Job都会跑一次OPA并且记录结果(前段时间可能DL ...

  4. SAP ui5 单元测试框架 - OPA

    Sent: Monday, July 4, 2016 6:41 PM 本地eclipse复现错误的步骤如下: 修改cus.crm.lead项目的pom.xml的参数如下: 1.10.0-SNAPSHO ...

  5. Solution for Lead OPA test error ( add button clicked after cancel button )

    改了Lead后遇到OPA的test failure: 问题的表现是我们的test code里点了cancel button之后,再点Add button,这行语句报错:在dialog里找不到这个期望的 ...

  6. 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 ...

  7. k8s访问控制--理解RBAC和OPA

    1. RBAC–基于角色的访问控制 1.1 Kubernetes基于意图的声明式API Kubernetes API的设计与大多数现代API不同.它是基于意图的,这意味着使用API的人考虑的是他们想要 ...

  8. 武夫提笔——席卷世界Nodejs之初步对比:与opa各占几分春色?

    Node 近年来风卷残云,在世界各地风起云涌.进入新公司后,阴差阳错作为一个后端工程师开启了猛攻node的进程.不想,进展神速,现在已在node技术栈上开发出了公司的即时消息系统.在安营扎寨的那些日夜 ...

  9. 激光雷达技术路线:机械式、MEMS是主流,OPA、Flash、FMCW发展空间大

    --激光雷达是通过发射激光束来探测物体与传感器之间精准距离的主动测量装置,包含发射单元.接收单元.扫描单元以及数据处理单元.激光雷达通过激光器和探测器组成的收发阵列,结合光束扫描,可以对广义机器人所处 ...

  10. UI5(十一)单元测试、与OPA的集成测试、Debugging 工具

    单元测试 文件夹结构 我们在测试文件夹和模型子文件夹下添加一个新的文件夹单元,在其中放置单元测试.文件夹结构与应用程序结构相匹配,可以很容易地找到相应的单元测试 webapp/test/unit/mo ...

最新文章

  1. win10 hao123劫持html文件,Win10 edge主页被hao123劫持如何解决|edge主页被hao123劫持的解决方法...
  2. 【随笔】如何快速转载CSDN中的博客
  3. 线段树segment_tree go语言实现
  4. 【Python】20个Pandas数据实战案例,干货多多
  5. leetcode 160. 相交链表(双指针)
  6. 招聘贴---这个很重要嘛
  7. Session重点整理
  8. 计算机网络要点,计算机网络要点
  9. php工程师绩效考核表_如何对程序员绩效考核?
  10. Origin: 散点图+拟合置信区间
  11. Js~弹出框插件jquery.boxy
  12. Oracle分析函数-first_value()和last_value()
  13. 【laravel-admin】权限管理与实现原理
  14. 语义分割系列6-Unet++(pytorch实现)
  15. java android studio 安卓开发 - 使用java发送邮件
  16. 使用oracle函数 LISTAGG 函数报错。ORA-00923: 未找到要求的 FROM 关键字
  17. c语言题库16页,C语言题库(完整版)(16页)-原创力文档
  18. CNC操机的几个步骤
  19. KIBANA用户手册(一) DISCOVER-时间
  20. Linux----dos界面 | 图形化界面切换

热门文章

  1. python保存Excel文件sheet_name是中文时出错:UnicodeDecodeError
  2. 开发常用图标png、ico 图标下载
  3. nRF52832之硬件I2C
  4. 远程--不用关闭防火墙,也可以远程连接(远程桌面连接不上怎么办)
  5. 【周志华机器学习】五、神经网络
  6. invalid use of non-static member function
  7. 云计算——第七天(寒假)
  8. 视频素材剪辑制作的方法分享
  9. 第三次作业--团队展示(团队)
  10. 用Python实现查心率