github.com/aleksanderaleksic/tgmigrate@v0.1.7/config/config_state_s3.go (about)

     1  package config
     2  
     3  import (
     4  	"github.com/hashicorp/hcl/v2"
     5  	"github.com/hashicorp/hcl/v2/gohcl"
     6  )
     7  
     8  type S3StateConfig struct {
     9  	Bucket        string  `hcl:"bucket"`
    10  	Region        string  `hcl:"region"`
    11  	Prefix        *string `hcl:"prefix,optional"`
    12  	StateFileName *string `hcl:"state_file_name,optional"`
    13  	AssumeRole    *string `hcl:"assume_role,optional"`
    14  }
    15  
    16  func ParseS3StateConfig(configFile File, ctx *hcl.EvalContext) (*S3StateConfig, error) {
    17  	var config S3StateConfig
    18  	diags := gohcl.DecodeBody(configFile.Migration.State.Remain, ctx, &config)
    19  
    20  	if diags.HasErrors() {
    21  		return nil, diags
    22  	}
    23  
    24  	return &config, nil
    25  }
    26  
    27  func (s S3StateConfig) GetStateFileName() string {
    28  	if s.StateFileName != nil {
    29  		return *s.StateFileName
    30  	}
    31  	return defaultStateFileName
    32  }