From d19dca6a472a356b1277036e0319b9ae6b5a264e Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 6 Mar 2025 10:13:12 -0800 Subject: [PATCH] Update readme --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- main.go | 2 +- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b0a5dc4..3dcb794 100644 --- a/README.md +++ b/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= write +``` + +- `-root-var`: The root path for the Nomad variable. +- ``: 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= -dir-perms= read +``` + +- `-root-var`: The root path for the Nomad variable. +- `-dir-perms`: (Optional) Default permissions for new directories (default: `0o777`). +- ``: 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. diff --git a/main.go b/main.go index bff63be..efc3aa2 100644 --- a/main.go +++ b/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) } }