Jobs & Workflows
https://armen.surge.sh
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
/* |
|
------------------------------------------------------------------------------------------------------------------------ |
|
####### cli ####### Copyright (c) 2021 mls-361 ##################################################### MIT License ####### |
|
------------------------------------------------------------------------------------------------------------------------ |
|
*/ |
|
|
|
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) { |
|
username := "cli" |
|
password, err := ccs.Crypto.EncryptString(username) |
|
if err != nil { |
|
return nil, errors.WithMessage(err, "unable to encrypt the requestor's username") ////////////////////////////// |
|
} |
|
|
|
cfg := ccs.Config.Server() |
|
scheme := "http" |
|
|
|
if cfg.TLS != nil { |
|
scheme += "s" |
|
} |
|
|
|
endpoint := &requestor.Endpoint{ |
|
URL: fmt.Sprintf("%s://localhost:%d", scheme, cfg.Port), |
|
Username: username, |
|
Password: password, |
|
} |
|
|
|
if cfg.TLS != nil { |
|
endpoint.CA = cfg.TLS.CA |
|
} |
|
|
|
rc := &requestor.Config{ |
|
Logger: ccs.Logger, |
|
Endpoints: []*requestor.Endpoint{endpoint}, |
|
} |
|
|
|
if cli := cfg.TLS.Cli; cli != nil { |
|
rc.Cert = cli.Cert |
|
rc.Key = cli.Key |
|
} |
|
|
|
return requestor.New(rc) |
|
} |
|
|
|
/* |
|
######################################################################################################## @(°_°)@ ####### |
|
*/
|
|
|