forked from vieter-v/vieter
Compare commits
No commits in common. "bb4406404db0db6a983f960bfc16b52f8691ab8f" and "641cf22669b8e75618b72ae8002f68c760748314" have entirely different histories.
bb4406404d
...
641cf22669
|
|
@ -7,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased](https://git.rustybever.be/vieter-v/vieter/src/branch/dev)
|
## [Unreleased](https://git.rustybever.be/vieter-v/vieter/src/branch/dev)
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
* CLI commands for removing packages, arch-repos & repositories
|
|
||||||
|
|
||||||
## [0.5.0-rc.2](https://git.rustybever.be/vieter-v/vieter/src/tag/0.5.0-rc.2)
|
## [0.5.0-rc.2](https://git.rustybever.be/vieter-v/vieter/src/tag/0.5.0-rc.2)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,10 @@ configuration variable required for each command.
|
||||||
([GitHub](https://github.com/Menci/docker-archlinuxarm)). This is the
|
([GitHub](https://github.com/Menci/docker-archlinuxarm)). This is the
|
||||||
image used for the Vieter CI builds.
|
image used for the Vieter CI builds.
|
||||||
* `max_log_age`: maximum age of logs (in days). Logs older than this will get
|
* `max_log_age`: maximum age of logs (in days). Logs older than this will get
|
||||||
cleaned by the log removal daemon. If set to zero, no logs are ever removed.
|
cleaned by the log removal daemon. If set to a negative value, no logs are
|
||||||
The age of logs is determined by the time the build was started.
|
ever removed. The age of logs is determined by the time the build was
|
||||||
* Default: `0`
|
started.
|
||||||
|
* Default: `-1`
|
||||||
* `log_removal_schedule`: cron schedule defining when to clean old logs.
|
* `log_removal_schedule`: cron schedule defining when to clean old logs.
|
||||||
* Default: `0 0` (every day at midnight)
|
* Default: `0 0` (every day at midnight)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,28 @@
|
||||||
module client
|
module client
|
||||||
|
|
||||||
import models { BuildLog, BuildLogFilter }
|
import models { BuildLog, BuildLogFilter }
|
||||||
|
import net.http { Method }
|
||||||
import web.response { Response }
|
import web.response { Response }
|
||||||
import time
|
import time
|
||||||
|
|
||||||
// get_build_logs returns all build logs.
|
// get_build_logs returns all build logs.
|
||||||
pub fn (c &Client) get_build_logs(filter BuildLogFilter) ![]BuildLog {
|
pub fn (c &Client) get_build_logs(filter BuildLogFilter) ![]BuildLog {
|
||||||
params := models.params_from(filter)
|
params := models.params_from(filter)
|
||||||
data := c.send_request<[]BuildLog>(.get, '/api/v1/logs', params)!
|
data := c.send_request<[]BuildLog>(Method.get, '/api/v1/logs', params)!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_build_log returns a specific build log.
|
// get_build_log returns a specific build log.
|
||||||
pub fn (c &Client) get_build_log(id int) !BuildLog {
|
pub fn (c &Client) get_build_log(id int) !BuildLog {
|
||||||
data := c.send_request<BuildLog>(.get, '/api/v1/logs/$id', {})!
|
data := c.send_request<BuildLog>(Method.get, '/api/v1/logs/$id', {})!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_build_log_content returns the contents of the build log file.
|
// get_build_log_content returns the contents of the build log file.
|
||||||
pub fn (c &Client) get_build_log_content(id int) !string {
|
pub fn (c &Client) get_build_log_content(id int) !string {
|
||||||
data := c.send_request_raw_response(.get, '/api/v1/logs/$id/content', {}, '')!
|
data := c.send_request_raw_response(Method.get, '/api/v1/logs/$id/content', {}, '')!
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +37,7 @@ pub fn (c &Client) add_build_log(target_id int, start_time time.Time, end_time t
|
||||||
'exitCode': exit_code.str()
|
'exitCode': exit_code.str()
|
||||||
}
|
}
|
||||||
|
|
||||||
data := c.send_request_with_body<int>(.post, '/api/v1/logs', params, content)!
|
data := c.send_request_with_body<int>(Method.post, '/api/v1/logs', params, content)!
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
module client
|
|
||||||
|
|
||||||
// remove_repo removes an entire repository.
|
|
||||||
pub fn (c &Client) remove_repo(repo string) ! {
|
|
||||||
c.send_request<string>(.delete, '/$repo', {})!
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove_arch_repo removes an entire arch-repo.
|
|
||||||
pub fn (c &Client) remove_arch_repo(repo string, arch string) ! {
|
|
||||||
c.send_request<string>(.delete, '/$repo/$arch', {})!
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove_package removes a single package from the given arch-repo.
|
|
||||||
pub fn (c &Client) remove_package(repo string, arch string, pkgname string) ! {
|
|
||||||
c.send_request<string>(.delete, '/$repo/$arch/$pkgname', {})!
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
module client
|
module client
|
||||||
|
|
||||||
import models { Target, TargetFilter }
|
import models { Target, TargetFilter }
|
||||||
|
import net.http { Method }
|
||||||
|
|
||||||
// get_targets returns a list of targets, given a filter object.
|
// get_targets returns a list of targets, given a filter object.
|
||||||
pub fn (c &Client) get_targets(filter TargetFilter) ![]Target {
|
pub fn (c &Client) get_targets(filter TargetFilter) ![]Target {
|
||||||
params := models.params_from(filter)
|
params := models.params_from(filter)
|
||||||
data := c.send_request<[]Target>(.get, '/api/v1/targets', params)!
|
data := c.send_request<[]Target>(Method.get, '/api/v1/targets', params)!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +34,7 @@ pub fn (c &Client) get_all_targets() ![]Target {
|
||||||
|
|
||||||
// get_target returns the target for a specific id.
|
// get_target returns the target for a specific id.
|
||||||
pub fn (c &Client) get_target(id int) !Target {
|
pub fn (c &Client) get_target(id int) !Target {
|
||||||
data := c.send_request<Target>(.get, '/api/v1/targets/$id', {})!
|
data := c.send_request<Target>(Method.get, '/api/v1/targets/$id', {})!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
@ -50,14 +51,14 @@ pub struct NewTarget {
|
||||||
// add_target adds a new target to the server.
|
// add_target adds a new target to the server.
|
||||||
pub fn (c &Client) add_target(t NewTarget) !int {
|
pub fn (c &Client) add_target(t NewTarget) !int {
|
||||||
params := models.params_from<NewTarget>(t)
|
params := models.params_from<NewTarget>(t)
|
||||||
data := c.send_request<int>(.post, '/api/v1/targets', params)!
|
data := c.send_request<int>(Method.post, '/api/v1/targets', params)!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove_target removes the target with the given id from the server.
|
// remove_target removes the target with the given id from the server.
|
||||||
pub fn (c &Client) remove_target(id int) !string {
|
pub fn (c &Client) remove_target(id int) !string {
|
||||||
data := c.send_request<string>(.delete, '/api/v1/targets/$id', {})!
|
data := c.send_request<string>(Method.delete, '/api/v1/targets/$id', {})!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +66,7 @@ pub fn (c &Client) remove_target(id int) !string {
|
||||||
// patch_target sends a PATCH request to the given target with the params as
|
// patch_target sends a PATCH request to the given target with the params as
|
||||||
// payload.
|
// payload.
|
||||||
pub fn (c &Client) patch_target(id int, params map[string]string) !string {
|
pub fn (c &Client) patch_target(id int, params map[string]string) !string {
|
||||||
data := c.send_request<string>(.patch, '/api/v1/targets/$id', params)!
|
data := c.send_request<string>(Method.patch, '/api/v1/targets/$id', params)!
|
||||||
|
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
module repos
|
|
||||||
|
|
||||||
import cli
|
|
||||||
import conf as vconf
|
|
||||||
import client
|
|
||||||
|
|
||||||
struct Config {
|
|
||||||
address string [required]
|
|
||||||
api_key string [required]
|
|
||||||
}
|
|
||||||
|
|
||||||
// cmd returns the cli module that handles modifying the repository contents.
|
|
||||||
pub fn cmd() cli.Command {
|
|
||||||
return cli.Command{
|
|
||||||
name: 'repos'
|
|
||||||
description: 'Interact with the repositories & packages stored on the server.'
|
|
||||||
commands: [
|
|
||||||
cli.Command{
|
|
||||||
name: 'remove'
|
|
||||||
required_args: 1
|
|
||||||
usage: 'repo [arch [pkgname]]'
|
|
||||||
description: 'Remove a repo, arch-repo, or package from the server.'
|
|
||||||
flags: [
|
|
||||||
cli.Flag{
|
|
||||||
name: 'force'
|
|
||||||
flag: cli.FlagType.bool
|
|
||||||
},
|
|
||||||
]
|
|
||||||
execute: fn (cmd cli.Command) ! {
|
|
||||||
config_file := cmd.flags.get_string('config-file')!
|
|
||||||
conf := vconf.load<Config>(prefix: 'VIETER_', default_path: config_file)!
|
|
||||||
|
|
||||||
if cmd.args.len < 3 {
|
|
||||||
if !cmd.flags.get_bool('force')! {
|
|
||||||
return error('Removing an arch-repo or repository is a very destructive command. If you really do wish to perform this operation, explicitely add the --force flag.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client := client.new(conf.address, conf.api_key)
|
|
||||||
|
|
||||||
if cmd.args.len == 1 {
|
|
||||||
client.remove_repo(cmd.args[0])!
|
|
||||||
} else if cmd.args.len == 2 {
|
|
||||||
client.remove_arch_repo(cmd.args[0], cmd.args[1])!
|
|
||||||
} else {
|
|
||||||
client.remove_package(cmd.args[0], cmd.args[1], cmd.args[2])!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,7 +8,6 @@ import console.logs
|
||||||
import console.schedule
|
import console.schedule
|
||||||
import console.man
|
import console.man
|
||||||
import console.aur
|
import console.aur
|
||||||
import console.repos
|
|
||||||
import cron
|
import cron
|
||||||
import agent
|
import agent
|
||||||
|
|
||||||
|
|
@ -49,7 +48,6 @@ fn main() {
|
||||||
man.cmd(),
|
man.cmd(),
|
||||||
aur.cmd(),
|
aur.cmd(),
|
||||||
agent.cmd(),
|
agent.cmd(),
|
||||||
repos.cmd(),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
app.setup()
|
app.setup()
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub:
|
||||||
default_arch string
|
default_arch string
|
||||||
global_schedule string = '0 3'
|
global_schedule string = '0 3'
|
||||||
base_image string = 'archlinux:base-devel'
|
base_image string = 'archlinux:base-devel'
|
||||||
max_log_age int [empty_default]
|
max_log_age int = -1
|
||||||
log_removal_schedule string = '0 0'
|
log_removal_schedule string = '0 0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue