Skip to content

Commit

Permalink
core: allow to customize GetOwnerID
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Jun 9, 2022
1 parent e287cc7 commit c1f49e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 8 additions & 6 deletions client/core/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
)

type DeviceConfiguration struct {
DialDTLS DialDTLS
DialTLS DialTLS
DialUDP DialUDP
DialTCP DialTCP
ErrFunc ErrFunc
TLSConfig *TLSConfig
DialDTLS DialDTLS
DialTLS DialTLS
DialUDP DialUDP
DialTCP DialTCP
ErrFunc ErrFunc
TLSConfig *TLSConfig
GetOwnerID func() (string, error)
}

type Device struct {
Expand Down Expand Up @@ -53,6 +54,7 @@ func NewDevice(
deviceTypes []string,
getEndpoints func() schema.Endpoints,
) *Device {

return &Device{
cfg: cfg,
deviceID: deviceID,
Expand Down
6 changes: 5 additions & 1 deletion client/core/getSdkOwnerID.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ func (c *Client) GetSdkOwnerID() (string, error) {
return id, nil
}

// GetSdkOwnerID returns sdk ownerID from sdk identity certificate.
// GetSdkOwnerID returns sdk ownerID
func (d *Device) GetSdkOwnerID() (string, error) {
if d.cfg.GetOwnerID != nil {
return d.cfg.GetOwnerID()
}

id, err := getSdkOwnerID(d.cfg.TLSConfig.GetCertificate)
if err != nil {
return "", fmt.Errorf("cannot get sdk id: %w", err)
Expand Down

0 comments on commit c1f49e4

Please sign in to comment.