mirror of
https://github.com/dragonheim/gagent.git
synced 2025-01-18 04:56:28 -08:00
style: Adjusting Picol format / syntax to match modern standards.
This commit is contained in:
parent
7d6fbfef24
commit
083bd608ef
4 changed files with 39 additions and 117 deletions
126
.drone.yml
126
.drone.yml
|
@ -1,16 +1,11 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build amd64
|
||||
name: validation
|
||||
|
||||
platform:
|
||||
arch: amd64
|
||||
|
||||
# trigger:
|
||||
# branch:
|
||||
# exclude:
|
||||
# - main
|
||||
|
||||
clone:
|
||||
depth: 1
|
||||
|
||||
|
@ -20,100 +15,27 @@ volumes:
|
|||
path: /run/docker.sock
|
||||
|
||||
steps:
|
||||
- name: Build ${DRONE_REPO} Container Image On amd64
|
||||
image: plugins/docker
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
settings:
|
||||
auto_tag: false
|
||||
daemon_off: true
|
||||
debug: false
|
||||
dockerfile: docker/Dockerfile
|
||||
dry_run: true
|
||||
experimental: true
|
||||
mirror: "https://registry.dragonheim.net/"
|
||||
pull_image: false
|
||||
purge: true
|
||||
repo: ${DRONE_REPO}
|
||||
# target: development
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_auth
|
||||
- name: Format Code
|
||||
image: golang:1.16-alpine3.13
|
||||
# volumes:
|
||||
# - name: dockersock
|
||||
# path: /var/run/docker.sock
|
||||
commands:
|
||||
- go fmt ./...
|
||||
- go vet ./...
|
||||
- curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.18.2
|
||||
- trivy repo ${DRONE_GIT_HTTP_URL}
|
||||
|
||||
- name: Send Status To Datadog
|
||||
image: masci/drone-datadog
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: Datadog
|
||||
events:
|
||||
- title: "Build failure on amd64"
|
||||
text: "Build ${DRONE_BUILD_NUMBER}"
|
||||
alert_type: "error"
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build arm
|
||||
|
||||
platform:
|
||||
arch: arm
|
||||
|
||||
# trigger:
|
||||
# branch:
|
||||
# exclude:
|
||||
# - main
|
||||
|
||||
clone:
|
||||
depth: 1
|
||||
|
||||
volumes:
|
||||
- name: dockersock
|
||||
host:
|
||||
path: /run/docker.sock
|
||||
|
||||
steps:
|
||||
- name: Build ${DRONE_REPO} Container Image On arm
|
||||
image: plugins/docker
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: arm
|
||||
settings:
|
||||
auto_tag: false
|
||||
daemon_off: true
|
||||
debug: false
|
||||
dockerfile: docker/Dockerfile
|
||||
dry_run: true
|
||||
experimental: true
|
||||
mirror: "https://registry.dragonheim.net/"
|
||||
pull_image: false
|
||||
purge: true
|
||||
repo: ${DRONE_REPO}
|
||||
# target: development
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_auth
|
||||
|
||||
- name: Send Status To Datadog
|
||||
image: dragonheim/drone-datadog
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: Datadog
|
||||
events:
|
||||
- title: "Build failure on arm"
|
||||
text: "Build ${DRONE_BUILD_NUMBER}"
|
||||
alert_type: "error"
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
# - name: Send Status To Datadog
|
||||
# image: masci/drone-datadog
|
||||
# settings:
|
||||
# api_key:
|
||||
# from_secret: Datadog
|
||||
# events:
|
||||
# - title: "Build failure on amd64"
|
||||
# text: "Build ${DRONE_BUILD_NUMBER}"
|
||||
# alert_type: "error"
|
||||
# when:
|
||||
# status:
|
||||
# - failure
|
||||
#
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func ArityErr(i *Interp, name string, argv []string) error {
|
||||
return fmt.Errorf("Wrong number of args for %s %s", name, argv)
|
||||
return fmt.Errorf("wrong number of args for %s %s", name, argv)
|
||||
}
|
||||
|
||||
func CommandMath(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||
|
@ -104,9 +104,9 @@ func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error) {
|
|||
if r, _ := strconv.Atoi(result); r != 0 {
|
||||
result, err := i.Eval(argv[2])
|
||||
switch err {
|
||||
case PICOL_CONTINUE, nil:
|
||||
case errContinue, nil:
|
||||
//pass
|
||||
case PICOL_BREAK:
|
||||
case errBreak:
|
||||
return result, nil
|
||||
default:
|
||||
return result, err
|
||||
|
@ -123,9 +123,9 @@ func CommandRetCodes(i *Interp, argv []string, pd interface{}) (string, error) {
|
|||
}
|
||||
switch argv[0] {
|
||||
case "break":
|
||||
return "", PICOL_BREAK
|
||||
return "", errBreak
|
||||
case "continue":
|
||||
return "", PICOL_CONTINUE
|
||||
return "", errContinue
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
@ -152,12 +152,12 @@ func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) {
|
|||
}
|
||||
|
||||
if arity != len(argv)-1 {
|
||||
return "", fmt.Errorf("Proc '%s' called with wrong arg num", argv[0])
|
||||
return "", fmt.Errorf("proc '%s' called with wrong arg num", argv[0])
|
||||
}
|
||||
|
||||
body := x[1]
|
||||
result, err := i.Eval(body)
|
||||
if err == PICOL_RETURN {
|
||||
if err == errReturn {
|
||||
err = nil
|
||||
}
|
||||
return result, err
|
||||
|
@ -178,7 +178,7 @@ func CommandReturn(i *Interp, argv []string, pd interface{}) (string, error) {
|
|||
if len(argv) == 2 {
|
||||
r = argv[1]
|
||||
}
|
||||
return r, PICOL_RETURN
|
||||
return r, errReturn
|
||||
}
|
||||
|
||||
func CommandError(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||
|
@ -190,7 +190,7 @@ func CommandError(i *Interp, argv []string, pd interface{}) (string, error) {
|
|||
|
||||
func CommandPuts(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||
if len(argv) != 2 {
|
||||
return "", fmt.Errorf("Wrong number of args for %s %s", argv[0], argv)
|
||||
return "", fmt.Errorf("wrong number of args for %s %s", argv[0], argv)
|
||||
}
|
||||
fmt.Println(argv[1])
|
||||
return "", nil
|
||||
|
|
|
@ -246,5 +246,5 @@ func (p *Parser) GetToken() string {
|
|||
return p.parseString()
|
||||
}
|
||||
}
|
||||
return p.token() /* unreached */
|
||||
/* return p.token() /* unreached */
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
PICOL_RETURN = errors.New("RETURN")
|
||||
PICOL_BREAK = errors.New("BREAK")
|
||||
PICOL_CONTINUE = errors.New("CONTINUE")
|
||||
errReturn = errors.New("RETURN")
|
||||
errBreak = errors.New("BREAK")
|
||||
errContinue = errors.New("CONTINUE")
|
||||
)
|
||||
|
||||
type Var string
|
||||
|
@ -91,7 +91,7 @@ func (i *Interp) Eval(t string) (string, error) {
|
|||
case PT_VAR:
|
||||
v, ok := i.Var(t)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("No such variable '%s'", t)
|
||||
return "", fmt.Errorf("no such variable '%s'", t)
|
||||
}
|
||||
t = string(v)
|
||||
case PT_CMD:
|
||||
|
@ -114,7 +114,7 @@ func (i *Interp) Eval(t string) (string, error) {
|
|||
if len(argv) != 0 {
|
||||
c := i.Command(argv[0])
|
||||
if c == nil {
|
||||
return "", fmt.Errorf("No such command '%s'", argv[0])
|
||||
return "", fmt.Errorf("no such command '%s'", argv[0])
|
||||
}
|
||||
result, err = c.fn(i, argv, c.privdata)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue