Sed は文字列を CA 証明書に置き換えます。

Sed は文字列を CA 証明書に置き換えます。

次のパラメータを含むyamlファイルがあります。

caCertificates: {} 

次に交換したいです。

caCertificates:
  hike.crt: |
    -----BEGIN CERTIFICATE-----
    MIIFOzCCAyOgAwIBAgIUIyHpTZS7DmOv1wOXytwFAZZTJmYwDQYJKoZIhvcNAQEL
    BQAwJTEjMCEGA1UEAxMaTUYgUkUgQ0Egb24gVmF1bHQgN2M3ODM2NDYwHhcNMjEw
    NDA3MTExMDIxWhcNMzEwNDA1MTExMDQwWjAlMSMwIQYDVQQDExpNRiBSRSBDQSBv
    biBWYXVsdCA3Yzc4MzY0NjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
    ALwivEBn9LmCc15++MbGCLoUnAbTLY60/XH8lLBa8O3u0Ay7uLIId+9P1PaWo1nP
    Ku5lYrScrczlElEKcKhTl3W54llGe7HoDsnkJRerX9gDeAMpJm099INovneTU73E
    YVtZdAB+PN8VM1/noZz2xX1MtEmoJ52tWDUnl4lyFbCY2sSsgAX5wzk9rHpzzGKF
    E1Lt6s8Df6j6Z1uJ4GIMuBKKYvAtyRYl/aznVLMmNaOO2SS6/PhF3QgwQsO3mRIZ
    s+IpHDiyOmiMM7tFYE8VD7I4S30+8oH18w6d0geXTvT7SybDRO2EDXXUalIsRzyJ
    xyH23vAmjcelYiBpHGICEOoi0eeJg+DyQB8i5gnqOMFiOC3fRRg+w4dZvOk0uQy/
    E3jMgDwJ1Xu6gcGE7SveQTyRoxq3AbAGcEHorfFp9iKKs7Y/2WSv/SsRUnDfa8kE
    OGmTvhiZoizRPkBeir6LEznf3cdG3NCYyZ/uU8vHtL+LxQ6yjIn6yC0BCNSR6d2t
    rcoOaZahr8nYn8VlukGUFS2x0szcVBEiiOgbtc35yHA6+MNafenwslg+CFjCvQzr
    U/CSHuKD6+KyowwLAX4g0i42NvOz4lKhnvCqKodXlIMPG5FRLYILZl6jAlVn7YPm
    oLfF7cvlMYjscufXD+0fP1O20CDdmVgBNIb0LVttS32rAgMBAAGjYzBhMA4GA1Ud
    DwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSOtPatITjgddDk
    5+0/dlUaPDW9nDAfBgNVHSMEGDAWgBSOtPatITjgddDk5+0/dlUaPDW9nDANBgkq
    hkiG9w0BAQsFAAOCAgEAbV64Ejz/VDSE0t+yaWlu283QCEvGkAImajpsAYNwrfnz
    U8w8bJMMKR0yknAwZCJOIloLHvP6CgHMKrDjc4CcbuoSVnKEjo7DbjbNjEaA9wWg
    Bbvo9Lw4MwwKkWkatFnlcxyh0SDQzYBp7CCK4CG5NYZTq7Rr1cfTNLkYu9p9sxxe
    8ER6ST5bPnfPZeVUELXoLRfgMycylBzEvbEv71S+CLOP3ACj4FGXSzFCYQtlqS8+
    U/B5vhHUvNYPwXUOScutMo402CSeB9oYN5bGTK6Uqln/viZc0bAgzATiZS+tT4qP
    k47PIsODRjnc5Xe9IyuAeIG2yvedvn/rhz0+e7RAx0sVwi3AhwdFbfRkM0nCuHYx
    Jys9HpI6+4oBR/+S61THTvP9s0vygr6/2PXHYocsqTUdTtUryyxelCRQygdXuHU8
    TsuYMiKStR/lAXEEnKQOvUV3xyDWoHGwsjGWkR4kAzUigGuQPWgpbCVBgGFnbSM1
    v8ZmLFPfVbRJNVPlDkxFluSedFdkvvVJmBG68eqQNBwIdDVqKebHES/vp3c1PYB4
    TA9LBiJQIvROTw4ZPtMOe7EuZrN5ybWIxZninFvJwoDqJHpb4s1qCy7Ru9CzsYqx
    ERx3xliLnFgGPtMIrNofvsSq4u7+/rPExYaF8vfkBtF3r50LFiy9EbqzHQtORdY=
    -----END CERTIFICATE-----

RE-ca.crtというファイルを読み、それをcaCertificates:{}に置き換えたいと思います。

答え1

次のことができました。

printf '%s\n' '/caCertificates: {}/r RE-ca.crt' 1 '/caCertificates: {}/d' w |value.yaml 編集

関連情報