Skip to content

Commit

Permalink
initial config changes for bitmovin
Browse files Browse the repository at this point in the history
  • Loading branch information
James Yeh committed Dec 28, 2016
1 parent 003fcd1 commit 02e97d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Config struct {
ElasticTranscoder *ElasticTranscoder
ElementalConductor *ElementalConductor
Zencoder *Zencoder
Bitmovin *Bitmovin
}

// EncodingCom represents the set of configurations for the Encoding.com
Expand Down Expand Up @@ -57,17 +58,24 @@ type ElementalConductor struct {
Destination string `envconfig:"ELEMENTALCONDUCTOR_DESTINATION"`
}

// Bitmovin represents the set of configurations for the Bitmovin
// provider.
type Bitmovin struct {
APIKey string `envconfig:"BITMOVIN_API_KEY"`
}

// LoadConfig loads the configuration of the API using environment variables.
func LoadConfig() *Config {
cfg := Config{
Redis: new(storage.Config),
EncodingCom: new(EncodingCom),
ElasticTranscoder: new(ElasticTranscoder),
ElementalConductor: new(ElementalConductor),
Bitmovin: new(Bitmovin),
Server: new(server.Config),
}
config.LoadEnvConfig(&cfg)
loadFromEnv(cfg.Redis, cfg.EncodingCom, cfg.ElasticTranscoder, cfg.ElementalConductor, cfg.Server)
loadFromEnv(cfg.Redis, cfg.EncodingCom, cfg.ElasticTranscoder, cfg.ElementalConductor, cfg.Bitmovin, cfg.Server)
return &cfg
}

Expand Down
14 changes: 14 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestLoadConfigFromEnv(t *testing.T) {
"ELEMENTALCONDUCTOR_AWS_ACCESS_KEY_ID": "AKIANOTREALLY",
"ELEMENTALCONDUCTOR_AWS_SECRET_ACCESS_KEY": "secret-key",
"ELEMENTALCONDUCTOR_DESTINATION": "https://safe-stuff",
"BITMOVIN_API_KEY": "secret-key",
"SWAGGER_MANIFEST_PATH": "/opt/video-transcoding-api-swagger.json",
"HTTP_ACCESS_LOG": accessLog,
"HTTP_PORT": "8080",
Expand Down Expand Up @@ -74,6 +75,9 @@ func TestLoadConfigFromEnv(t *testing.T) {
SecretAccessKey: "secret-key",
Destination: "https://safe-stuff",
},
Bitmovin: &Bitmovin{
APIKey: "secret-key",
},
Server: &server.Config{
HTTPPort: 8080,
HTTPAccessLog: &accessLog,
Expand All @@ -94,6 +98,9 @@ func TestLoadConfigFromEnv(t *testing.T) {
if !reflect.DeepEqual(*cfg.ElasticTranscoder, *expectedCfg.ElasticTranscoder) {
t.Errorf("LoadConfig(): wrong ElasticTranscoder config returned. Want %#v. Got %#v.", *expectedCfg.ElasticTranscoder, *cfg.ElasticTranscoder)
}
if !reflect.DeepEqual(*cfg.Bitmovin, *expectedCfg.Bitmovin) {
t.Errorf("LoadConfig(): wrong Bitmovin config returned. Want %#v. Got %#v.", *expectedCfg.Bitmovin, *cfg.Bitmovin)
}
if !reflect.DeepEqual(*cfg.ElementalConductor, *expectedCfg.ElementalConductor) {
t.Errorf("LoadConfig(): wrong Elemental Conductor config returned. Want %#v. Got %#v.", *expectedCfg.ElementalConductor, *cfg.ElementalConductor)
}
Expand Down Expand Up @@ -124,6 +131,7 @@ func TestLoadConfigFromEnvWithDefauts(t *testing.T) {
"ELEMENTALCONDUCTOR_AWS_ACCESS_KEY_ID": "AKIANOTREALLY",
"ELEMENTALCONDUCTOR_AWS_SECRET_ACCESS_KEY": "secret-key",
"ELEMENTALCONDUCTOR_DESTINATION": "https://safe-stuff",
"BITMOVIN_API_KEY": "secret-key",
"SWAGGER_MANIFEST_PATH": "/opt/video-transcoding-api-swagger.json",
"HTTP_ACCESS_LOG": accessLog,
"HTTP_PORT": "8080",
Expand Down Expand Up @@ -163,6 +171,9 @@ func TestLoadConfigFromEnvWithDefauts(t *testing.T) {
SecretAccessKey: "secret-key",
Destination: "https://safe-stuff",
},
Bitmovin: &Bitmovin{
APIKey: "secret-key",
},
Server: &server.Config{
HTTPPort: 8080,
HTTPAccessLog: &accessLog,
Expand All @@ -186,6 +197,9 @@ func TestLoadConfigFromEnvWithDefauts(t *testing.T) {
if !reflect.DeepEqual(*cfg.ElementalConductor, *expectedCfg.ElementalConductor) {
t.Errorf("LoadConfig(): wrong Elemental Conductor config returned. Want %#v. Got %#v.", *expectedCfg.ElementalConductor, *cfg.ElementalConductor)
}
if !reflect.DeepEqual(*cfg.Bitmovin, *expectedCfg.Bitmovin) {
t.Errorf("LoadConfig(): wrong Bitmovin config returned. Want %#v. Got %#v.", *expectedCfg.Bitmovin, *cfg.Bitmovin)
}
if !reflect.DeepEqual(*cfg.Server, *expectedCfg.Server) {
t.Errorf("LoadConfig(): wrong Server config returned. Want %#v. Got %#v.", *expectedCfg.Server, *cfg.Server)
}
Expand Down

0 comments on commit 02e97d3

Please sign in to comment.