Add --type option for services across all 42 implementations
Support service_type for SRV records (minecraft, mumble, teamspeak, source, tcp, udp). Each implementation now parses --type and sends service_type in the JSON payload.
This commit is contained in:
parent
564e9e7075
commit
eb5d4ca8bf
42 changed files with 783 additions and 104 deletions
23
un.scm
23
un.scm
|
|
@ -172,7 +172,7 @@
|
|||
(display response)
|
||||
(newline))))))
|
||||
|
||||
(define (service-cmd action id name ports bootstrap)
|
||||
(define (service-cmd action id name ports bootstrap type)
|
||||
(let ((api-key (get-api-key)))
|
||||
(cond
|
||||
((equal? action "list")
|
||||
|
|
@ -196,7 +196,8 @@
|
|||
((and (equal? action "create") name)
|
||||
(let* ((ports-json (if ports (format #f ",\"ports\":[~a]" ports) ""))
|
||||
(bootstrap-json (if bootstrap (format #f ",\"bootstrap\":\"~a\"" (escape-json bootstrap)) ""))
|
||||
(json (format #f "{\"name\":\"~a\"~a~a}" name ports-json bootstrap-json))
|
||||
(type-json (if type (format #f ",\"service_type\":\"~a\"" type) ""))
|
||||
(json (format #f "{\"name\":\"~a\"~a~a~a}" name ports-json bootstrap-json type-json))
|
||||
(response (curl-post api-key "/services" json)))
|
||||
(format #t "~aService created~a\n" green reset)
|
||||
(display response)
|
||||
|
|
@ -222,24 +223,26 @@
|
|||
((equal? (car args) "service")
|
||||
(cond
|
||||
((and (> (length args) 1) (equal? (cadr args) "--list"))
|
||||
(service-cmd "list" #f #f #f #f))
|
||||
(service-cmd "list" #f #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--info"))
|
||||
(service-cmd "info" (caddr args) #f #f #f))
|
||||
(service-cmd "info" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--logs"))
|
||||
(service-cmd "logs" (caddr args) #f #f #f))
|
||||
(service-cmd "logs" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--sleep"))
|
||||
(service-cmd "sleep" (caddr args) #f #f #f))
|
||||
(service-cmd "sleep" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--wake"))
|
||||
(service-cmd "wake" (caddr args) #f #f #f))
|
||||
(service-cmd "wake" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--destroy"))
|
||||
(service-cmd "destroy" (caddr args) #f #f #f))
|
||||
(service-cmd "destroy" (caddr args) #f #f #f #f))
|
||||
((and (> (length args) 2) (equal? (cadr args) "--name"))
|
||||
(let ((name (caddr args))
|
||||
(ports (if (and (> (length args) 4) (equal? (list-ref args 3) "--ports"))
|
||||
(list-ref args 4) #f))
|
||||
(bootstrap (if (and (> (length args) 6) (equal? (list-ref args 5) "--bootstrap"))
|
||||
(list-ref args 6) #f)))
|
||||
(service-cmd "create" #f name ports bootstrap)))
|
||||
(list-ref args 6) #f))
|
||||
(type (if (and (> (length args) 8) (equal? (list-ref args 7) "--type"))
|
||||
(list-ref args 8) #f)))
|
||||
(service-cmd "create" #f name ports bootstrap type)))
|
||||
(else
|
||||
(display "Error: Invalid service command\n" (current-error-port))
|
||||
(exit 1))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue