Przeglądaj źródła

Use -c instead of -f for file to mimic docker stack deploy

Alan Colon 7 lat temu
rodzic
commit
b883a3df9e
3 zmienionych plików z 72 dodań i 4 usunięć
  1. 68 0
      README.md
  2. 3 3
      bin/portainer.js
  3. 1 1
      package.json

+ 68 - 0
README.md

@@ -0,0 +1,68 @@
+# Portainer Command Line Interface
+
+## Deploy a Stack
+
+```
+  Usage: npx portainer stack deploy [options] <name>
+
+  Options:
+
+    --help                             output usage information
+    -v, --verbose                      Enable verbose logging
+    -u, --username <username>          Portainer username. Defaults to environment variable PORTAINER_USERNAME.
+    -p, --password <password>          Portainer password. Defaults to environment variable PORTAINER_PASSWORD.
+    -r, --url <url>                    Portainer URL, such as http://server:9000. Defaults to environment variable PORTAINER_URL.
+    -k, --insecure                     Ignore certificate errors.
+    -j, --json                         Format JSON.
+    -c, --compose-file <compose_file>  Path to docker-compose.yml file. Defaults to ./docker-compose.yml.
+    -P, --prune                        Prune obsolete or orphaned containers. Defaults to true.
+    -W, --warning                      Add warning message to head of yaml. Defaults to true.
+```
+
+## List Stacks
+
+```
+  Usage: npx portainer stack ls [options]
+
+  Options:
+
+    --help                     output usage information
+    -v, --verbose              Enable verbose logging
+    -u, --username <username>  Portainer username. Defaults to environment variable PORTAINER_USERNAME.
+    -p, --password <password>  Portainer password. Defaults to environment variable PORTAINER_PASSWORD.
+    -r, --url <url>            Portainer URL, such as http://server:9000. Defaults to environment variable PORTAINER_URL.
+    -k, --insecure             Ignore certificate errors.
+    -j, --json                 Format JSON.
+```
+
+## Delete a Stack
+
+```
+  Usage: npx portainer stack rm [options] <name>
+
+  Options:
+
+    --help                     output usage information
+    -v, --verbose              Enable verbose logging
+    -u, --username <username>  Portainer username. Defaults to environment variable PORTAINER_USERNAME.
+    -p, --password <password>  Portainer password. Defaults to environment variable PORTAINER_PASSWORD.
+    -r, --url <url>            Portainer URL, such as http://server:9000. Defaults to environment variable PORTAINER_URL.
+    -k, --insecure             Ignore certificate errors.
+    -j, --json                 Format JSON.
+```
+
+## List Endpoints
+
+```
+  Usage: npx portainer stack rm [options] <name>
+
+  Options:
+
+    --help                     output usage information
+    -v, --verbose              Enable verbose logging
+    -u, --username <username>  Portainer username. Defaults to environment variable PORTAINER_USERNAME.
+    -p, --password <password>  Portainer password. Defaults to environment variable PORTAINER_PASSWORD.
+    -r, --url <url>            Portainer URL, such as http://server:9000. Defaults to environment variable PORTAINER_URL.
+    -k, --insecure             Ignore certificate errors.
+    -j, --json                 Format JSON.
+```

+ 3 - 3
bin/portainer.js

@@ -66,16 +66,16 @@ const main = async() => {
     }
 
     command('stack deploy <name>', 'Creates or updates a stack.')
-    .option('-f, --file <yaml_file>', 'Path to docker-compose.yml file. Defaults to ./docker-compose.yml.')
+    .option('-c, --compose-file <compose_file>', 'Path to docker-compose.yml file. Defaults to ./docker-compose.yml.')
     .option('-P, --prune', 'Prune obsolete or orphaned containers. Defaults to true.')
     .option('-W, --warning', 'Add warning message to head of yaml. Defaults to true.')
     .action(action(async (client, model) => {
         if (model.options.prune === undefined) model.options.prune = true
         if (model.options.warning === undefined) model.options.warning = true
-        if (model.options.file === undefined) model.options.file = 'docker-compose.yml'
+        if (model.options['compose-file'] === undefined) model.options['compose-file'] = 'docker-compose.yml'
         log('Upserting stack')
         return await client.upsertStack({
-                stackFile: model.options.file,
+                stackFile: model.options['compose-file'],
                 ...model,
                 ...model.options
             })

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "portainer",
-  "version": "0.0.2",
+  "version": "0.0.3",
   "description": "Portainer command line deployment",
   "main": "lib/client.js",
   "bin": {