Skip to content

Commit a766831

Browse files
committed
feat: Update clone_wp_site.py to clone src app config
Applications store their config in a 'json' field (which is submitted as JSON in the REST API). In opalstack-python, this field is represented by a dictionary. This change stores the source app config and applies it to the created app, which preserves such settings as "gzip", "php_version", and "auto_site_url".
1 parent c5fc6c5 commit a766831

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/clone_wp_site.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def main(args):
8080
opalapi.ips.list_all(embed=['server']), {'server.hostname': web_server['hostname'], 'primary': True},
8181
)
8282

83+
# Retrieve existing app information for later use
84+
log.info(f'Retrieving app information for {SRC_APP_NAME}')
85+
src_app = filt_one(
86+
opalapi.apps.list_all(), {'name': SRC_APP_NAME}
87+
)
88+
8389
# Either retrieve or create destination osuser, depending on whether or not a password was specified.
8490
if DST_OSUSER_PASS:
8591
log.info(f'Retrieving existing osuser {DST_OSUSER_NAME}')
@@ -111,7 +117,8 @@ def main(args):
111117
'name': DST_APP_NAME,
112118
'osuser': dst_osuser['id'],
113119
'type': 'APA',
114-
'installer_url': 'https://raw.githubusercontent.com/opalstack/installers/master/core/wordpress/install.sh'
120+
'installer_url': 'https://raw.githubusercontent.com/opalstack/installers/master/core/wordpress/install.sh',
121+
'json': src_app['json'],
115122
})
116123

117124
# Create site

0 commit comments

Comments
 (0)