This commit is contained in:
parent
9deac7cc7e
commit
d19dca6a47
53
README.md
53
README.md
@ -1,3 +1,52 @@
|
||||
# [nomad-var-dirsync](/iamthefij/nomad-var-dirsync)
|
||||
# Nomad Var DirSync
|
||||
|
||||
Sync a directory with Nomad Variables
|
||||
Nomad Var DirSync is a command-line tool designed to synchronize directories with Nomad variables. It allows you to write the contents of a directory to Nomad variables and read Nomad variables back into a directory.
|
||||
|
||||
## Installation
|
||||
|
||||
To install Nomad Var DirSync, you need to have Go installed on your machine. You can download and install Go from [the official website](https://golang.org/dl/).
|
||||
|
||||
Once you have Go installed, you can install Nomad Var DirSync by running the following command:
|
||||
|
||||
```sh
|
||||
go install git.iamthefij.com/iamthefij/nomad-var-dirsync@latest
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Nomad Var DirSync provides two main actions: `write` and `read`.
|
||||
|
||||
### Write Directory to Nomad Variables
|
||||
|
||||
To write the contents of a directory to Nomad variables, use the `write` action:
|
||||
|
||||
```sh
|
||||
nomad-var-dirsync -root-var=<root-variable-path> write <source-directory>
|
||||
```
|
||||
|
||||
- `-root-var`: The root path for the Nomad variable.
|
||||
- `<destination-directory>`: The path to the directory you want to write to Nomad variables.
|
||||
|
||||
### Read Nomad Variables to Directory
|
||||
|
||||
To read Nomad variables back into a directory, use the `read` action:
|
||||
|
||||
```sh
|
||||
nomad-var-dirsync -root-var=<root-variable-path> -dir-perms=<permissions> read <target-directory>
|
||||
```
|
||||
|
||||
- `-root-var`: The root path for the Nomad variable.
|
||||
- `-dir-perms`: (Optional) Default permissions for new directories (default: `0o777`).
|
||||
- `<target-directory>`: The path to the directory where you want to read the Nomad variables.
|
||||
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `NOMAD_ADDR`: The address of the Nomad server (default: `http://localhost:4646`).
|
||||
- `NOMAD_TOKEN`: The secret ID token for authenticating with the Nomad API.
|
||||
|
||||
This should also support the same environment variables as the official [Nomad CLI](https://www.nomadproject.io/docs/commands/cli).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
|
2
main.go
2
main.go
@ -97,7 +97,7 @@ func readDir(client *nomad_api.Client, root string, targetDir string, newDirPerm
|
||||
parentDir := filepath.Dir(filePath)
|
||||
if _, err := os.Stat(parentDir); err != nil {
|
||||
if err = os.MkdirAll(parentDir, fs.FileMode(newDirPerms)); err != nil {
|
||||
return fmt.Errorf("error creating paretn dir for file at path %s: %w", filePath, err)
|
||||
return fmt.Errorf("error creating parent dir for file at path %s: %w", filePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user