Swyctl Reference Guide
Опубликовано Денис Завьялов on 21 November 2018 10:23
|
|
Installing SwyctlAside from using the swifty.dashboard web panel, you can also manage Swifty with the The # brew tap swiftycloud/swyctl # brew install swyctl Now you can use Using SwyctlA typical # swyctl <op> <args> [-<option> <value> ...] where When run without arguments, The following sections list commands that you may need the most. Logging In and Looking AroundLogin as # swyctl login user:pass@gate:port Login over HTTP instead of default HTTPS: # swyctl login user:pass@gate:port -tls no Login and simultaneously configure # swyctl login user:pass@gate:port -admd admd:port Login directly to a gate/admd, bypassing NGINX proxy: # swyctl login user:pass@gate:port -proxy no Identify the current user: # swyctl me user@gate:8686 (http) When logged in as admin, you can perform all actions described in the next sections for any other user. You can do this by either setting a user once: # swyctl me for another-user Or by specifying a username in each command with the # swyctl <op> <args> [-<option> <value> ...] -for another-user The name of another user, as well as some runtime data, is stored in the Working with FunctionsAdd a function: # swyctl fa <name> -src <path-to-file> List functions: # swyctl fl ID NAME STATE 5b3e3bcffd65c307ee564f6b foo ready 5b57535dfd65c37ce175da12 bar starting Print information about a specific function. Either by name, e.g., # swyctl fi foo Lang: python Version: 1 (1) State: ready ... Or by ID: # swyctl fi :<id> The important fields are Version is the sequence number typically bumped on source updates. The one or more numbers in braces indicate the currently running version. If it is smaller than the number before the braces, it means the function is being updated. States can be The Remove a function: # swyctl fd foo Update function sources: # swyctl fu foo -src <path-to-file> Note that the gate does not check that the Add an URL trigger or (e)vent for a function: # swyctl ea foo <trigger-name> <URL> Print triggers and information about them: # swyctl el foo 5b6a643efd65c36eb9828da0 <name> url # swyctl ei foo <name> Name: <name> Source: url URL: gate:8686/call/b4ee91f0a97615906a44420d311a2d8317867678022b42f824b6a36a9f09715f The same URL is shown in function information as well: # swyctl fi foo ... URL: gate:8686/call/b4...5f ... Check how the function works. Either with a query: # curl gate:8686/call/b4...5f?<args> Or with a body: # curl -H 'Content-Type: text/plain' -d <body> gate:8686/call/b4...5f # curl -H 'Content-Type: application/json' -d @<file-with-body> gate:8686/call/b4...5f Or with an exact method: # curl -X <method> gate:8686/call/b4...5f Working with Middleware (e.g., MongoDB)Add middleware: # swyctl ma <name> <type> List middleware: # swyctl ml ID NAME TYPE 5b50a1d6fd65c37b42265d64 x mongo 5b50a1d9fd65c37b42265d65 y maria Print information about middleware: # swyctl mi x Name: x Type: mongo Disk usage: 0 bytes The # swyctl mi :5b50a1d6fd65c37b42265d64 Attach middleware to a function by updating the function: # swyctl fu foo -mw +x Detach middleware from a function by updating the function: # swyctl fu foo -mw -x Attached middleware is also listed in function information: # swyctl fi foo ... Mware: x mongo (id:5b50a1d6fd65c37b42265d64) Working with Accounts (GitHub)Add an account. Either by name: # swyctl aa github -name <name> Or by personal access token (name will be resolved automatically): # swyctl aa github -token <value> List accounts: # swyctl al ID TYPE 5b684455fd65c3123a244380 github Print information about an account. Use ID as there are no name for accounts: # swyctl ai 5b684455fd65c3123a244380 Type: github GitHub name: <name> GitHub token: 2a79fc... Remove an account: # swyctl ad 5b684455fd65c3123a244380 Working with RepositoriesOnly GitHub is currently supported. Add a repo by URL: # swyctl ra https://github.com/xemul/repo.git Add a repo that is private to the account, so cloning is only possible with PAT: # swyctl ra https://github.com/xemul/privrepo.git -acc 5b684455fd65c3123a244380 List all repos accessible by the current user: # swyctl rl ID TYPE STATE URL 5b4ca23afd65c34a68c47e90 github ready https://github.com/xemul/repo.git 5b4d687efd65c30b73407196 github* ready https://github.com/xemul/priv-repo.git github unattached https://github.com/xemul/random-repo.git The presence of ID and the state If no ID is present and the state is List attached repos: # swyctl rl -at true ID TYPE STATE URL 5b4ca23afd65c34a68c47e90 github ready https://github.com/xemul/repo.git 5b4d687efd65c30b73407196 github* ready https://github.com/xemul/priv-repo.git List unattached repos: # swyctl rl -at false ID TYPE STATE URL github unattached https://github.com/xemul/random-repo.git Print repo contents: # swyctl rl <ID> .gitignore () .swifty.yml () README.md () functions/fn.py (python) functions/fn.go (golang) Pretty-print repo contents: # swyctl rl <ID> -pretty tree .gitignore () .swifty.yml () README.md () functions fn.py (python) fn.go (golang) Print repo contents descriptions if # swyctl rl <ID> -pretty desc Some demo functions Hello world: Golang hello-world example functions/fn.go (golang) Hello world: Python hello-world example functions/fn.py (python) Authorizing as a ServiceEnable authorization: # swyctl auth on Disable authorization: # swyctl auth off See authorization status. Since AaaS is a deployment, run # swyctl dl ID NAME 5b5b080efd65c3714310b76f simple_auth (3 items) auth # swyctl di simple_auth State: ready Items: simple_auth_um: function, ready simple_auth_jwt: mware, ready simple_auth_mgo: mware, ready Note that the same components can be accessed with Authorize a function: # swyctl fu foo -auth simple_auth_jwt
| |
|