Skip to content

Commit

Permalink
Merge pull request #1 from johnlettman/devel
Browse files Browse the repository at this point in the history
Development sync 1
  • Loading branch information
johnlettman authored Jul 16, 2024
2 parents 0c67a5a + 4f545da commit cb758f2
Show file tree
Hide file tree
Showing 24 changed files with 1,441 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
labels:
- "CI/CD"
commit-message:
prefix: "ci: "
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
branches: [ main, devel ]
pull_request:
branches: [ main ]
paths-ignore:
- "**/*.md"
- "**/*.py"
- "LICENSE"

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
uses: robherley/go-test-action@v0
with:
testArguments: -covermode=atomic -coverprofile=coverage.out ./...
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
on:
push:
branches: [main, devel]
pull_request:
branches: [main]
paths-ignore:
- "**/*.md"
- "**/*.py"
- "LICENSE"
workflow_dispatch:
inputs:
head:
description: "Git commit to publish documentation for."
required: true
type: string

jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Setup Node
uses: actions/setup-node@v4
- name: Generate documentation
run: |
npm install pagefind --prefix .
export PAGEFIND="./node_modules/.bin/pagefind"
go install go.abhg.dev/doc2go@latest
doc2go -out docs -pagefind="${PAGEFIND}" ./...
- name: Upload documentation
uses: actions/upload-artifact@v1
with:
name: documentation
path: docs
- name: Upload pages
if: github.ref == 'refs/heads/devel'
uses: actions/upload-pages-artifact@v1
with:
path: docs

publish:
name: Publish pages website
needs: build

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub pages
if: github.ref == 'refs/heads/devel'
id: deployment
uses: actions/deploy-pages@v1

15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### Testing
# Local samples
samples/

### Documentation
# Generated docs
docs/

### Node.js
# Logs
npm-debug.log*

# Dependency directories
node_modules/

### JetBrains
# User-specific stuff
.idea/**/workspace.xml
Expand Down
27 changes: 27 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module github.com/johnlettman/oyster

go 1.22.5

require (
github.com/barweiss/go-tuple v1.1.2
github.com/ungerik/go3d v0.0.0-20240502073936-1137f6adf7e9
gonum.org/v1/gonum v0.15.0
)

