generated from snivilised/arcadia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(proxy): validate sampler info (#48)
- Loading branch information
1 parent
b16ee29
commit 214842e
Showing
7 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package proxy | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type ( | ||
ConfiguredSamplingScheme struct { | ||
Profiles []string `mapstructure:"profiles"` | ||
} | ||
|
||
ConfiguredSchemes map[string]ConfiguredSamplingScheme | ||
|
||
SamplerSchemes map[string][]ConfiguredSamplingScheme | ||
SamplerInfo struct { | ||
Files int `mapstructure:"files"` | ||
Folders int `mapstructure:"folders"` | ||
Schemes SamplerSchemes `mapstructure:"schemes"` | ||
} | ||
) | ||
|
||
func (cs SamplerInfo) Validate(name string, profiles *ConfiguredProfiles) error { | ||
if name == "" { | ||
return nil | ||
} | ||
|
||
var ( | ||
found bool | ||
scheme []ConfiguredSamplingScheme | ||
) | ||
|
||
if scheme, found = cs.Schemes[name]; !found { | ||
return fmt.Errorf("scheme: '%v' not found in config", scheme) | ||
} | ||
|
||
for _, p := range scheme[0].Profiles { | ||
if _, found := (*profiles)[p]; !found { | ||
return fmt.Errorf("profile(scheme: '%v'): '%v' not found in config", name, p) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters