Skip to content

Commit

Permalink
Merge branch 'kubeedge-main' into main
Browse files Browse the repository at this point in the history
Signed-off-by: zongke <zongk@shangyuantech.com>

# Conflicts:
#	pkg/modbus/device/twindata.go
  • Loading branch information
zongke committed Apr 20, 2021
2 parents 0d427ec + 13fa280 commit 2e4579d
Show file tree
Hide file tree
Showing 51 changed files with 1,947 additions and 211 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/fossa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: FOSSA
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.14.x"
- run: go version
# Runs a set of commands to initialize and analyze with FOSSA
- name: run FOSSA analysis
env:
# FOSSA Push-Only API Token
FOSSA_API_KEY: '87a9c35cbed49f802657f98b60134ee8'
run: |
export GOPATH=$HOME/go
export PATH=$PATH:$(go env GOPATH)/bin
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash
fossa init
fossa analyze
93 changes: 93 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Main CI WorkFlow

on:
push:
branches:
- main
tags:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Verify vendor, do lint
env:
GOPATH: /home/runner/work/${{ github.repository }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
path: ./src/github.com/${{ github.repository }}

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Install dependences
run: |
sudo apt-get install -y jq
- name: Run verify test
run: make verify
working-directory: ./src/github.com/${{ github.repository }}

- name: Run lint test
run: make lint
working-directory: ./src/github.com/${{ github.repository }}

build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Multiple build
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Install dependences
run: sudo apt-get install -y upx-ucl gcc-aarch64-linux-gnu libc6-dev-arm64-cross gcc-arm-linux-gnueabi libc6-dev-armel-cross

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- run: make

docker_build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Multiple docker image build
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- run: make modbusmapper_image

- run: make opcuamapper_image
65 changes: 65 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- vendor
- fake
- externalversions

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
uniq-by-line: true

linters-settings:
gci:
local-prefixes: github.com/kubeedge
misspell:
ignore-words:
- mosquitto

linters:
disable-all: true
enable:
- goconst
- errcheck
- gofmt
- golint
- gosimple
- govet
- misspell
- whitespace

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: pkg/opcua/driver/client.go
linters:
- gofmt

40 changes: 39 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,55 @@ all: modbusmapper opcuamapper

.PHONY: modbusmapper
modbusmapper:
go build -o ./pkg/modbus/modbus ./pkg/modbus
go build -o ./pkg/modbus/modbus ./pkg/modbus

.PHONY: modbusmapper_image
modbusmapper_image:modbusmapper
sudo docker build -t modbusmapper:v1.0 ./pkg/modbus

.PHONY: opcuamapper
opcuamapper:
go build -o ./pkg/opcua/opcua ./pkg/opcua

.PHONY: opcuamapper_image
opcuamapper_image:opcuamapper
sudo docker build -t opcuamapper:v1.0 ./pkg/opcua

clean:
rm -f ./pkg/modbus/modbus ./pkg/opcua/opcua

define VERIFY_HELP_INFO
# verify golang,vendor and codegen
#
# Example:
# make verify
endef
.PHONY: verify
ifeq ($(HELP),y)
verify:
@echo "$$VERIFY_HELP_INFO"
else
verify:verify-golang
endif

.PHONY: verify-golang
verify-golang:
hack/verify-golang.sh


define LINT_HELP_INFO
# run golang lint check.
#
# Example:
# make lint
# make lint HELP=y
endef
.PHONY: lint
ifeq ($(HELP),y)
lint:
@echo "$$LINT_HELP_INFO"
else
lint:
hack/make-rules/lint.sh
endif

63 changes: 63 additions & 0 deletions build/crd-samples/devices/CC2650-device-instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

apiVersion: devices.kubeedge.io/v1alpha2
kind: Device
metadata:
name: sensor-tag-instance-01
labels:
description: TISimplelinkSensorTag
manufacturer: TexasInstruments
model: cc2650-sensortag
spec:
deviceModelRef:
name: cc2650-sensortag
protocol:
bluetooth:
macAddress: "BC:6A:29:AE:CC:96" #pls note it is optional to provide MAC address
nodeSelector:
nodeSelectorTerms:
- matchExpressions:
- key: ''
operator: In
values:
- edge-node1 #pls give your edge node name
propertyVisitors:
- propertyName: temperature
bluetooth:
characteristicUUID: f000aa0104514000b000000000000000
dataConverter:
startIndex: 1
endIndex: 0
shiftRight: 2
orderOfOperations:
- operationType: Multiply
operationValue: 0.03125
- propertyName: temperature-enable
bluetooth:
characteristicUUID: f000aa0204514000b000000000000000
dataWrite:
"ON": [1] #Here "ON" refers to the value of the property "temperature-enable" and [1] refers to the corresponding []byte value to be written into the device when the value of temperature-enable is "ON"
"OFF": [0]
- propertyName: io-config-initialize
bluetooth:
characteristicUUID: f000aa6604514000b000000000000000
- propertyName: io-data-initialize
bluetooth:
characteristicUUID: f000aa6504514000b000000000000000
- propertyName: io-config
bluetooth:
characteristicUUID: f000aa6604514000b000000000000000
- propertyName: io-data
bluetooth:
characteristicUUID: f000aa6504514000b000000000000000
dataWrite:
"Red": [1] #Here "Red" refers to the value of the property "io-data" and [1] refers to the corresponding []byte value to be written into the device when the value of io-data is "Red"
"Green": [2]
"RedGreen": [3]
"Buzzer": [4]
"BuzzerRed": [5]
"BuzzerGreen": [6]
"BuzzerRedGreen": [7]
status:
twins:
- propertyName: temperature-enable
- propertyName: io-data
44 changes: 44 additions & 0 deletions build/crd-samples/devices/CC2650-device-model.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: devices.kubeedge.io/v1alpha2
kind: DeviceModel
metadata:
name: cc2650-sensortag
namespace: default
spec:
properties:
- name: temperature
description: temperature in degree celsius
type:
int:
accessMode: ReadOnly
maximum: 100
unit: degree celsius
- name: temperature-enable
description: enable data collection of temperature sensor
type:
string:
accessMode: ReadWrite
defaultValue: 'ON'
- name: io-config-initialize
description: initialize io-config with value 0
type:
int:
accessMode: ReadWrite
defaultValue: 0
- name: io-data-initialize
description: initialize io-data with value 0
type:
int:
accessMode: ReadWrite
defaultValue: 0
- name: io-config
description: register activation of io-config
type:
int:
accessMode: ReadWrite
defaultValue: 1
- name: io-data
description: data field to control io-control
type:
int:
accessMode: ReadWrite
defaultValue: 0
Loading

0 comments on commit 2e4579d

Please sign in to comment.