CLI utility tool to help you manage your configuration between systems
This repository has been archived on 2024-02-15. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
DataHearth 06d09e1be6
build / Build and test (push) Successful in 35s Details
chore(ci): use new runner image label
2023-07-18 14:10:14 +02:00
.chglog chore(changelog): update git repository url 2022-08-20 16:38:59 +02:00
.gitea/workflows chore(ci): use new runner image label 2023-07-18 14:10:14 +02:00
cmd chore(changelog): release v0.6.2 2023-07-15 23:25:25 +02:00
internal chore(logging): use charmbracelet/log instead of custom logging 2023-03-02 18:35:26 +01:00
.config-mapper.yml.template chore(template): update brew key 2022-07-17 23:17:37 +02:00
.gitignore chore(process): add just and goreleaser 2022-10-02 21:15:10 +02:00
.goreleaser.yaml chore(process): force use of gitea token goreleaser 2023-07-18 00:33:02 +02:00
CHANGELOG.md chore(changelog): release v0.6.2 2023-07-15 23:25:25 +02:00
LICENSE Update 'LICENSE' 2023-05-24 10:02:31 +02:00
README.md chore(process): update justfile 2023-07-18 11:04:52 +02:00
go.mod chore(logging): use charmbracelet/log instead of custom logging 2023-03-02 18:35:26 +01:00
go.sum chore(logging): use charmbracelet/log instead of custom logging 2023-03-02 18:35:26 +01:00
justfile chore(process): update justfile 2023-07-18 11:04:52 +02:00
main.go feat(ssh): add possibilty to use multiple SSH configurations 2022-09-12 18:40:40 +02:00

README.md

config-mapper

License Version

config-mapper is CLI utility tool to help you manage your configuration between UNIX systems.
It provides a set of tools to load your configuration from a system, save it into a git repository and then save it to a new system. This configuration can be a set of files, folders or even dependencies.

Usage

Before going any further, you need to create a repository to store your configuration. You can choose any supplier as long it's a git repository :).

When copying a file from your configuration repository to your system, it's performing a copy. If the file exists on the system, it's content will be replaced by your configuration's one.

The system is detected automatically. You just need to specify whether the related field in case of files or folders sections (fields: darwin | linux).

You can get a configuration template here.

Installation

  • Using a pre-build binary

Binaries are available in the release section at https://gitea.antoine-langlois.net/DataHearth/config-mapper/releases.

  • Building from source:
git clone https://gitea.antoine-langlois.net/DataHearth/config-mapper.git
cd config-mapper
go build -o $HOME/.local/bin/config-mapper
  • With Golang cli
go install gitea.antoine-langlois.net/datahearth/config-mapper@latest

Setup

Create a file called .config-mapper.yml in your home directory (it is the default search path for config-mapper).
If you wish to move it to another directory, you can choose by either setting an environment: CONFIG_MAPPER_CFG=/path/to/config/.config-mapper.yml or by using the -c /path/to/config/.config-mapper.yml flag.

Once the configuration file created, run this command to initialize the repository locally:

config-mapper init

If the folder is already present and is a git directory, clone instruction will be ignored.

template for storage part:

storage:
  # Where will be the repository folder located ? [DEFAULT: MacOS($TMPDIR/config-mapper) | Linux(/tmp/config-mapper)]
  location: /path/to/folder
  git:
    # * by default, if ssh dict is set with its keys filled, I'll try to clone with SSH
    repository: git@github.com:DataHearth/my-config.git
    basic-auth:
      username: USERNAME
      # * NOTE: if you're having trouble with error "authentication required", you should maybe use a token access
      # * In some cases, it's due to 2FA authentication enabled on the git hosting provided
      password: TOKEN
    ssh:
      # path can be relative and can contain environment variables
      private-key: /path/to/private/key
      passphrase: PASSPHRASE

Save your configuration into your repository

Now that your repository is setup localy, you can sync your configuration into it by simply running this command:

config-mapper save

All defined files and folders will be copied inside your repository.

If you want to exclude one part of your configuration file (files, folders), you can use these flags to ignore them --disable-files --disable-folders.

You can also exclude files and folders from a given directory with a .gitignore like file named .ignore. Put it in the root directory of an included folder and add relative path to exclude (does not support glob for now). E.g:

Permissions Size User    Date Modified Name
drwxr-xr-x     - antoine  1 Jun 20:28  ../demo
.rw-r--r--    12 antoine  1 Jun 20:28  ├── .ignore
drwxr-xr-x     - antoine  1 Jun 20:28  ├── egg
.rw-r--r--     0 antoine  1 Jun 20:28  │  └── bar.py
.rw-r--r--     0 antoine  1 Jun 20:26  ├── example.py
drwxr-xr-x     - antoine  1 Jun 20:27  └── foo
.rw-r--r--     0 antoine  1 Jun 20:24     ├── bar
.rw-r--r--     0 antoine  1 Jun 20:27     └── demo.py

.ignore content:

# bar file will be ignored
foo/bar

# egg folder will be ignore
egg

template for your configuration:

# NOTE: the $LOCATION if refering to the "storage.location" path. It'll be replaced automatically
# The left part of ":" is your repository location and right part is on your system
files:
  - darwin: "$LOCATION/macos/.zshrc:~/.zshrc"
    linux: "$LOCATION/linux/.zshrc:~/.zshrc"

folders:
  - darwin: "$LOCATION/macos/.config:~/.config"
    linux: "$LOCATION/macos/.config:~/.config"

package-managers:
  installation-order:
    - brew
  brew:
    - bat
    - hexyl
    - fd
    - hyperfine
    - diskus
    - jq
    - k9s
    - go
    - starship
    - exa
    - httpie
    - neovim
    - nmap
    - pinentry
    - zsh

  apt-get: []
  pip: []
  cargo: []
  pip: []
  go: []

Load your configuration onto the system

Once your repository is populated with your configurations, you can now load them onto a new system by using:

config-mapper load

The same ignore flags are used in the save command.

TO-DO

  • add .ignore file to ignore content inside directory
  • use remote configuration: SSH
  • optimisation over speed and memory
  • add more storage options
    • smb storage
    • nfs storage
    • zip

Known issues

  • GitHub SSH repository url: ssh: handshake failed: knownhosts: key mismatch Resolved by create a new primary key based on GitHub new GIT SSH standards (issue)
  • Cloning from GitHub with https BasicAuth and 2FA activated: authentication required Resolved by creating an access token and set it as password in configuration
  • WSL might have a rough time with opened files by homebrew and throwing Error: too many open files.
    This thread discuss about this issue. The workaround seems to be increase the filesystem limit (ulimit -Hn && ulimit -Sn). Another way is to launch again your command as homebrew already installed some the packages.