Browse Source

En cours de développement

master
mls-361 9 months ago
parent
commit
8cd53eb71f
  1. 2
      go.mod
  2. 4
      go.sum
  3. 6
      internal/api/api.go
  4. 16
      internal/cli/cli.go
  5. 11
      internal/cli/jobs.go
  6. 29
      internal/cli/loggers.go
  7. 3
      internal/cli/requestor.go

2
go.mod

@ -6,7 +6,7 @@ require (
forge.chapril.org/armen/jw v0.0.0-20210818151220-edd8f137c57a
forge.chapril.org/armen/memory v0.0.0-20210818151319-7833375304b3
forge.chapril.org/armen/model v0.0.0-20210818151340-5240fd23add0
forge.chapril.org/armen/requestor v0.0.0-20210818152630-57a59637bb94
forge.chapril.org/armen/requestor v0.0.0-20210818162048-0aff3c672ef4
forge.chapril.org/armen/runner v0.0.0-20210818151447-f3652512c45d
forge.chapril.org/armen/workers v0.0.0-20210818151509-2e23246740d1
forge.chapril.org/mls-361/application v0.0.0-20210805205753-c663b93b7e1a

4
go.sum

@ -6,8 +6,8 @@ forge.chapril.org/armen/memory v0.0.0-20210818151319-7833375304b3 h1:u48zZxALcdS
forge.chapril.org/armen/memory v0.0.0-20210818151319-7833375304b3/go.mod h1:xyl3FV9dHJficKKFfN2CUXYs9tCMmaqsYxxQNuBwE9E=
forge.chapril.org/armen/model v0.0.0-20210818151340-5240fd23add0 h1:wVhb7mYJkZrx/Xtk9b9/DWV2fDS45+Yj2JgKHe9j/tQ=
forge.chapril.org/armen/model v0.0.0-20210818151340-5240fd23add0/go.mod h1:vboGfVFhFMfEonHWaOkQqiEGbODOBbNWr0I4Dp3R3O4=
forge.chapril.org/armen/requestor v0.0.0-20210818152630-57a59637bb94 h1:DUulTDYG/b6M+t6TPzHuyJPpgypJt/j1G0WtL/wpx/w=
forge.chapril.org/armen/requestor v0.0.0-20210818152630-57a59637bb94/go.mod h1:mzGQhobQAY4mxaULS9gDL04Fi/yIwPijmW3CIopujjw=
forge.chapril.org/armen/requestor v0.0.0-20210818162048-0aff3c672ef4 h1:nd56YmxR7wbW8ksyoRRe4dCvrw+yVJX062qmkurSHnk=
forge.chapril.org/armen/requestor v0.0.0-20210818162048-0aff3c672ef4/go.mod h1:mzGQhobQAY4mxaULS9gDL04Fi/yIwPijmW3CIopujjw=
forge.chapril.org/armen/runner v0.0.0-20210818151447-f3652512c45d h1:/X+rSbB043fdImXZ4PW4XsjrbmUbxk2lYGcj2ZKd6ec=
forge.chapril.org/armen/runner v0.0.0-20210818151447-f3652512c45d/go.mod h1:UElsW53JSF14TlZWr+Z1WYlRTXf90UNSBCq6WOzE8cE=
forge.chapril.org/armen/workers v0.0.0-20210818151509-2e23246740d1 h1:gpTGo6Abo4BrXFr9BZxHuNyyGMchI33hGvKVeUPbkr8=

6
internal/api/api.go

@ -13,6 +13,7 @@ import (
"forge.chapril.org/armen/model"
"forge.chapril.org/mls-361/errors"
"forge.chapril.org/mls-361/jsonapi"
"forge.chapril.org/mls-361/logger"
"forge.chapril.org/mls-361/uuid"
"forge.chapril.org/armen/armen/internal/components"
@ -49,6 +50,10 @@ func (api *api) trace(hf jsonapi.HandlerFunc) jsonapi.Handler {
)
}
func (api *api) loggers(r *jsonapi.Request) {
r.RenderJSON(http.StatusOK, logger.GetAll(), api.logger)
}
func (api *api) createJob(r *jsonapi.Request) {
job := new(jw.Job)
@ -141,6 +146,7 @@ func Build(ccs *components.Components) {
api := newAPI(ccs)
router := ccs.Router
router.GetJSON("/api/loggers", api.debug(api.loggers))
router.PostJSON("/api/job/create", api.debug(api.createJob))
router.GetJSON("/api/job/next/:namespace", api.trace(api.nextJob))
router.PutJSON("/api/job/update", api.debug(api.updateJob))

16
internal/cli/cli.go

@ -7,6 +7,7 @@
package cli
import (
"encoding/json"
"flag"
"fmt"
"io"
@ -26,6 +27,18 @@ func newFlagSet(ccs *components.Components) *flag.FlagSet {
return fs
}
func displayResult(result interface{}) error {
data, err := json.MarshalIndent(result, "", "\t")
if err != nil {
fmt.Printf("%+v\n\n", result)
return err
}
fmt.Println(string(data))
return nil
}
func decrypt(args []string, ccs *components.Components) error {
if len(args) != 1 {
help()
@ -89,6 +102,7 @@ The commands are:
-run_after <datetime> (RFC3339)
-retries <int>
-category <string>
loggers
version
--@(°_°)@-------------------------------
@ -104,6 +118,8 @@ func Run(args []string, ccs *components.Components) error {
return encrypt(args[1:], ccs)
case "jobs":
return jobs(args[1:], ccs)
case "loggers":
return loggers(args[1:], ccs)
case "version":
version(ccs)
default:

11
internal/cli/jobs.go

@ -9,7 +9,6 @@ package cli
import (
"encoding/json"
"errors"
"fmt"
"time"
"forge.chapril.org/armen/jw"
@ -77,15 +76,7 @@ func jobCreate(args []string, ccs *components.Components) error {
return err
}
data, err := json.MarshalIndent(job, "", " ")
if err != nil {
fmt.Printf("%+v\n\n", job)
return err
}
fmt.Println(string(data))
return nil
return displayResult(job)
}
func jobs(args []string, ccs *components.Components) error {

29
internal/cli/loggers.go

@ -0,0 +1,29 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### cli ####### Copyright (c) 2021 mls-361 ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package cli
import (
"forge.chapril.org/armen/armen/internal/components"
)
func loggers(_ []string, ccs *components.Components) error {
requestor, err := newRequestor(ccs)
if err != nil {
return err
}
loggers, err := requestor.Loggers()
if err != nil {
return err
}
return displayResult(loggers)
}
/*
######################################################################################################## @(°_°)@ #######
*/

3
internal/cli/requestor.go

@ -9,14 +9,13 @@ package cli
import (
"fmt"
"forge.chapril.org/armen/jw"
"forge.chapril.org/armen/requestor"
"forge.chapril.org/mls-361/errors"
"forge.chapril.org/armen/armen/internal/components"
)
func newRequestor(ccs *components.Components) (jw.Model, error) {
func newRequestor(ccs *components.Components) (requestor.Requestor, error) {
username := "cli"
password, err := ccs.Crypto.EncryptString(username)
if err != nil {

Loading…
Cancel
Save