Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrate Camera Management example to V3 #214

Merged
merged 16 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions application-services/custom/camera-management/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ APPVERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)

# This pulls the version of the SDK from the go.mod file. If the SDK is the only required module,
# it must first remove the word 'required' so the offset of $2 is the same if there are multiple required modules
SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/app-functions-sdk-go/v2 v' | sed 's/require//g' | awk '{print $$2}')
SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/app-functions-sdk-go/v3 v' | sed 's/require//g' | awk '{print $$2}')

MICROSERVICE=app-camera-management
GOFLAGS=-ldflags "-X github.com/edgexfoundry/app-functions-sdk-go/v2/internal.SDKVersion=$(SDKVERSION) -X github.com/edgexfoundry/app-functions-sdk-go/v2/internal.ApplicationVersion=$(APPVERSION)"
GOFLAGS=-ldflags "-X github.com/edgexfoundry/app-functions-sdk-go/v3/internal.SDKVersion=$(SDKVERSION) -X github.com/edgexfoundry/app-functions-sdk-go/v3/internal.ApplicationVersion=$(APPVERSION)"

GIT_SHA=$(shell git rev-parse HEAD)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"net/http"
"sync"

"github.com/edgexfoundry/app-functions-sdk-go/v2/pkg/interfaces"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
"github.com/edgexfoundry/app-functions-sdk-go/v3/pkg/interfaces"
"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/logger"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -67,7 +67,7 @@ func (app *CameraManagementApp) Run() error {
}
}

if err = app.service.MakeItRun(); err != nil {
if err = app.service.Run(); err != nil {
return errors.Wrap(err, "failed to run pipeline")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ package appcamera
import (
"context"
"fmt"

"github.com/IOTechSystems/onvif/device"
"github.com/IOTechSystems/onvif/media"
"github.com/IOTechSystems/onvif/ptz"
"github.com/IOTechSystems/onvif/xsd/onvif"
"github.com/edgexfoundry/go-mod-core-contracts/v2/dtos"
dtosCommon "github.com/edgexfoundry/go-mod-core-contracts/v2/dtos/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
dtosCommon "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
"github.com/pkg/errors"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package appcamera

import (
"github.com/edgexfoundry/go-mod-bootstrap/v2/config"
"github.com/edgexfoundry/go-mod-core-contracts/v2/errors"
"github.com/edgexfoundry/go-mod-bootstrap/v3/config"
"github.com/edgexfoundry/go-mod-core-contracts/v3/errors"
)

const (
Expand All @@ -19,7 +19,7 @@ const (
// tryGetCredentials will attempt one time to get the camera credentials from the
// secret provider and return them, otherwise return an error.
func (app *CameraManagementApp) tryGetCredentials() (config.Credentials, errors.EdgeX) {
secretData, err := app.service.GetSecret(CameraCredentials, UsernameKey, PasswordKey)
secretData, err := app.service.SecretProvider().GetSecret(CameraCredentials, UsernameKey, PasswordKey)
if err != nil {
return config.Credentials{}, errors.NewCommonEdgeXWrapper(err)
}
Expand Down
10 changes: 5 additions & 5 deletions application-services/custom/camera-management/appcamera/evam.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"net/url"
"path"

"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/common"

"github.com/IOTechSystems/onvif/media"
"github.com/edgexfoundry/app-functions-sdk-go/v2/pkg/interfaces"
"github.com/edgexfoundry/go-mod-core-contracts/v2/dtos"
"github.com/edgexfoundry/app-functions-sdk-go/v3/pkg/interfaces"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -245,11 +245,11 @@ func (app *CameraManagementApp) processEdgeXDeviceSystemEvent(_ interfaces.AppFu
}

switch systemEvent.Action {
case common.DeviceSystemEventActionAdd:
case common.SystemEventActionAdd:
if err = app.startDefaultPipeline(device); err != nil {
return false, err
}
case common.DeviceSystemEventActionDelete:
case common.SystemEventActionDelete:
// stop any running pipelines for the deleted device
if info, found := app.getPipelineInfo(device.Name); found {
if err = app.stopPipeline(device.Name, info.Id); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"net/http"
"path"

dtosCommon "github.com/edgexfoundry/go-mod-core-contracts/v2/dtos/common"
dtosCommon "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
"github.com/gorilla/mux"

"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
"github.com/pkg/errors"
)

Expand Down
21 changes: 11 additions & 10 deletions application-services/custom/camera-management/appcamera/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/http/utils"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
"github.com/edgexfoundry/go-mod-core-contracts/v2/dtos"
"github.com/edgexfoundry/go-mod-core-contracts/v2/dtos/responses"
"github.com/pkg/errors"
"io"
"net/http"

"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/http/utils"
"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/logger"
"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/responses"
"github.com/pkg/errors"
)

const (
Expand Down Expand Up @@ -60,7 +61,7 @@ func (app *CameraManagementApp) issueGetCommandWithJsonForResponse(ctx context.C
}

func (app *CameraManagementApp) issueGetCommand(ctx context.Context, deviceName string, commandName string) (*responses.EventResponse, error) {
return app.service.CommandClient().IssueGetCommandByName(ctx, deviceName, commandName, "no", "yes")
return app.service.CommandClient().IssueGetCommandByName(ctx, deviceName, commandName, false, true)
}

func (app *CameraManagementApp) issueGetCommandForResponse(ctx context.Context, deviceName string, commandName string,
Expand All @@ -74,15 +75,15 @@ func (app *CameraManagementApp) issueGetCommandForResponse(ctx context.Context,
}

func issuePostRequest(ctx context.Context, res interface{}, baseUrl string, reqPath string, jsonValue []byte) (err error) {
return utils.PostRequest(ctx, &res, baseUrl, reqPath, jsonValue, common.ContentTypeJSON)
return utils.PostRequest(ctx, &res, baseUrl, reqPath, jsonValue, common.ContentTypeJSON, nil)
}

func issueGetRequest(ctx context.Context, res interface{}, baseUrl string, requestPath string) (err error) {
return utils.GetRequest(ctx, &res, baseUrl, requestPath, nil)
return utils.GetRequest(ctx, &res, baseUrl, requestPath, nil, nil)
}

func issueDeleteRequest(ctx context.Context, res interface{}, baseUrl string, requestPath string) (err error) {
return utils.DeleteRequest(ctx, &res, baseUrl, requestPath)
return utils.DeleteRequest(ctx, &res, baseUrl, requestPath, nil)
}

func respondError(lc logger.LoggingClient, w http.ResponseWriter, statusCode int, errStr string) {
Expand Down
68 changes: 34 additions & 34 deletions application-services/custom/camera-management/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,69 @@ go 1.18

require (
github.com/IOTechSystems/onvif v0.0.2-0.20220301065030-7cf2dd734897
github.com/edgexfoundry/app-functions-sdk-go/v2 v2.3.0
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.3.0
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.3.0
github.com/edgexfoundry/app-functions-sdk-go/v3 v3.0.0-dev.66
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@presatish , the SDK version can now be bumped to v3.0.0. Make tidy will bump the others

github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.90
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.41
github.com/gorilla/mux v1.8.0
github.com/pkg/errors v0.9.1
)

require (
bitbucket.org/bertimus9/systemstat v0.5.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/diegoholiveira/jsonlogic/v3 v3.2.6 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.1 // indirect
github.com/edgexfoundry/go-mod-configuration/v2 v2.3.0 // indirect
github.com/edgexfoundry/go-mod-messaging/v2 v2.3.0 // indirect
github.com/edgexfoundry/go-mod-registry/v2 v2.3.0 // indirect
github.com/edgexfoundry/go-mod-secrets/v2 v2.3.0 // indirect
github.com/diegoholiveira/jsonlogic/v3 v3.2.7 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.2 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.10 // indirect
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.31 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.17 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.13.0 // indirect
github.com/go-redis/redis/v7 v7.3.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/consul/api v1.15.3 // indirect
github.com/hashicorp/consul/api v1.20.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.9.7 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/nats-io/nats.go v1.18.0 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nats-io/nats.go v1.25.0 // indirect
github.com/nats-io/nkeys v0.4.4 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pebbe/zmq4 v1.2.7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.1 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/errs v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/square/go-jose.v2 v2.4.1 // indirect
github.com/zeebo/errs v1.3.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading