diff options
| author | cai6489 <144650622+cai6489@users.noreply.github.com> | 2023-11-28 15:10:04 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-28 15:10:04 +0800 |
| commit | bf325d652156ed9207293c1ad65b0212a79b84c7 (patch) | |
| tree | 399309f2006774dcde38651d39c79cbc1bd8337c /staging | |
| parent | update codegen (diff) | |
| parent | Merge pull request #5207 from wbc6080/update-go-version (diff) | |
| download | kubeedge-bf325d652156ed9207293c1ad65b0212a79b84c7.tar.gz | |
Merge branch 'master' into v1beta1-dmi
Diffstat (limited to 'staging')
14 files changed, 76 insertions, 64 deletions
diff --git a/staging/src/github.com/kubeedge/beehive/go.mod b/staging/src/github.com/kubeedge/beehive/go.mod index 6c2dc7291..9a94a8344 100644 --- a/staging/src/github.com/kubeedge/beehive/go.mod +++ b/staging/src/github.com/kubeedge/beehive/go.mod @@ -1,6 +1,6 @@ module github.com/kubeedge/beehive -go 1.19 +go 1.20 require ( github.com/google/uuid v1.2.0 diff --git a/staging/src/github.com/kubeedge/mapper-framework/OWNERS b/staging/src/github.com/kubeedge/mapper-framework/OWNERS new file mode 100644 index 000000000..6b3f122b1 --- /dev/null +++ b/staging/src/github.com/kubeedge/mapper-framework/OWNERS @@ -0,0 +1,9 @@ +approvers: + - cl2017 + - fisherxu + - WillardHu +reviewers: + - cl2017 + - fisherxu + - wbc6080 + - WillardHu diff --git a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/Dockerfile b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/Dockerfile index 1afa4316f..8feae0900 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/Dockerfile +++ b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17-alpine AS builder +FROM golang:1.20.10-alpine3.18 AS builder WORKDIR /build @@ -10,7 +10,7 @@ COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -o main cmd/main.go -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN mkdir -p kubeedge diff --git a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/cmd/main.go b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/cmd/main.go index 3ca00fb82..2f398d589 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/cmd/main.go +++ b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/cmd/main.go @@ -9,9 +9,9 @@ import ( "github.com/kubeedge/Template/device" "github.com/kubeedge/Template/pkg/common" "github.com/kubeedge/Template/pkg/config" + "github.com/kubeedge/Template/pkg/grpcclient" "github.com/kubeedge/Template/pkg/grpcserver" "github.com/kubeedge/Template/pkg/httpserver" - "github.com/kubeedge/Template/pkg/util/grpcclient" "github.com/kubeedge/Template/pkg/util/parse" ) @@ -50,7 +50,7 @@ func main() { // if dev init mode is register, mapper's dev will init when registry to edgecore if c.DevInit.Mode != common.DevInitModeRegister { klog.Infoln("======dev init mode is not register, will register to edgecore") - if _, _, err = grpcclient.RegisterMapper(&c, false); err != nil { + if _, _, err = grpcclient.RegisterMapper(false); err != nil { klog.Fatal(err) } klog.Infoln("registerMapper finished") diff --git a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/device.go b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/device.go index af1b027a0..3769c1a8c 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/device.go +++ b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/device.go @@ -131,6 +131,7 @@ func dataHandler(ctx context.Context, dev *driver.CustomizedDev) { VisitorConfig: &visitorConfig, Topic: fmt.Sprintf(common.TopicTwinUpdate, dev.Instance.ID), CollectCycle: time.Duration(twin.Property.CollectCycle), + ReportToCloud: twin.Property.ReportToCloud, } go twinData.Run(ctx) // handle push method @@ -366,7 +367,7 @@ func (d *DevPanel) DevInit(cfg *config.Config) error { // return err // } case common.DevInitModeRegister: - if err := parse.ParseByUsingRegister(cfg, devs, d.models, d.protocols); err != nil { + if err := parse.ParseByUsingRegister(devs, d.models, d.protocols); err != nil { return err } } diff --git a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/devicetwin.go b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/devicetwin.go index 062e608f6..5df21570e 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/devicetwin.go +++ b/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/device/devicetwin.go @@ -12,7 +12,7 @@ import ( "github.com/kubeedge/Template/driver" "github.com/kubeedge/Template/pkg/common" dmiapi "github.com/kubeedge/Template/pkg/dmi-api" - "github.com/kubeedge/Template/pkg/util/grpcclient" + "github.com/kubeedge/Template/pkg/grpcclient" "github.com/kubeedge/Template/pkg/util/parse" ) @@ -26,6 +26,7 @@ type TwinData struct { Topic string Results interface{} CollectCycle time.Duration + ReportToCloud bool } func (td *TwinData) GetPayLoad() ([]byte, error) { @@ -87,6 +88,9 @@ func (td *TwinData) PushToEdgeCore() { } func (td *TwinData) Run(ctx context.Context) { + if !td.ReportToCloud { + return + } if td.CollectCycle == 0 { td.CollectCycle = 1 * time.Second } diff --git a/staging/src/github.com/kubeedge/mapper-framework/go.mod b/staging/src/github.com/kubeedge/mapper-framework/go.mod index 32db07c1b..f5d6eb7b2 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/go.mod +++ b/staging/src/github.com/kubeedge/mapper-framework/go.mod @@ -1,6 +1,6 @@ module github.com/kubeedge/Template -go 1.17 +go 1.20 require ( github.com/golang/protobuf v1.5.2 diff --git a/staging/src/github.com/kubeedge/mapper-framework/go.sum b/staging/src/github.com/kubeedge/mapper-framework/go.sum index 1ae584393..40950bf40 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/go.sum +++ b/staging/src/github.com/kubeedge/mapper-framework/go.sum @@ -64,12 +64,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= 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/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -77,8 +75,6 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -88,10 +84,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -101,8 +94,6 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 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= @@ -112,21 +103,12 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -137,8 +119,6 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/grpcclient/config.go b/staging/src/github.com/kubeedge/mapper-framework/pkg/grpcclient/config.go index 7de4d6233..7de4d6233 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/grpcclient/config.go +++ b/staging/src/github.com/kubeedge/mapper-framework/pkg/grpcclient/config.go diff --git a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/grpcclient/register.go b/staging/src/github.com/kubeedge/mapper-framework/pkg/grpcclient/register.go index 3f577f956..f582de56e 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/grpcclient/register.go +++ b/staging/src/github.com/kubeedge/mapper-framework/pkg/grpcclient/register.go @@ -9,12 +9,11 @@ import ( "google.golang.org/grpc" "github.com/kubeedge/Template/pkg/common" - "github.com/kubeedge/Template/pkg/config" dmiapi "github.com/kubeedge/Template/pkg/dmi-api" ) // RegisterMapper if withData is true, edgecore will send device and model list. -func RegisterMapper(cfg *config.Config, withData bool) ([]*dmiapi.Device, []*dmiapi.DeviceModel, error) { +func RegisterMapper(withData bool) ([]*dmiapi.Device, []*dmiapi.DeviceModel, error) { // connect grpc server conn, err := grpc.Dial(cfg.Common.EdgeCoreSock, grpc.WithInsecure(), diff --git a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/grpcclient/report.go b/staging/src/github.com/kubeedge/mapper-framework/pkg/grpcclient/report.go index 4e18d9b82..4e18d9b82 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/grpcclient/report.go +++ b/staging/src/github.com/kubeedge/mapper-framework/pkg/grpcclient/report.go diff --git a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go b/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go index 20308e532..a88d7778a 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go +++ b/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/grpc.go @@ -76,26 +76,18 @@ func BuildProtocolFromGrpc(device *dmiapi.Device) (common.ProtocolConfig, error) } func buildTwinsFromGrpc(device *dmiapi.Device) []common.Twin { - if len(device.Status.Twins) == 0 { + if len(device.Spec.Properties) == 0 { return nil } - res := make([]common.Twin, 0, len(device.Status.Twins)) - for _, twin := range device.Status.Twins { + res := make([]common.Twin, 0, len(device.Spec.Properties)) + for _, property := range device.Spec.Properties { cur := common.Twin{ - PropertyName: twin.PropertyName, - + PropertyName: property.Name, ObservedDesired: common.TwinProperty{ - Value: twin.ObservedDesired.Value, - Metadata: common.Metadata{ - Timestamp: twin.ObservedDesired.Metadata["timestamp"], - Type: twin.ObservedDesired.Metadata["type"], - }, - }, - Reported: common.TwinProperty{ - Value: twin.Reported.Value, + Value: property.Desired.Value, Metadata: common.Metadata{ - Timestamp: twin.ObservedDesired.Metadata["timestamp"], - Type: twin.ObservedDesired.Metadata["type"], + Timestamp: property.Desired.Metadata["timestamp"], + Type: property.Desired.Metadata["type"], }, }, } @@ -138,20 +130,48 @@ func buildPropertiesFromGrpc(device *dmiapi.Device) []common.DeviceProperty { // get dbMethod filed by grpc device instance var dbMethodName string var dbconfig common.DBConfig - if pptv.PushMethod.DBMethod != nil { - dbMethodName, err = getDBMethodFromGrpc(pptv) + var pushMethod []byte + var pushMethodName string + if pptv.PushMethod != nil { + if pptv.PushMethod.DBMethod != nil { + dbMethodName, err = getDBMethodFromGrpc(pptv) + if err != nil { + klog.Errorf("err: %+v", err) + return nil + } + switch dbMethodName { + case "influx": + clientconfig, err := json.Marshal(pptv.PushMethod.DBMethod.Influxdb2.Influxdb2ClientConfig) + if err != nil { + klog.Errorf("err: %+v", err) + return nil + } + dataconfig, err := json.Marshal(pptv.PushMethod.DBMethod.Influxdb2.Influxdb2DataConfig) + if err != nil { + klog.Errorf("err: %+v", err) + return nil + } + dbconfig = common.DBConfig{ + Influxdb2ClientConfig: clientconfig, + Influxdb2DataConfig: dataconfig, + } + } + } + // get pushMethod filed by grpc device instance + pushMethodName, err = getPushMethodFromGrpc(pptv) if err != nil { klog.Errorf("err: %+v", err) return nil } - switch dbMethodName { - case "influx": - clientconfig, err := json.Marshal(pptv.PushMethod.DBMethod.Influxdb2.Influxdb2ClientConfig) + switch pushMethodName { + case "http": + pushMethod, err = json.Marshal(pptv.PushMethod.Http) if err != nil { klog.Errorf("err: %+v", err) return nil } - dataconfig, err := json.Marshal(pptv.PushMethod.DBMethod.Influxdb2.Influxdb2DataConfig) + case "mqtt": + pushMethod, err = json.Marshal(pptv.PushMethod.Mqtt) if err != nil { klog.Errorf("err: %+v", err) return nil @@ -205,13 +225,14 @@ func buildPropertiesFromGrpc(device *dmiapi.Device) []common.DeviceProperty { // get the final Properties cur := common.DeviceProperty{ - Name: pptv.GetName(), - PropertyName: pptv.GetName(), - ModelName: device.Spec.DeviceModelReference, - CollectCycle: pptv.GetCollectCycle(), - ReportCycle: pptv.GetReportCycle(), - Protocol: protocolName, - Visitors: visitorConfig, + Name: pptv.GetName(), + PropertyName: pptv.GetName(), + ModelName: device.Spec.DeviceModelReference, + CollectCycle: pptv.GetCollectCycle(), + ReportCycle: pptv.GetReportCycle(), + ReportToCloud: pptv.GetReportToCloud(), + Protocol: protocolName, + Visitors: visitorConfig, PushMethod: common.PushMethodConfig{ MethodName: pushMethodName, MethodConfig: pushMethod, diff --git a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/parse.go b/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/parse.go index 6c02d9a7f..74558bbd8 100644 --- a/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/parse.go +++ b/staging/src/github.com/kubeedge/mapper-framework/pkg/util/parse/parse.go @@ -22,17 +22,15 @@ import ( "k8s.io/klog/v2" "github.com/kubeedge/Template/pkg/common" - "github.com/kubeedge/Template/pkg/config" - "github.com/kubeedge/Template/pkg/util/grpcclient" + "github.com/kubeedge/Template/pkg/grpcclient" ) var ErrEmptyData error = errors.New("device or device model list is empty") -func ParseByUsingRegister(cfg *config.Config, - devices map[string]*common.DeviceInstance, +func ParseByUsingRegister(devices map[string]*common.DeviceInstance, dms map[string]common.DeviceModel, protocols map[string]common.ProtocolConfig) error { - deviceList, deviceModelList, err := grpcclient.RegisterMapper(cfg, true) + deviceList, deviceModelList, err := grpcclient.RegisterMapper(true) if err != nil { return err } diff --git a/staging/src/github.com/kubeedge/viaduct/go.mod b/staging/src/github.com/kubeedge/viaduct/go.mod index b65edad25..ea1808ef0 100644 --- a/staging/src/github.com/kubeedge/viaduct/go.mod +++ b/staging/src/github.com/kubeedge/viaduct/go.mod @@ -1,6 +1,6 @@ module github.com/kubeedge/viaduct -go 1.19 +go 1.20 require ( github.com/golang/mock v1.5.0 |
