mirror of
https://github.com/dragonheim/gagent.git
synced 2025-04-26 08:08:58 -07: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
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build amd64
|
name: validation
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
# trigger:
|
|
||||||
# branch:
|
|
||||||
# exclude:
|
|
||||||
# - main
|
|
||||||
|
|
||||||
clone:
|
clone:
|
||||||
depth: 1
|
depth: 1
|
||||||
|
|
||||||
|
@ -20,100 +15,27 @@ volumes:
|
||||||
path: /run/docker.sock
|
path: /run/docker.sock
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Build ${DRONE_REPO} Container Image On amd64
|
- name: Format Code
|
||||||
image: plugins/docker
|
image: golang:1.16-alpine3.13
|
||||||
volumes:
|
# volumes:
|
||||||
- name: dockersock
|
# - name: dockersock
|
||||||
path: /var/run/docker.sock
|
# path: /var/run/docker.sock
|
||||||
environment:
|
commands:
|
||||||
GOOS: linux
|
- go fmt ./...
|
||||||
GOARCH: amd64
|
- go vet ./...
|
||||||
settings:
|
- curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.18.2
|
||||||
auto_tag: false
|
- trivy repo ${DRONE_GIT_HTTP_URL}
|
||||||
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
|
# - name: Send Status To Datadog
|
||||||
image: masci/drone-datadog
|
# image: masci/drone-datadog
|
||||||
settings:
|
# settings:
|
||||||
api_key:
|
# api_key:
|
||||||
from_secret: Datadog
|
# from_secret: Datadog
|
||||||
events:
|
# events:
|
||||||
- title: "Build failure on amd64"
|
# - title: "Build failure on amd64"
|
||||||
text: "Build ${DRONE_BUILD_NUMBER}"
|
# text: "Build ${DRONE_BUILD_NUMBER}"
|
||||||
alert_type: "error"
|
# alert_type: "error"
|
||||||
when:
|
# when:
|
||||||
status:
|
# status:
|
||||||
- failure
|
# - 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
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ArityErr(i *Interp, name string, argv []string) error {
|
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) {
|
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 {
|
if r, _ := strconv.Atoi(result); r != 0 {
|
||||||
result, err := i.Eval(argv[2])
|
result, err := i.Eval(argv[2])
|
||||||
switch err {
|
switch err {
|
||||||
case PICOL_CONTINUE, nil:
|
case errContinue, nil:
|
||||||
//pass
|
//pass
|
||||||
case PICOL_BREAK:
|
case errBreak:
|
||||||
return result, nil
|
return result, nil
|
||||||
default:
|
default:
|
||||||
return result, err
|
return result, err
|
||||||
|
@ -123,9 +123,9 @@ func CommandRetCodes(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||||
}
|
}
|
||||||
switch argv[0] {
|
switch argv[0] {
|
||||||
case "break":
|
case "break":
|
||||||
return "", PICOL_BREAK
|
return "", errBreak
|
||||||
case "continue":
|
case "continue":
|
||||||
return "", PICOL_CONTINUE
|
return "", errContinue
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,12 @@ func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if arity != len(argv)-1 {
|
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]
|
body := x[1]
|
||||||
result, err := i.Eval(body)
|
result, err := i.Eval(body)
|
||||||
if err == PICOL_RETURN {
|
if err == errReturn {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
return result, err
|
return result, err
|
||||||
|
@ -178,7 +178,7 @@ func CommandReturn(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||||
if len(argv) == 2 {
|
if len(argv) == 2 {
|
||||||
r = argv[1]
|
r = argv[1]
|
||||||
}
|
}
|
||||||
return r, PICOL_RETURN
|
return r, errReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
func CommandError(i *Interp, argv []string, pd interface{}) (string, error) {
|
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) {
|
func CommandPuts(i *Interp, argv []string, pd interface{}) (string, error) {
|
||||||
if len(argv) != 2 {
|
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])
|
fmt.Println(argv[1])
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|
|
@ -246,5 +246,5 @@ func (p *Parser) GetToken() string {
|
||||||
return p.parseString()
|
return p.parseString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p.token() /* unreached */
|
/* return p.token() /* unreached */
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
PICOL_RETURN = errors.New("RETURN")
|
errReturn = errors.New("RETURN")
|
||||||
PICOL_BREAK = errors.New("BREAK")
|
errBreak = errors.New("BREAK")
|
||||||
PICOL_CONTINUE = errors.New("CONTINUE")
|
errContinue = errors.New("CONTINUE")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Var string
|
type Var string
|
||||||
|
@ -91,7 +91,7 @@ func (i *Interp) Eval(t string) (string, error) {
|
||||||
case PT_VAR:
|
case PT_VAR:
|
||||||
v, ok := i.Var(t)
|
v, ok := i.Var(t)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("No such variable '%s'", t)
|
return "", fmt.Errorf("no such variable '%s'", t)
|
||||||
}
|
}
|
||||||
t = string(v)
|
t = string(v)
|
||||||
case PT_CMD:
|
case PT_CMD:
|
||||||
|
@ -114,7 +114,7 @@ func (i *Interp) Eval(t string) (string, error) {
|
||||||
if len(argv) != 0 {
|
if len(argv) != 0 {
|
||||||
c := i.Command(argv[0])
|
c := i.Command(argv[0])
|
||||||
if c == nil {
|
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)
|
result, err = c.fn(i, argv, c.privdata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue