99from .backend import BackendSpec
1010from .config import ConfigSpec
1111from .blueprint import BlueprintSpec
12+ from .export import ExportSpec
1213from .utils import read_blueprints , ANSIColors
1314
1415
@@ -22,6 +23,7 @@ def __init__(self):
2223 { ANSIColors .BOLD } blueprint{ ANSIColors .ENDC } - configure available blueprints
2324 { ANSIColors .BOLD } config{ ANSIColors .ENDC } - configure instance variable overrides
2425 destroy
26+ { ANSIColors .BOLD } export{ ANSIColors .ENDC } - export blueprint configuration
2527 graph
2628 import
2729 init
@@ -45,7 +47,7 @@ def __init__(self):
4547 parser .add_argument ('-q' , '--quiet' , action = 'store_true' , help = 'suppress execution output to stdout' )
4648 parser .add_argument ('-var-file' , metavar = '<var_file>' , help = 'override default config' )
4749 parser .add_argument ('command' , help = 'Subcommand to run' , choices = ['apply' , 'destroy' , 'force-unlock' , 'graph' , 'import' , 'init' , 'output' , 'plan' , 'providers' , 'refresh' , 'show' ,
48- 'state' , 'taint' , 'untaint' , 'version' , 'workspace' ] + ['blueprint' , 'backend' , 'config' ])
50+ 'state' , 'taint' , 'untaint' , 'version' , 'workspace' ] + ['blueprint' , 'backend' , 'config' , 'export' ])
4951 parser .add_argument ('cmd_args' , metavar = '<cmd_args>' ,
5052 help = 'additional arguments for sub-commands' , nargs = '*' )
5153
@@ -73,6 +75,8 @@ def __init__(self):
7375 self .config (sys .argv [sys .argv .index (args .command ) + 1 :])
7476 elif args .command == 'blueprint' :
7577 self .blueprint (sys .argv [sys .argv .index (args .command ) + 1 :])
78+ elif args .command == 'export' :
79+ self .export (sys .argv [sys .argv .index (args .command ) + 1 :])
7680
7781 sys .exit ()
7882
@@ -162,6 +166,20 @@ def blueprint(self, args):
162166
163167 spec .run ()
164168
169+ def export (self , args ):
170+ spec = ExportSpec (None , None , pull_image = self .pull_image , dry_run = self .dryrun , verbose = self .verbose )
171+ blueprint_home = BlueprintSpec .get_blueprint_home ()
172+ blueprint = self .get_blueprint ()
173+ spec .blueprint_home = blueprint_home
174+ spec .blueprint_id = blueprint [0 ]
175+ spec .image = blueprint [1 ]['image' ]
176+ spec .image_registry = BlueprintSpec .get_blueprint_registry ()
177+ spec .image_tag = BlueprintSpec .get_blueprint_tag ()
178+
179+ spec .instance_name = 'tf_export'
180+
181+ spec .run ()
182+
165183
166184if __name__ == "__main__" :
167185 BedrockCli ()
0 commit comments