很难简明扼要地描述,所以我来演示一下.
from sys import stdout
from ruamel.yaml import YAML
yml = YAML()
doc = """
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
local:
path: ./operator-images
mirror:
operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.14
packages:
- name: rhods-operator
channels:
- name: fast
minVersion: 2.7.0
maxVersion: 2.7.0
- name: nfd
channels:
- name: stable
additionalImages:
- name: quay.io/integreatly/prometheus-blackbox-exporter@sha256:35b9d2c1002201723b7f7a9f54e9406b2ec4b5b0f73d114f47c70e15956103b5
- name: quay.io/modh/codeserver@sha256:7b53d6c49b0e18d8907392c19b23ddcdcd4dbf730853ccdf153358ca81b2c523
- name: quay.io/modh/cuda-notebooks@sha256:00c53599f5085beedd0debb062652a1856b19921ccf59bd76134471d24c3fa7d
- name: quay.io/modh/cuda-notebooks@sha256:4275eefdab2d5e32a7be26f747d1cdb58e82fb0cd57dda939a9a24e084bd1f7e
- name: quay.io/modh/cuda-notebooks@sha256:6fadedc5a10f5a914bb7b27cd41bc644392e5757ceaf07d930db884112054265
- name: quay.io/modh/cuda-notebooks@sha256:88d80821ff8c5d53526794261d519125d0763b621d824f8c3222127dab7b6cc8
"""
y = yml.load(doc)
yml.dump(y, stdout)
打印内容如下:
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
local:
path: ./operator-images
mirror:
operators:
- catalog: registry.redhat.io/redhat/redhat-operator-index:v4.14
packages:
- name: rhods-operator
channels:
- name: fast
minVersion: 2.7.0
maxVersion: 2.7.0
- name: nfd
channels:
- name: stable
additionalImages:
- name:
quay.io/integreatly/prometheus-blackbox-exporter@sha256:35b9d2c1002201723b7f7a9f54e9406b2ec4b5b0f73d114f47c70e15956103b5
- name:
quay.io/modh/codeserver@sha256:7b53d6c49b0e18d8907392c19b23ddcdcd4dbf730853ccdf153358ca81b2c523
- name:
quay.io/modh/cuda-notebooks@sha256:00c53599f5085beedd0debb062652a1856b19921ccf59bd76134471d24c3fa7d
- name:
quay.io/modh/cuda-notebooks@sha256:4275eefdab2d5e32a7be26f747d1cdb58e82fb0cd57dda939a9a24e084bd1f7e
- name:
quay.io/modh/cuda-notebooks@sha256:6fadedc5a10f5a914bb7b27cd41bc644392e5757ceaf07d930db884112054265
- name:
quay.io/modh/cuda-notebooks@sha256:88d80821ff8c5d53526794261d519125d0763b621d824f8c3222127dab7b6cc8
为什么在转储时,mirror.additionalImages
列表中的name: xxx
个单词会被分成两行?它是基于密钥值的长度还是别的什么?我怎么才能阻止它呢?(在一个有数百个这样的文件中,这真的变得很荒谬.)我已经try 了YAML()
个实例的各种设置,但都没有用.(例如,indent()
、compact()
和default_flow_style
.)