fixed keys parsing from ENV/cli
This commit is contained in:
+18
-2
@@ -50,6 +50,7 @@ func NewConfig(confString string) (*Config, error) {
|
|||||||
Redis: RedisConfig{
|
Redis: RedisConfig{
|
||||||
Address: "localhost:6379",
|
Address: "localhost:6379",
|
||||||
},
|
},
|
||||||
|
Keys: map[string]string{},
|
||||||
}
|
}
|
||||||
if confString != "" {
|
if confString != "" {
|
||||||
yaml.Unmarshal([]byte(confString), conf)
|
yaml.Unmarshal([]byte(confString), conf)
|
||||||
@@ -65,8 +66,7 @@ func (conf *Config) UpdateFromCLI(c *cli.Context) error {
|
|||||||
conf.KeyFile = c.String("key-file")
|
conf.KeyFile = c.String("key-file")
|
||||||
}
|
}
|
||||||
if c.IsSet("keys") {
|
if c.IsSet("keys") {
|
||||||
keys := []byte(c.String("keys"))
|
if err := conf.unmarshalKeys(c.String("keys")); err != nil {
|
||||||
if err := yaml.Unmarshal(keys, &conf.Keys); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,3 +84,19 @@ func (conf *Config) UpdateFromCLI(c *cli.Context) error {
|
|||||||
conf.KeyFile = file
|
conf.KeyFile = file
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (conf *Config) unmarshalKeys(keys string) error {
|
||||||
|
temp := make(map[string]interface{})
|
||||||
|
if err := yaml.Unmarshal([]byte(keys), temp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.Keys = make(map[string]string, len(temp))
|
||||||
|
|
||||||
|
for key, val := range temp {
|
||||||
|
if secret, ok := val.(string); ok {
|
||||||
|
conf.Keys[key] = secret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConfig_UnmarshalKeys(t *testing.T) {
|
||||||
|
conf, err := NewConfig("")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.NoError(t, conf.unmarshalKeys("key1: secret1"))
|
||||||
|
assert.Equal(t, "secret1", conf.Keys["key1"])
|
||||||
|
}
|
||||||
@@ -127,7 +127,7 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outTrack.SetTransceiver(transceiver)
|
outTrack.SetTransceiver(transceiver)
|
||||||
// TODO: when outtrack is bound, start loop to send reports
|
// when outtrack is bound, start loop to send reports
|
||||||
outTrack.OnBind(func() {
|
outTrack.OnBind(func() {
|
||||||
if rr := bufferFactory.GetOrNew(packetio.RTCPBufferPacket, outTrack.SSRC()).(*buffer.RTCPReader); rr != nil {
|
if rr := bufferFactory.GetOrNew(packetio.RTCPBufferPacket, outTrack.SSRC()).(*buffer.RTCPReader); rr != nil {
|
||||||
rr.OnPacket(func(pkt []byte) {
|
rr.OnPacket(func(pkt []byte) {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func TestIsReady(t *testing.T) {
|
|||||||
func TestTrackPublishing(t *testing.T) {
|
func TestTrackPublishing(t *testing.T) {
|
||||||
t.Run("should send the correct events", func(t *testing.T) {
|
t.Run("should send the correct events", func(t *testing.T) {
|
||||||
p := newParticipantForTest("test")
|
p := newParticipantForTest("test")
|
||||||
|
p.state.Store(livekit.ParticipantInfo_ACTIVE)
|
||||||
track := &typesfakes.FakePublishedTrack{}
|
track := &typesfakes.FakePublishedTrack{}
|
||||||
track.IDReturns("id")
|
track.IDReturns("id")
|
||||||
published := false
|
published := false
|
||||||
|
|||||||
Reference in New Issue
Block a user