标签:色彩 tps usr span 读取 yaml func creat 新建
krenz的网课,透视与结构、动态与构成、色彩与光影 赠送 人体结构教程+psd+k大笔刷
完整版地址:点击我
=========================================================================================================
service模板yaml
apiVersion: v1
kind: Service
metadata:
name: ${jarName}
labels:
name: ${jarName}
version: v1
spec:
ports:
- port: ${port}
targetPort: ${port}
selector:
name: ${jarName}
转成json的结构
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "${jarName}",
"labels": {
"name": "${jarName}",
"version": "v1"
}
},
"spec": {
"ports": [
{
"port": "${port}",
"targetPort": "${port}"
}
],
"selector": {
"name": "${jarName}"
}
}
}
# 通过传入service_name及ports列表
def create_service_yaml(service_name, ports):
# 将yaml读取为json,然后修改所有需要修改的${jarName}
service_data[‘metadata‘][‘name‘] = service_name
service_data[‘metadata‘][‘labels‘][‘name‘] = service_name
service_data[‘spec‘][‘selector‘][‘name‘] = service_name
# .spec.ports 比较特殊,是一个字典列表,由于传入的ports难以确定数量,难以直接修改
# 新建一个列表,遍历传入的ports列表,将传入的每个port都生成为一个字典,添加入新列表中
new_spec_ports = []
for port in ports:
port = int(port)
new_port = {‘port‘: port, ‘targetPort‘: port}
标签:色彩 tps usr span 读取 yaml func creat 新建
原文地址:https://www.cnblogs.com/momoyu/p/13235224.html