Working with packages and allowed IPs.
giredorectl now able to interact with giredored about: * Setting package data. There is no such thing as "create" or "update", just set. * Deleting package data. * Setting allowed IP addresses. This is the only authorization method ATM, more may come in future.
This commit is contained in:
5
internal/structs/allowedips.go
Normal file
5
internal/structs/allowedips.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package structs
|
||||
|
||||
type AllowedIPsSetRequest struct {
|
||||
AllowedIPs []string
|
||||
}
|
12
internal/structs/error.go
Normal file
12
internal/structs/error.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package structs
|
||||
|
||||
const (
|
||||
ErrInvalidAllowedIPDefined Error = "Invalid allowed IP address defined."
|
||||
ErrIPAddressNotAllowed Error = "IP address not allowed to access configuration API."
|
||||
ErrPackageWasntDefined Error = "Passed package wasn't defined."
|
||||
ErrParsingAllowedIPsSetRequest Error = "Error parsing allowed IPs request."
|
||||
ErrParsingDeleteRequest Error = "Delete request parsing failed"
|
||||
ErrParsingPackagesGetRequest Error = "Error parsing package(s) info get request"
|
||||
)
|
||||
|
||||
type Error string
|
37
internal/structs/package.go
Normal file
37
internal/structs/package.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package structs
|
||||
|
||||
// Package defines structure for 'pkg set' request and for storing it's
|
||||
// data in configuration.
|
||||
type Package struct {
|
||||
// Description is an additional and optional description that
|
||||
// can be show on package's page.
|
||||
Description string
|
||||
// OriginalPath is a package original path without domain part.
|
||||
// E.g. for package "go.example.tld/group/pkgname" you should
|
||||
// put here "/group/pkgname".
|
||||
OriginalPath string
|
||||
// RealPath is a path where package will be found. It should
|
||||
// contain VCS path, e.g. "https://github.com/user/project.git".
|
||||
RealPath string
|
||||
// VCS is a versioning control system used for package. Everything
|
||||
// that is supported by "go get" is applicable.
|
||||
VCS string
|
||||
}
|
||||
|
||||
// PackageDeleteRequest defines structure for package deleting request.
|
||||
type PackageDeleteRequest struct {
|
||||
// OriginalPath is a package original path without domain part.
|
||||
// E.g. for package "go.example.tld/group/pkgname" you should
|
||||
// put here "/group/pkgname".
|
||||
OriginalPath string
|
||||
}
|
||||
|
||||
// PackageGetRequest defined structure for package information getting
|
||||
// request.
|
||||
type PackageGetRequest struct {
|
||||
// Should all packages be returned?
|
||||
All bool
|
||||
// If All = false, then what package name (or names) to return?
|
||||
// They should be delimited with comma in CLI.
|
||||
PackageNames []string
|
||||
}
|
9
internal/structs/reply.go
Normal file
9
internal/structs/reply.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package structs
|
||||
|
||||
// Reply defined reply data structure that giredored and giredorectl
|
||||
// will use.
|
||||
type Reply struct {
|
||||
Status Status
|
||||
Errors []Error
|
||||
Data interface{}
|
||||
}
|
8
internal/structs/status.go
Normal file
8
internal/structs/status.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package structs
|
||||
|
||||
const (
|
||||
StatusFailure Status = "failure"
|
||||
StatusSuccess Status = "success"
|
||||
)
|
||||
|
||||
type Status string
|
Reference in New Issue
Block a user