-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Latest improvements to serverless (#1255)
* Add support for typescript in the nodejs runtime (#1225) * Eliminate plugin usage for sls fn invoke (#1226) * Add doctl serverless trigger support (for scheduled functions) (#1232) * Add support for triggers * Add lastRun field to trigger list output * Hide commands we won't be supporting in EA day 1 * Bump deployer version to pick up bug fix * Fix error handling in services related to triggers Many calls were not checking for errors. * Switch to latest API Change both the triggers command (native to doctl) and the deployer version (which affects the semantics of deploy/undeploy). * Pick up latest deployer (triggers bug fix) * Remove support for prototype API and clean up code * Fix unit tests * Fix misleading comment * Remove added complexity due to successive change * Add filtering by function when listing triggers * Fix omitted code in DeleteTrigger * Guard triggers get/list with status check Otherwise, the credentials read fails with a cryptic error instead of an informative one when you are not connected to a namespace. Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com>
- Loading branch information
1 parent
1d61603
commit ac179f5
Showing
25 changed files
with
1,008 additions
and
101 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
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,71 @@ | ||
/* | ||
Copyright 2018 The Doctl Authors All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package displayers | ||
|
||
import ( | ||
"io" | ||
"time" | ||
|
||
"github.com/digitalocean/doctl/do" | ||
) | ||
|
||
// Triggers is the type of the displayer for triggers list | ||
type Triggers struct { | ||
List []do.ServerlessTrigger | ||
} | ||
|
||
var _ Displayable = &Triggers{} | ||
|
||
// JSON is the displayer JSON method specialized for triggers list | ||
func (i *Triggers) JSON(out io.Writer) error { | ||
return writeJSON(i.List, out) | ||
} | ||
|
||
// Cols is the displayer Cols method specialized for triggers list | ||
func (i *Triggers) Cols() []string { | ||
return []string{"Name", "Cron", "Function", "Enabled", "LastRun"} | ||
} | ||
|
||
// ColMap is the displayer ColMap method specialized for triggers list | ||
func (i *Triggers) ColMap() map[string]string { | ||
return map[string]string{ | ||
"Name": "Name", | ||
"Cron": "Cron Expression", | ||
"Function": "Invokes", | ||
"Enabled": "Enabled", | ||
"LastRun": "Last Run At", | ||
} | ||
} | ||
|
||
// KV is the displayer KV method specialized for triggers list | ||
func (i *Triggers) KV() []map[string]interface{} { | ||
out := make([]map[string]interface{}, 0, len(i.List)) | ||
for _, ii := range i.List { | ||
lastRunTime, err := time.Parse(time.RFC3339, ii.LastRun) | ||
lastRun := "_" | ||
if err == nil { | ||
lastRun = lastRunTime.Local().Format("01/02 03:04:05") | ||
} | ||
x := map[string]interface{}{ | ||
"Name": ii.Name, | ||
"Cron": ii.Cron, | ||
"Function": ii.Function, | ||
"Enabled": ii.Enabled, | ||
"LastRun": lastRun, | ||
} | ||
out = append(out, x) | ||
} | ||
|
||
return out | ||
} |
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
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
Oops, something went wrong.