Skip to content

Commit

Permalink
add option to pass in anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
panbenson committed Dec 16, 2024
1 parent c7348a9 commit ffd4034
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions paasta_tools/contrib/service_shard_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import logging
import sys

from ruamel.yaml.comments import CommentedMap
from ruamel.yaml.comments import CommentedSeq

from paasta_tools.cli.utils import trigger_deploys
from paasta_tools.config_utils import AutoConfigUpdater
from paasta_tools.utils import DEFAULT_SOA_CONFIGS_GIT_URL
Expand Down Expand Up @@ -164,6 +167,15 @@ def parse_args():
type=int,
dest="autotune_max_disk",
)
parser.add_argument(
"--anchor",
dest="anchors",
help="Additional configuration to add to the service shard (YAML anchor names)",
action="append",
type=str,
default=[],
required=False,
)
return parser.parse_args()


Expand Down Expand Up @@ -306,6 +318,19 @@ def main(args):
# Add the missing definition and write to the corresponding config
if args.shard_name not in config_file.keys():
config_file[args.shard_name] = instance_config

# Finally, add any YAML anchors to the service shard configuration
if len(args.anchors) > 0:
configWithAnchor = CommentedMap({
'<<': CommentedSeq(
[config_file[anchor] for anchor in args.anchors if anchor in config_file.keys()]
)
})
# set the formatting to single line for readability
configWithAnchor["<<"].fa.set_flow_style()
configWithAnchor.update(config_file[args.shard_name])
config_file[args.shard_name] = configWithAnchor

updater.write_configs(
args.service, f"{config_prefix}{config_path}", config_file
)
Expand Down

0 comments on commit ffd4034

Please sign in to comment.