Documentation ¶
Index ¶
- func UpdateDir(ctx context.Context, current *ModuleContext, dirname string) error
- func UpdateFile(ctx context.Context, mc *ModuleContext, filename string) error
- func UpdateFileOrDir(ctx context.Context, gc *GlobalContext, path string) error
- func UpdateHCL(ctx context.Context, mc *ModuleContext, r io.Reader, w io.Writer, ...) (bool, error)
- type GlobalContext
- type LockUpdater
- type ModuleContext
- func (mc *ModuleContext) FS() afero.Fs
- func (mc *ModuleContext) GlobalContext() *GlobalContext
- func (mc *ModuleContext) Option() Option
- func (mc *ModuleContext) ResolveProviderShortNameFromSource(source string) string
- func (mc *ModuleContext) SelecetedProviders() []SelectedProvider
- func (mc *ModuleContext) Updater() Updater
- type ModuleUpdater
- type Option
- type ProviderUpdater
- type SelectedProvider
- type TerraformUpdater
- type Updater
- func NewLockUpdater(platforms []string, index lock.Index) (Updater, error)
- func NewModuleUpdater(name string, version string, nameRegex *regexp.Regexp) (Updater, error)
- func NewProviderUpdater(name string, version string) (Updater, error)
- func NewTerraformUpdater(version string) (Updater, error)
- func NewUpdater(o Option) (Updater, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpdateDir ¶
func UpdateDir(ctx context.Context, current *ModuleContext, dirname string) error
UpdateDir updates version constraints for files in a given directory. If a recursive flag is true, it checks and updates recursively. skip hidden directories such as .terraform or .git. It also skips unsupported file type.
func UpdateFile ¶
func UpdateFile(ctx context.Context, mc *ModuleContext, filename string) error
UpdateFile updates version constraints in a single file. We use an afero filesystem here for testing.
func UpdateFileOrDir ¶
func UpdateFileOrDir(ctx context.Context, gc *GlobalContext, path string) error
UpdateFileOrDir updates version constraints in a given file or directory.
func UpdateHCL ¶
func UpdateHCL(ctx context.Context, mc *ModuleContext, r io.Reader, w io.Writer, filename string) (bool, error)
UpdateHCL reads HCL from io.Reader, updates version constraints and writes updated contents to io.Writer. If contents changed successfully, it returns true, or otherwise returns false. If an error occurs, Nothing is written to the output stream.
Types ¶
type GlobalContext ¶ added in v0.7.0
type GlobalContext struct {
// contains filtered or unexported fields
}
GlobalContext is information that is shared over the lifetime of the process.
func NewGlobalContext ¶ added in v0.7.0
func NewGlobalContext(fs afero.Fs, o Option) (*GlobalContext, error)
NewGlobalContext returns a new instance of NewGlobalContext.
type LockUpdater ¶ added in v0.7.0
type LockUpdater struct {
// contains filtered or unexported fields
}
LockUpdater is a updater implementation which updates the dependency lock file.
func (*LockUpdater) Update ¶ added in v0.7.0
func (u *LockUpdater) Update(ctx context.Context, mc *ModuleContext, filename string, f *hclwrite.File) error
Update updates the dependency lock file. Note that this method will rewrite the AST passed as an argument.
type ModuleContext ¶ added in v0.7.0
type ModuleContext struct {
// contains filtered or unexported fields
}
ModuleContext is information shared across files within a directory.
func NewModuleContext ¶ added in v0.7.0
func NewModuleContext(dir string, gc *GlobalContext) (*ModuleContext, error)
NewModuleContext parses a given module and returns a new ModuleContext. The dir is a relative path to the module from the current working directory.
func (*ModuleContext) FS ¶ added in v0.7.0
func (mc *ModuleContext) FS() afero.Fs
FS returns an instance of afero filesystem
func (*ModuleContext) GlobalContext ¶ added in v0.7.0
func (mc *ModuleContext) GlobalContext() *GlobalContext
GlobalContext returns an instance of the global context.
func (*ModuleContext) Option ¶ added in v0.7.0
func (mc *ModuleContext) Option() Option
Option returns an instance of Option.
func (*ModuleContext) ResolveProviderShortNameFromSource ¶ added in v0.8.0
func (mc *ModuleContext) ResolveProviderShortNameFromSource(source string) string
ResolveProviderShortNameFromSource is a helper function to resolve provider short names from the source address. If not found, return an empty string.
func (*ModuleContext) SelecetedProviders ¶ added in v0.7.0
func (mc *ModuleContext) SelecetedProviders() []SelectedProvider
SelectedProviders returns a list of providers inferred from version constraints. The result is sorted alphabetically by source address. Version constraints only support simple constants and not comparison operators. Ignore what cannot be interpreted.
func (*ModuleContext) Updater ¶ added in v0.7.0
func (mc *ModuleContext) Updater() Updater
Updater returns an instance of Updater.
type ModuleUpdater ¶ added in v0.3.0
type ModuleUpdater struct {
// contains filtered or unexported fields
}
ModuleUpdater is a updater implementation which updates the module version constraint.
func (*ModuleUpdater) Update ¶ added in v0.3.0
func (u *ModuleUpdater) Update(_ context.Context, _ *ModuleContext, filename string, f *hclwrite.File) error
Update updates the module version constraint. Note that this method will rewrite the AST passed as an argument.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is a set of parameters to update.
func NewOption ¶
func NewOption(updateType string, name string, version string, platforms []string, recursive bool, ignorePaths []string, sourceMatchType string) (Option, error)
NewOption returns an option.
func (*Option) MatchIgnorePaths ¶
MatchIgnorePaths returns whether any of the ignore conditions are met.
type ProviderUpdater ¶
type ProviderUpdater struct {
// contains filtered or unexported fields
}
ProviderUpdater is a updater implementation which updates the provider version constraint.
func (*ProviderUpdater) Update ¶
func (u *ProviderUpdater) Update(_ context.Context, mc *ModuleContext, filename string, f *hclwrite.File) error
Update updates the provider version constraint. Note that this method will rewrite the AST passed as an argument.
type SelectedProvider ¶ added in v0.7.0
type SelectedProvider struct { // source is a source address of the provider. Source string // version is a version of the provider. Version string }
SelectedProvider is the source address and version of the provider, as inferred from the version constraint.
type TerraformUpdater ¶
type TerraformUpdater struct {
// contains filtered or unexported fields
}
TerraformUpdater is a updater implementation which updates the terraform version constraint.
func (*TerraformUpdater) Update ¶
func (u *TerraformUpdater) Update(_ context.Context, _ *ModuleContext, filename string, f *hclwrite.File) error
Update updates the terraform version constraint. Note that this method will rewrite the AST passed as an argument.
type Updater ¶
type Updater interface { // Update updates a version constraint. // Note that this method will rewrite the AST passed as an argument. Update(ctx context.Context, mc *ModuleContext, filename string, f *hclwrite.File) error }
Updater is an interface which updates a version constraint in HCL.
func NewLockUpdater ¶ added in v0.7.0
NewLockUpdater is a factory method which returns an LockUpdater instance.
func NewModuleUpdater ¶ added in v0.3.0
NewModuleUpdater is a factory method which returns an ModuleUpdater instance.
func NewProviderUpdater ¶
NewProviderUpdater is a factory method which returns an ProviderUpdater instance.
func NewTerraformUpdater ¶
NewTerraformUpdater is a factory method which returns an TerraformUpdater instance.
func NewUpdater ¶
NewUpdater is a factory method which returns an Updater implementation.