diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md
new file mode 100644
index 0000000..ea689a8
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug-report.md
@@ -0,0 +1,30 @@
+---
+name: Bug Report
+about: Create a report to help us improve
+title: "[BUG]"
+labels: kind/bug
+
+---
+
+
+
+
+**What happened**:
+
+**What you expected to happen**:
+
+**How to reproduce it (as minimally and precisely as possible)**:
+
+**Anything else we need to know?**:
+
+**Environment**:
+- OpenYurt version:
+- Kubernetes version (use `kubectl version`):
+- OS (e.g: `cat /etc/os-release`):
+- Kernel (e.g. `uname -a`):
+- Install tools:
+- Others:
+
+**others**
+
+/kind bug
diff --git a/.github/ISSUE_TEMPLATE/failing-test.md b/.github/ISSUE_TEMPLATE/failing-test.md
new file mode 100644
index 0000000..b64d0df
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/failing-test.md
@@ -0,0 +1,24 @@
+---
+name: Failing Test
+about: Report continuously failing tests or jobs in Kubernetes CI
+labels: kind/failing-test
+
+---
+
+
+
+#### Which jobs are failing:
+
+#### Which test(s) are failing:
+
+#### Since when has it been failing:
+
+#### Testgrid link:
+
+#### Reason for failure:
+
+#### Anything else we need to know:
+
+#### labels
+
+/kind failing-test
diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md
new file mode 100644
index 0000000..64d18a0
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.md
@@ -0,0 +1,18 @@
+---
+name: Feature Request
+about: Suggest an idea for this project
+title: "[feature request]"
+labels: kind/feature
+
+---
+
+
+
+**What would you like to be added**:
+
+
+**Why is this needed**:
+
+
+**others**
+/kind feature
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
new file mode 100644
index 0000000..3b9b050
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -0,0 +1,28 @@
+---
+name: Question
+about: Question about OpenYurt.
+title: "[Question]"
+labels: kind/question
+
+---
+
+
+
+**What happened**:
+
+**What you expected to happen**:
+
+**How to reproduce it (as minimally and precisely as possible)**:
+
+**Anything else we need to know?**:
+
+**Environment**:
+- OpenYurt version:
+- Kubernetes version (use `kubectl version`):
+- OS (e.g: `cat /etc/os-release`):
+- Kernel (e.g. `uname -a`):
+- Install tools:
+- Others:
+
+**others**
+/kind question
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..dd9e9f5
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,53 @@
+
+
+
+#### What type of PR is this?
+> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespace from that line:
+> /kind bug
+> /kind documentation
+> /kind enhancement
+> /kind good-first-issue
+> /kind feature
+> /kind question
+> /kind design
+> /sig ai
+> /sig iot
+> /sig network
+> /sig storage
+
+
+
+#### What this PR does / why we need it:
+
+#### Which issue(s) this PR fixes:
+
+Fixes #
+
+#### Special notes for your reviewer:
+
+
+
+#### Does this PR introduce a user-facing change?
+
+```release-note
+
+```
+
+#### other Note
+
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644
index 0000000..831f010
--- /dev/null
+++ b/.github/workflows/ci.yaml
@@ -0,0 +1,73 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - main
+ - release-*
+ pull_request: {}
+ workflow_dispatch: {}
+
+env:
+ # Common versions
+ GO_VERSION: '1.16'
+ GOLANGCI_VERSION: 'v1.40'
+
+jobs:
+ check-license:
+ runs-on: ubuntu-18.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run Check License
+ run: hack/make-rules/check_license.sh
+
+ golangci-lint:
+ runs-on: ubuntu-18.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Setup Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ env.GO_VERSION }}
+ - name: Lint golang code
+ uses: golangci/golangci-lint-action@v2
+ with:
+ version: ${{ env.GOLANGCI_VERSION }}
+ args: --disable-all -E deadcode -E gofmt -E goimports -E ineffassign -E misspell -E vet --timeout=15m
+
+ markdownlint-misspell-shellcheck:
+ runs-on: ubuntu-18.04
+ # this image is build from Dockerfile
+ # https://github.com/pouchcontainer/pouchlinter/blob/master/Dockerfile
+ container: pouchcontainer/pouchlinter:v0.1.2
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run misspell
+ run: find ./* -name "*" | xargs misspell -error
+ - name: Lint markdown files
+ run: find ./ -name "*.md" | grep -v enhancements | grep -v .github | xargs mdl -r ~MD010,~MD013,~MD014,~MD022,~MD024,~MD029,~MD031,~MD032,~MD033,~MD034,~MD036
+ build-binaries:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Fetch History
+ run: git fetch --prune --unshallow
+ - name: Setup Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ env.GO_VERSION }}
+ - name: Cache Go Dependencies
+ uses: actions/cache@v2
+ with:
+ path: ~/go/pkg/mod
+ key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
+ restore-keys: ${{ runner.os }}-go-
+ - name: Build All Binaries
+ run: make build
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..464fab1
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,12 @@
+approvers:
+ - charleszheng44
+ - qclc
+ - Peeknut
+ - rambohe-ch
+ - yixingjia
+reviewers:
+ - charleszheng44
+ - qclc
+ - Peeknut
+ - rambohe-ch
+ - yixingjia
\ No newline at end of file
diff --git a/README.md b/README.md
index b43865b..e6f4bf0 100644
--- a/README.md
+++ b/README.md
@@ -12,9 +12,9 @@ For details of the design, please see the [document](https://github.com/openyurt
## Architecture
-Yurt-device-controller introduces an approach leverages existing edge computing platforms, like EdgeX Foundry, and uses Kubernetes custom resources to abstract edge devices.
-Inspiring by the Unix philosophy, "Do one thing and do it well", we believe that Kubernetes should focus on managing computing resources while edge devices management can be done by adopting existing edge computing platforms.
-Therefore, we define several generic custom resource definitions(CRD) that act as the mediator between OpenYurt and the edge platform.
+Yurt-device-controller introduces an approach leverages existing edge computing platforms, like EdgeX Foundry, and uses Kubernetes custom resources to abstract edge devices.
+Inspiring by the Unix philosophy, "Do one thing and do it well", we believe that Kubernetes should focus on managing computing resources while edge devices management can be done by adopting existing edge computing platforms.
+Therefore, we define several generic custom resource definitions(CRD) that act as the mediator between OpenYurt and the edge platform.
Any existing edge platforms can be integrated into the OpenYurt by implementing custom controllers for these CRDs. These CRDS and corresponding controllers allow users to manage edge devices in a declarative way, which provides users with a Kubernetes-native experience and reduces the complexity of managing, operating and maintaining edge platform devices.
![yurt-device-controller-architecture](docs/img/yurt-device-controller-architecture.png)
@@ -48,7 +48,6 @@ Contributions are welcome, whether by creating new issues or pull requests. See
-
## License
Yurt-device-controller is under the Apache 2.0 license. See the [LICENSE](LICENSE) file for details. Certain implementations in Yurt-device-controller rely on the existing code from [Kubernetes](https://github.com/kubernetes/kubernetes) and [OpenKruise](https://github.com/openkruise/kruise) the credits go to the original authors.
\ No newline at end of file
diff --git a/clients/interface.go b/clients/interface.go
index f40c470..ada1dd0 100644
--- a/clients/interface.go
+++ b/clients/interface.go
@@ -18,6 +18,7 @@ package clients
import (
"context"
+
"github.com/openyurtio/device-controller/api/v1alpha1"
)
diff --git a/controllers/deviceprofile_syncer.go b/controllers/deviceprofile_syncer.go
index 7742d47..d6b9bbc 100644
--- a/controllers/deviceprofile_syncer.go
+++ b/controllers/deviceprofile_syncer.go
@@ -118,7 +118,7 @@ func (ds *DeviceProfileSyncer) Run(stop <-chan struct{}) {
}
func addNodePoolField(edgeXDevs []devicev1alpha1.DeviceProfile, NodePoolName string) {
- for i, _ := range edgeXDevs {
+ for i := range edgeXDevs {
edgeXDevs[i].Spec.NodePool = NodePoolName
}
}
diff --git a/controllers/suite_test.go b/controllers/suite_test.go
index ecad843..46efdc6 100644
--- a/controllers/suite_test.go
+++ b/controllers/suite_test.go
@@ -37,7 +37,7 @@ import (
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
-var cfg *rest.Config
+var _ *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
diff --git a/docs/img/yurt-device-controller-architecture.png b/docs/img/yurt-device-controller-architecture.png
index 708c0f4..756b5e7 100644
Binary files a/docs/img/yurt-device-controller-architecture.png and b/docs/img/yurt-device-controller-architecture.png differ
diff --git a/docs/yurt-device-controller-tutorial.md b/docs/yurt-device-controller-tutorial.md
index a640a37..609870d 100644
--- a/docs/yurt-device-controller-tutorial.md
+++ b/docs/yurt-device-controller-tutorial.md
@@ -85,13 +85,13 @@ spec:
terminationGracePeriodSeconds: 10
topology:
pools:
- - name: hangzhou
+ - name: hangzhou
nodeSelectorTerm:
matchExpressions:
- key: apps.openyurt.io/nodepool
operator: In
values:
- - hangzhou
+ - hangzhou
replicas: 1
tolerations:
- effect: NoSchedule
@@ -143,8 +143,6 @@ This tutorial shows how to manipulate object instances in the Edgex Foundry by u
EOF
```
-
-
2. Create a deviceProfile
```bash
@@ -184,8 +182,6 @@ This tutorial shows how to manipulate object instances in the Edgex Foundry by u
EOF
```
-
-
3. Create a device
Create a device using the deviceService and deviceProfile created above:
@@ -211,8 +207,6 @@ This tutorial shows how to manipulate object instances in the Edgex Foundry by u
EOF
```
-
-
### Delete Device, DeviceService, DeviceProfile
The deletion operation is very simple, you can delete device, deviceService and deviceProfile just like deleting ordinary K8S objects:
@@ -239,7 +233,7 @@ The following operation uses `random-boolean-device` device, which is automatica
NAME AGE
hangzhou-random-boolean-device 23h
hangzhou-random-integer-device 23h
-
+
$ kubectl describe device hangzhou-random-boolean-device
Name: hangzhou-random-boolean-device
Namespace: default
@@ -298,8 +292,6 @@ The following operation uses `random-boolean-device` device, which is automatica
Events:
```
-
-
2. Set the `managed` field of device to `true`
The `Device.Spec.Managed` field determines whether the cloud can set the property value of the edge device. The cloud can successfully set device properties only if `managed=true`:
@@ -375,8 +367,6 @@ The following operation uses `random-boolean-device` device, which is automatica
Synced: true
```
-
-
4. Change the `operatingState` of device
> The operating state (aka op state) provides an indication on the part of EdgeX about the internal operating status of the device service. The operating state is not set externally (as by another system or man), it is a signal from within EdgeX (and potentially the device service itself) about the condition of the service. The operating state of the device service may be either enabled or disabled. When the operating state of the device service is disabled, it is either experiencing some difficulty or going through some process (for example an upgrade) which does not allow it to function in its normal capacity.
@@ -405,14 +395,12 @@ The following operation uses `random-boolean-device` device, which is automatica
Synced: true
```
-
-
5. Set the deviceProperties
```bash
# Ensure adminState = UNLOCKED
$ kubectl patch devices.device.openyurt.io hangzhou-random-boolean-device -p '{"spec":{"adminState":"UNLOCKED"}}' --type=merge
-
+
# Ensure operatingState = ENABLED
$ kubectl patch devices.device.openyurt.io hangzhou-random-boolean-device -p '{"spec":{"operatingState":"ENABLED"}}' --type=merge
```
@@ -460,8 +448,8 @@ The following operation uses `random-boolean-device` device, which is automatica
"spec":{
"deviceProperties":{
"Bool":{
- "desiredValue":"false",
- "name":"Bool",
+ "desiredValue":"false",
+ "name":"Bool",
"putURL":"http://edgex-core-command:48082/api/v1/device/07b0d343-cc07-43ff-afb1-6a2792d48b7f/command/9a61a8d5-7c15-4d1b-b552-15b7879d9fc8"
}
}
@@ -474,7 +462,7 @@ The following operation uses `random-boolean-device` device, which is automatica
```bash
$ kubectl get service | grep edgex-core-command
edgex-core-command NodePort 10.96.39.34 48082:30082/TCP 39h
-
+
$ curl http://10.96.39.34:48082/api/v1/device/07b0d343-cc07-43ff-afb1-6a2792d48b7f/command/9a61a8d5-7c15-4d1b-b552-15b7879d9fc8
{"device":"random-boolean-device","origin":1632378327952106491,"readings":[{"origin":1632378327951971484,"device":"random-boolean-device","name":"Bool","value":"false","valueType":"Bool"}],"EncodedEvent":null}
```
@@ -491,4 +479,3 @@ The following operation uses `random-boolean-device` device, which is automatica
$ cd yurt-device-controller
$ make docker-build IMG=
```
-
diff --git a/hack/make-rules/check_license.sh b/hack/make-rules/check_license.sh
new file mode 100755
index 0000000..41b76cf
--- /dev/null
+++ b/hack/make-rules/check_license.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+# Copyright 2021 The OpenYurt Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# exit immediately when a command fails
+set -e
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
+# error on unset variables
+set -u
+
+licRes=$(
+ find . -type f -regex '.*\.go\|.*\.sh' ! -path '*/vendor/*' -exec \
+ sh -c 'head -n4 $1 | grep -Eq "(Copyright|generated|GENERATED)" || echo -e $1' {} {} \;
+)
+
+if [ -n "${licRes}" ]; then
+ echo -e "license header checking failed:\\n${licRes}"
+ exit 255
+fi
\ No newline at end of file