()
| 38 | } |
| 39 | |
| 40 | func (p *Profile) GetApplicationID() (string, error) { |
| 41 | if os.Getenv("ALGOLIA_APPLICATION_ID") != "" { |
| 42 | return os.Getenv("ALGOLIA_APPLICATION_ID"), nil |
| 43 | } |
| 44 | |
| 45 | if p.ApplicationID != "" { |
| 46 | return p.ApplicationID, nil |
| 47 | } |
| 48 | |
| 49 | if p.Name == "" { |
| 50 | p.LoadDefault() |
| 51 | } |
| 52 | |
| 53 | if err := viper.ReadInConfig(); err == nil { |
| 54 | appID := viper.GetString(p.GetFieldName("application_id")) |
| 55 | if appID != "" { |
| 56 | return appID, nil |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return "", ErrApplicationIDNotConfigured |
| 61 | } |
| 62 | |
| 63 | func (p *Profile) GetAPIKey() (string, error) { |
| 64 | if os.Getenv("ALGOLIA_API_KEY") != "" { |
no test coverage detected