feat: port influx export stack subcommand (#150)
* confirmed subcommand parsing * feat: port influx export stack subcommand * refactor: removed redundant code and improved error messages * chore: ran make fmt to fix code formatting issues Co-authored-by: Michelle McFarland <michellemcfarland@Michelles-MacBook-Pro.local>
This commit is contained in:
@ -110,3 +110,26 @@ func (c Client) ExportAll(ctx context.Context, params *AllParams) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type StackParams struct {
|
||||
OutParams
|
||||
StackId string
|
||||
}
|
||||
|
||||
func (c Client) ExportStack(ctx context.Context, params *StackParams) error {
|
||||
if params.StackId == "" {
|
||||
return fmt.Errorf("no stack id provided")
|
||||
}
|
||||
|
||||
exportReq := api.TemplateExport{StackID: ¶ms.StackId}
|
||||
tmpl, err := c.ExportTemplate(ctx).TemplateExport(exportReq).Execute()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to export stack %q: %w", params.StackId, err)
|
||||
}
|
||||
if err := params.OutParams.writeTemplate(tmpl); err != nil {
|
||||
return fmt.Errorf("failed to write exported template: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user