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.

50 lines
1.3 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,
}
rc := &requestor.Config{
Logger: ccs.Logger,
Endpoints: []*requestor.Endpoint{endpoint},
}
return requestor.New(rc)
}
/*
######################################################################################################## @(°_°)@ #######
*/