Get sample data for a specific project (simplified using PNS)
(projectID string)
| 943 | |
| 944 | // Get sample data for a specific project (simplified using PNS) |
| 945 | func getSampleDataForProject(projectID string) (map[string]interface{}, string, error) { |
| 946 | proj, exists := project.GetProject(projectID) |
| 947 | |
| 948 | if !exists { |
| 949 | return map[string]interface{}{}, "", fmt.Errorf("project %s not found", projectID) |
| 950 | } |
| 951 | |
| 952 | result := make(map[string]interface{}) |
| 953 | dataSources := make([]string, 0) |
| 954 | |
| 955 | // Get sample data from all project components using PNS |
| 956 | for componentName := range proj.Inputs { |
| 957 | samples := getSampleDataFromComponent("input." + componentName) |
| 958 | if len(samples) > 0 { |
| 959 | result[fmt.Sprintf("input.%s", componentName)] = samples |
| 960 | dataSources = append(dataSources, "input."+componentName) |
| 961 | } |
| 962 | } |
| 963 | |
| 964 | for componentName := range proj.Rulesets { |
| 965 | samples := getSampleDataFromComponent("ruleset." + componentName) |
| 966 | if len(samples) > 0 { |
| 967 | result[fmt.Sprintf("ruleset.%s", componentName)] = samples |
| 968 | dataSources = append(dataSources, "ruleset."+componentName) |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | for componentName := range proj.Outputs { |
| 973 | samples := getSampleDataFromComponent("output." + componentName) |
| 974 | if len(samples) > 0 { |
| 975 | result[fmt.Sprintf("output.%s", componentName)] = samples |
| 976 | dataSources = append(dataSources, "output."+componentName) |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | if len(result) > 0 { |
| 981 | dataSource := fmt.Sprintf("project.%s components: %s", projectID, strings.Join(dataSources, ", ")) |
| 982 | return result, dataSource, nil |
| 983 | } |
| 984 | |
| 985 | return map[string]interface{}{}, "", fmt.Errorf("no sample data available for project %s", projectID) |
| 986 | } |
no test coverage detected