repotools

package module
v0.0.0-...-380e484 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2023 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

README

Repository Management Tools

This Go module is a collection of tools that have been written for managing the AWS SDK for Go V2 source repository. At the time these were written, the Go ecosystem lacked tooling for managing repositories containing multiple Go modules with at the size and scale of the AWS SDK. With over 274 Go modules in the repository the tooling found here has been made to manage the lifecycle of managing dependencies (iter-repository and external), managing the releases of new changes, tag management following Go semver requirements, and production of changelogs.

Utilities

The following is a breakdown of some the key utilities found in this module that are used to manage the SDK and handle the complex release process.

Commands Description README
changelog Create and manage changelog annotations. Annotations are used to document module changes and refining of the next semver version. Link
updaterequires Manages go.mod require entries, allows for easily updating inter-repository module dependencies to their latest tag, and the ability to quickly manage external dependency requirements. N/A
updatemodulemeta Generates a go_module_metadata.go file in each module containing useful runtime metadata like the modules tagged version. N/A
generatechangelog Uses a release description and associated changelog annotations to produce CHANGELOG.md entries for the release in each repository module. In addition, a summarized release statement will be created at the root of the repository. N/A
gomodgen Copies smithy-go codegen build artifacts into the SDK repository and generates a go.mod file using the build artifacts generated.json description. N/A
annotatestablegen Generates a release changelog annotation type for new smithy-go generated modules that are not marked as unstable. N/A
calculaterelease Detects new and changed Go modules in the repository, associates changelog annotations, and computes the next semver version tag for each module. Produces a release manifest that is used with other utilities to orchestrate a release. Link
tagrelease Commits pending changes to the working directory, reads the release manifest, and creates the computed tags N/A
makerelative Used to generate go.mod replace statements for inter-repository module dependencies. This ensures that when developing on a given Go module it's iter-repository dependencies refer to the cloned repository. N/A
eachmodule Utility for quickly scripting execution of commands in each module of a repository. N/A

Configuration

A number of the repository tools, specifically those involved with the dependency management and release have specific behavior that is driven by the modman.toml file found at the root of the git repository. This configuration file is a TOML configuration file.

Dependencies

The dependencies is a dictionary of key-value pairs that describe external dependencies that one or more modules within the repository may depend on. (External dependencies is defined as the set of Go modules that are not found within the project git repository.) This section is used to quickly set the version of a dependency modules in the repository should use. The updaterequires tool can be used to update all Go modules require statements for each module in the repository and update them to the indicated version if they depend on the given external module.

Example
[dependencies]
"github.com/aws/smithy-go" = "v1.4.0"

This example indicates that repository modules that depend on github.com/aws/smithy-go should depend on v1.4.0 version of the library. After updating the value in the configuration file, updaterequires can be used to update modules with this information.

Modules

modules is a dictionary where the keys are module directories relative to the repository root. Each key maps to a dictionary of key-value pairs that can configure several properties of a module that affect how or if a module is handled when performing a release.

Example

To configure the module feature/service/shinything to not be tagged by the release process:

[modules."feature/service/shinything"]
no_tag = true

For more information on how to configure how modules are released see the calculaterelease README.

Mark a module to be

NOTE: If you wish to create a configuration item for a module located at the root of the repository use . as the key name.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfNotPresent

func AppendIfNotPresent(x []string, value string) []string

AppendIfNotPresent appends value to the slice x if not present. The slice must be sorted in ascending order.

func FindRepoRoot

func FindRepoRoot(dir string) (string, error)

FindRepoRoot returns the absolute path to the root directory of the repository, or error. If the dir passed in is a relative path it will be used relative to the current working directory of the executable.

func GetEditorTool

func GetEditorTool() (string, error)

GetEditorTool returns the editor tool to use for interactive file edits.

func GetRepoRoot

func GetRepoRoot() (string, error)

GetRepoRoot uses the current working directory to find the repository root.

func JoinWorkingDirectory

func JoinWorkingDirectory(dir string) (string, error)

JoinWorkingDirectory will return an absolute file system path of the passed in dir path with the current working directory.

func UUIDVersion4

func UUIDVersion4(u [16]byte) string

UUIDVersion4 takes an array of 16 (random) bytes and converts it to a UUIDv4 value.

func WriteConfig

func WriteConfig(path string, config Config) (err error)

WriteConfig writes the tooling configuration to the given path.

Types

type Boots

type Boots struct {
	// Directories to skip when iterating.
	SkipDirs []string
	// contains filtered or unexported fields
}

Boots was made for walking the file tree searching for modules.

func (*Boots) Modules

func (b *Boots) Modules() []string

Modules returns a slice of module directory absolute paths.

func (*Boots) Walk

func (b *Boots) Walk(path string, info os.FileInfo, err error) error

Walk is the function to walk folders in the repo searching for go modules.

type Config

type Config struct {
	Modules      map[string]ModuleConfig `toml:"modules,omitempty"`
	Dependencies map[string]string       `toml:"dependencies,omitempty"`
}

Config is a configuration file for describing how modules and dependencies are managed.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads the tooling configuration file located in the directory path.

func ReadConfig

func ReadConfig(reader io.Reader) (Config, error)

ReadConfig reads the tooling configuration from the given reader.

type ModuleConfig

type ModuleConfig struct {
	// Indicates that the given module should not be tagged (released)
	NoTag bool `toml:"no_tag,omitempty"`

	// The semver pre-release string for the module
	PreRelease string `toml:"pre_release,omitempty"`

	// The package alternative location relative to the module where the go_module_metadata.go should be written.
	// By default this file is written in the location of the module root where the `go.mod` is located.
	MetadataPackage string `toml:"metadata_package,omitempty"`
}

ModuleConfig is the configuration for the repository module

Directories

Path Synopsis
cmd
internal
semver
Package semver implements comparison of semantic version strings.
Package semver implements comparison of semantic version strings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL