-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cgi-ctl): add update manifest command
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/reddec/trusted-cgi/cmd/internal" | ||
internal2 "github.com/reddec/trusted-cgi/internal" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
type updateManifest struct { | ||
remoteLink | ||
UID string `short:"o" long:"uid" env:"UID" description:"Lambda UID (if empty - dirname of input will be used)"` | ||
} | ||
|
||
func (cmd *updateManifest) Execute(args []string) error { | ||
ctx, closer := internal.SignalContext() | ||
defer closer() | ||
wd, err := os.Getwd() | ||
if err != nil { | ||
return fmt.Errorf("detect work dir: %w", err) | ||
} | ||
if cmd.UID == "" { | ||
cmd.UID = filepath.Base(wd) | ||
} | ||
log.Println("lambda", cmd.UID) | ||
log.Println("login...") | ||
token, err := cmd.Token(ctx) | ||
if err != nil { | ||
return fmt.Errorf("login: %w", err) | ||
} | ||
log.Println("getting info...") | ||
info, err := cmd.Lambdas().Info(ctx, token, cmd.UID) | ||
if err != nil { | ||
return fmt.Errorf("get info: %w", err) | ||
} | ||
log.Println("saving...") | ||
err = info.Manifest.SaveAs(internal2.ManifestFile) | ||
if err != nil { | ||
return fmt.Errorf("update manifest file: %w", err) | ||
} | ||
log.Println("done") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
layout: default | ||
title: update manifest | ||
parent: Control util | ||
nav_order: 207 | ||
--- | ||
|
||
## update manifest | ||
|
||
Pulls remote lambda manifest and saves it locally. Useful to update only the configuration, while | ||
keeping files remotely unsynchronized with local environment. | ||
|
||
``` | ||
Usage: | ||
cgi-ctl [OPTIONS] update manifest [manifest-OPTIONS] | ||
Help Options: | ||
-h, --help Show this help message | ||
[manifest command options] | ||
-l, --login= Login name (default: admin) [$LOGIN] | ||
-p, --password= Password (default: admin) [$PASSWORD] | ||
-P, --ask-pass Get password from stdin [$ASK_PASS] | ||
-u, --url= Trusted-CGI endpoint (default: http://127.0.0.1:3434/) [$URL] | ||
--ghost Disable save credentials to user config dir [$GHOST] | ||
--independent Disable read credentials from user config dir [$INDEPENDENT] | ||
-o, --uid= Lambda UID (if empty - dirname of input will be used) [$UID] | ||
``` |