mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-21 10:06:58 +00:00
OAS: rework data feeding + sampleIDs (#917)
* Call OAS feeder * Don't call old OAS code * Rework calls * Work on it * Put back rules * Make it compile * start thinking of test * Compiles * Save * Fixes * Save * Fixing * Trying to fake conn * add timeout * Test timeout * Fix tests * Only build OAS for HTTP entries * Remove some dead code * Adding SampleIDs * Cosmetics * lint * Revert rename * Sample ID for content * Cleanuo * Add more sample IDs * Checking hypothesis * Move assignment place a bit * Cosmetics * Update test.yml Co-authored-by: undera <undera@undera-old-desktop.home> Co-authored-by: Igor Gov <iggvrv@gmail.com>
This commit is contained in:
@@ -115,7 +115,7 @@ type nvParams struct {
|
||||
GeneralizeName func(name string) string
|
||||
}
|
||||
|
||||
func handleNameVals(gw nvParams, params **openapi.ParameterList, checkIgnore bool) {
|
||||
func handleNameVals(gw nvParams, params **openapi.ParameterList, checkIgnore bool, sampleId uint) {
|
||||
visited := map[string]*openapi.ParameterObj{}
|
||||
for _, pair := range gw.Pairs {
|
||||
if (checkIgnore && gw.IsIgnored(pair.Name)) || pair.Name == "" {
|
||||
@@ -137,6 +137,8 @@ func handleNameVals(gw nvParams, params **openapi.ParameterList, checkIgnore boo
|
||||
logger.Log.Warningf("Failed to add example to a parameter: %s", err)
|
||||
}
|
||||
visited[nameGeneral] = param
|
||||
|
||||
setSampleID(¶m.Extensions, sampleId)
|
||||
}
|
||||
|
||||
// maintain "required" flag
|
||||
@@ -474,3 +476,15 @@ func intersectSliceWithMap(required []string, names map[string]struct{}) []strin
|
||||
}
|
||||
return required
|
||||
}
|
||||
|
||||
func setSampleID(extensions *openapi.Extensions, id uint) {
|
||||
if id > 0 {
|
||||
if *extensions == nil {
|
||||
*extensions = openapi.Extensions{}
|
||||
}
|
||||
err := (extensions).SetExtension(SampleId, id)
|
||||
if err != nil {
|
||||
logger.Log.Warningf("Failed to set sample ID: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user