mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Improved wording of comments a bit.
This commit is contained in:
parent
06d6d69755
commit
24710be9fe
1 changed files with 12 additions and 12 deletions
|
|
@ -55,14 +55,14 @@ type processor struct {
|
||||||
keyRing *crypto.KeyRing
|
keyRing *crypto.KeyRing
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pathes to the config ini file
|
// iniPaths are the potential file locations of the the config file.
|
||||||
var iniPaths = []string{
|
var iniPaths = []string{
|
||||||
"~/.config/csaf/uploader.ini",
|
"~/.config/csaf/uploader.ini",
|
||||||
"~/.csaf_uploader.ini",
|
"~/.csaf_uploader.ini",
|
||||||
"csaf_uploader.ini",
|
"csaf_uploader.ini",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the OpenPGP key
|
// loadKey loads an OpenPGP key.
|
||||||
func loadKey(filename string) (*crypto.Key, error) {
|
func loadKey(filename string) (*crypto.Key, error) {
|
||||||
f, err := os.Open(filename)
|
f, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -111,8 +111,8 @@ func newProcessor(opts *options) (*processor, error) {
|
||||||
return &p, nil
|
return &p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// httpClient Initializes the http client according
|
// httpClient initializes the http client according
|
||||||
// to the "Insecure" flag option and returns it
|
// to the "Insecure" flag option and returns it.
|
||||||
func (p *processor) httpClient() *http.Client {
|
func (p *processor) httpClient() *http.Client {
|
||||||
var client http.Client
|
var client http.Client
|
||||||
if p.opts.Insecure {
|
if p.opts.Insecure {
|
||||||
|
|
@ -125,7 +125,7 @@ func (p *processor) httpClient() *http.Client {
|
||||||
return &client
|
return &client
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeStrings prints the passed messages under the specific passed header
|
// writeStrings prints the passed messages under the specific passed header.
|
||||||
func writeStrings(header string, messages []string) {
|
func writeStrings(header string, messages []string) {
|
||||||
if len(messages) > 0 {
|
if len(messages) > 0 {
|
||||||
fmt.Println(header)
|
fmt.Println(header)
|
||||||
|
|
@ -135,8 +135,8 @@ func writeStrings(header string, messages []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create makes and sends the request for creating the initial files and directories
|
// create sends an request to create the initial files and directories
|
||||||
// It prints the response messages
|
// on the server. It prints the response messages.
|
||||||
func (p *processor) create() error {
|
func (p *processor) create() error {
|
||||||
req, err := http.NewRequest(http.MethodGet, p.opts.URL+"/api/create", nil)
|
req, err := http.NewRequest(http.MethodGet, p.opts.URL+"/api/create", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -172,9 +172,9 @@ func (p *processor) create() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpoladRequest creates the request for uploading a csaf document by passing the filename.
|
// uploadRequest creates the request for uploading a csaf document by passing the filename.
|
||||||
// According to the flags values the multipart sections of the request are established.
|
// According to the flags values the multipart sections of the request are established.
|
||||||
// It returns the created http request
|
// It returns the created http request.
|
||||||
func (p *processor) uploadRequest(filename string) (*http.Request, error) {
|
func (p *processor) uploadRequest(filename string) (*http.Request, error) {
|
||||||
data, err := os.ReadFile(filename)
|
data, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -257,8 +257,8 @@ func (p *processor) uploadRequest(filename string) (*http.Request, error) {
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// process calls the uploadRequest to establish the request and sends it.
|
// process attemps to upload a file filename to the server.
|
||||||
// It prints the response messages
|
// It prints the response messages.
|
||||||
func (p *processor) process(filename string) error {
|
func (p *processor) process(filename string) error {
|
||||||
|
|
||||||
req, err := p.uploadRequest(filename)
|
req, err := p.uploadRequest(filename)
|
||||||
|
|
@ -300,7 +300,7 @@ func (p *processor) process(filename string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findIniFile looks for a file in the pre-defined pathes in "iniPaths".
|
// findIniFile looks for a file in the pre-defined paths in "iniPaths".
|
||||||
// The returned value will be the name of file if found, otherwise an empty string.
|
// The returned value will be the name of file if found, otherwise an empty string.
|
||||||
func findIniFile() string {
|
func findIniFile() string {
|
||||||
for _, f := range iniPaths {
|
for _, f := range iniPaths {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue