зеркало из https://github.com/mozilla/mig.git
[minor] add disable manifest functionality
This commit is contained in:
Родитель
58644787bf
Коммит
509b6dcaa0
|
@ -42,7 +42,7 @@ func manifestReader(input string, cli client.Client) (err error) {
|
|||
|
||||
prompt := fmt.Sprintf("\x1b[31;1mmanifest %d>\x1b[0m ", uint64(mid)%1000)
|
||||
for {
|
||||
var symbols = []string{"entry", "exit", "json", "r", "reset", "sign"}
|
||||
var symbols = []string{"disable", "entry", "exit", "json", "r", "reset", "sign"}
|
||||
readline.Completer = func(query, ctx string) []string {
|
||||
var res []string
|
||||
for _, sym := range symbols {
|
||||
|
@ -63,6 +63,12 @@ func manifestReader(input string, cli client.Client) (err error) {
|
|||
}
|
||||
orders := strings.Split(strings.TrimSpace(input), " ")
|
||||
switch orders[0] {
|
||||
case "disable":
|
||||
err = cli.ManifestRecordStatus(mr, "disabled")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Manifest record has been disabled")
|
||||
case "entry":
|
||||
mre, err := mr.ManifestResponse()
|
||||
if err != nil {
|
||||
|
|
|
@ -37,6 +37,16 @@ func (db *DB) ManifestAddSignature(mid float64, sig string, invid float64) (err
|
|||
return
|
||||
}
|
||||
|
||||
// Disable a manifest record
|
||||
func (db *DB) ManifestDisable(mid float64) (err error) {
|
||||
_, err = db.c.Exec(`UPDATE manifests SET status='disabled' WHERE
|
||||
id=$1`, mid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Update the status of a manifest based on the number of signatures it has
|
||||
func (db *DB) ManifestUpdateStatus(mid float64) (err error) {
|
||||
var cnt int
|
||||
|
@ -53,7 +63,7 @@ func (db *DB) ManifestUpdateStatus(mid float64) (err error) {
|
|||
_, err = db.c.Exec(`UPDATE manifests SET status=$1 WHERE
|
||||
id=$2`, status, mid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -64,17 +64,22 @@ func statusManifest(respWriter http.ResponseWriter, request *http.Request) {
|
|||
// could be added as well, active we don't want as this should
|
||||
// always be set by the API based on the number of valid signatures
|
||||
// applied to the record.
|
||||
if sts != "staged" {
|
||||
panic("Invalid status specified")
|
||||
}
|
||||
|
||||
err = ctx.DB.ManifestClearSignatures(manifestid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = ctx.DB.ManifestUpdateStatus(manifestid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if sts == "staged" {
|
||||
err = ctx.DB.ManifestClearSignatures(manifestid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = ctx.DB.ManifestUpdateStatus(manifestid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else if sts == "disabled" {
|
||||
err = ctx.DB.ManifestDisable(manifestid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic("Invalid status specified, must be disabled or staged")
|
||||
}
|
||||
|
||||
respond(200, resource, respWriter, request)
|
||||
|
|
Загрузка…
Ссылка в новой задаче