require (
github.com/agiledragon/gomonkey/v2 v2.12.0
github.com/brianvoe/gofakeit/v7 v7.0.4
github.com/google/gopacket v1.1.19
github.com/gookit/goutil v0.6.15
github.com/johnlettman/buffergenerics v0.0.0-20240713034920-8ec5b0a7ac46
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
55 changes: 55 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
github.com/agiledragon/gomonkey/v2 v2.12.0 h1:ek0dYu9K1rSV+TgkW5LvNNPRWyDZVIxGMCFI6Pz9o38=
github.com/agiledragon/gomonkey/v2 v2.12.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY=
github.com/barweiss/go-tuple v1.1.2 h1:ul9tIW0LZ5w+Vk/Hi3X9z3JyqkD0yaVGZp+nNTLW2YE=
github.com/barweiss/go-tuple v1.1.2/go.mod h1:SpoVilkI7ycNrIkQxcQfS1JG5A+R40sWwEUlPONlp3k=
github.com/brianvoe/gofakeit/v7 v7.0.4 h1:Mkxwz9jYg8Ad8NvT9HA27pCMZGFQo08MK6jD0QTKEww=
github.com/brianvoe/gofakeit/v7 v7.0.4/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
github.com/gookit/goutil v0.6.15 h1:mMQ0ElojNZoyPD0eVROk5QXJPh2uKR4g06slgPDF5Jo=
github.com/gookit/goutil v0.6.15/go.mod h1:qdKdYEHQdEtyH+4fNdQNZfJHhI0jUZzHxQVAV3DaMDY=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/johnlettman/buffergenerics v0.0.0-20240713034920-8ec5b0a7ac46 h1:wzEFdKuHGwzhKqyBAVZga3UBDTvVJhVMI2J9kmaITdY=
github.com/johnlettman/buffergenerics v0.0.0-20240713034920-8ec5b0a7ac46/go.mod h1:+MfOwzy5m3FiRgGnUs1uE1I7EMzu5obrrJaRkRYqCWA=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ungerik/go3d v0.0.0-20240502073936-1137f6adf7e9 h1:wMWP16Ijw+W+IXGcAzrwQDua1NBB4tP8iWECpg5DVRQ=
github.com/ungerik/go3d v0.0.0-20240502073936-1137f6adf7e9/go.mod h1:ipEjrk2uLK4xX8ivWBPIVOD0fMtKyPI0strluUfIlYQ=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ=
gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
95 changes: 95 additions & 0 deletions types/auto-start-flag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package types

import (
"github.com/johnlettman/oyster/types/pseudo"
"strings"
)

// AutoStartFlag represents a boolean flag used for enabling or disabling auto-start functionality.
//
// For additional information, refer to [Ouster docs: Standby Operating Mode Examples].
//
// Warning:
//
// AutoStartFlag has been deprecated with firmware v2.4 and later.
// Usage of AutoStartFlag in firmware prior to v2.0.0 has unexpected behavior.
//
// [Ouster docs: Standby Operating Mode Examples]: https://static.ouster.dev/sensor-docs/image_route1/image_route2/sensor_operations/sensor-operations.html#standby-operating-mode-examples
type AutoStartFlag pseudo.IntBoolJSON

const (
AutoStartOn AutoStartFlag = true // Equivalent to OperatingMode "NORMAL"
AutoStartOff AutoStartFlag = false // Equivalent to OperatingMode "STANDBY"
)

// String returns the string representation of an AutoStartFlag.
func (a AutoStartFlag) String() string {
switch a {
default:
fallthrough
case AutoStartOn:
return "auto start on"
case AutoStartOff:
return "auto start off"
}
}

// GoString returns the Go syntax representation of an AutoStartFlag.
func (a AutoStartFlag) GoString() string {
switch a {
default:
fallthrough
case AutoStartOn:
return "AutoStartOn"
case AutoStartOff:
return "AutoStartOff"
}
}

// MarshalText returns the text representation of an AutoStartFlag.
// - If the AutoStartFlag is AutoStartOff, it returns "off";
// - otherwise, it returns "on".
//
// It always returns nil, indicating no error occurred.
func (a AutoStartFlag) MarshalText() ([]byte, error) {
switch a {
default:
fallthrough
case AutoStartOn:
return []byte("on"), nil
case AutoStartOff:
return []byte("off"), nil
}
}

// UnmarshalText parses the provided text and assigns the corresponding value to the receiver.
// The method converts the input text to lowercase.
// - If the text is 'off', it assigns AutoStartOff to the receiver.
// - For any other text, it assigns AutoStartOn to the receiver.
//
// It always returns nil error, indicating no error occurred.
func (a *AutoStartFlag) UnmarshalText(text []byte) error {
switch strings.ToLower(string(text)) {
default:
fallthrough
case "on":
*a = AutoStartOn
case "off":
*a = AutoStartOff
}

return nil
}

// MarshalJSON converts AutoStartFlag to JSON format using pseudo.IntBoolJSON.MarshalJSON method.
// It returns the JSON bytes and any occurred error.
func (a AutoStartFlag) MarshalJSON() ([]byte, error) {
return (*pseudo.IntBoolJSON)(&a).MarshalJSON()
}

// UnmarshalJSON converts the JSON data into the AutoStartFlag value.
// It leverages the pseudo.IntBoolJSON.UnmarshalJSON method to perform the actual unmarshaling.
// It returns any occurred error.
func (a *AutoStartFlag) UnmarshalJSON(data []byte) error {
return (*pseudo.IntBoolJSON)(a).UnmarshalJSON(data)
}
Loading

0 comments on commit cb758f2

Please sign in to comment.