Skip to content

Commit 2c74d68

Browse files
committed
unexport analysis structs
1 parent db86474 commit 2c74d68

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tools/sift.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ type investigationRequest struct {
3838
}
3939

4040
// Interesting: The analysis complete with results that indicate a probable cause for failure.
41-
type AnalysisResult struct {
41+
type analysisResult struct {
4242
Successful bool `json:"successful"`
4343
Interesting bool `json:"interesting"`
4444
Message string `json:"message"`
4545
Details map[string]interface{} `json:"details"`
4646
}
4747

48-
type AnalysisMeta struct {
49-
Items []Analysis `json:"items"`
48+
type analysisMeta struct {
49+
Items []analysis `json:"items"`
5050
}
5151

52-
// An Analysis struct provides the status and results
52+
// An analysis struct provides the status and results
5353
// of running a specific type of check.
54-
type Analysis struct {
54+
type analysis struct {
5555
ID uuid.UUID `json:"id"`
5656
CreatedAt time.Time `json:"created"`
5757
UpdatedAt time.Time `json:"modified"`
@@ -65,7 +65,7 @@ type Analysis struct {
6565
// Name is the name of the check that this analysis represents.
6666
Name string `json:"name"`
6767
Title string `json:"title"`
68-
Result AnalysisResult `json:"result"`
68+
Result analysisResult `json:"result"`
6969
}
7070

7171
type Investigation struct {
@@ -88,7 +88,7 @@ type Investigation struct {
8888
// investigation failed.
8989
FailureReason string `json:"failureReason,omitempty"`
9090

91-
Analyses AnalysisMeta `json:"analyses"`
91+
Analyses analysisMeta `json:"analyses"`
9292
}
9393

9494
// siftClient represents a client for interacting with the Sift API.
@@ -167,7 +167,7 @@ type GetSiftAnalysisParams struct {
167167
}
168168

169169
// getSiftAnalysis retrieves a specific analysis from an investigation
170-
func getSiftAnalysis(ctx context.Context, args GetSiftAnalysisParams) (*Analysis, error) {
170+
func getSiftAnalysis(ctx context.Context, args GetSiftAnalysisParams) (*analysis, error) {
171171
client, err := siftClientFromContext(ctx)
172172
if err != nil {
173173
return nil, fmt.Errorf("creating Sift client: %w", err)
@@ -241,7 +241,7 @@ type FindErrorPatternLogsParams struct {
241241
}
242242

243243
// findErrorPatternLogs creates an investigation with ErrorPatternLogs check, waits for it to complete, and returns the analysis
244-
func findErrorPatternLogs(ctx context.Context, args FindErrorPatternLogsParams) (*Analysis, error) {
244+
func findErrorPatternLogs(ctx context.Context, args FindErrorPatternLogsParams) (*analysis, error) {
245245
client, err := siftClientFromContext(ctx)
246246
if err != nil {
247247
return nil, fmt.Errorf("creating Sift client: %w", err)
@@ -275,7 +275,7 @@ func findErrorPatternLogs(ctx context.Context, args FindErrorPatternLogsParams)
275275
}
276276

277277
// Find the ErrorPatternLogs analysis
278-
var errorPatternLogsAnalysis *Analysis
278+
var errorPatternLogsAnalysis *analysis
279279
for i := range analyses {
280280
if analyses[i].Name == string(checkTypeErrorPatternLogs) {
281281
errorPatternLogsAnalysis = &analyses[i]
@@ -307,7 +307,7 @@ type FindSlowRequestsParams struct {
307307
}
308308

309309
// findSlowRequests creates an investigation with SlowRequests check, waits for it to complete, and returns the analysis
310-
func findSlowRequests(ctx context.Context, args FindSlowRequestsParams) (*Analysis, error) {
310+
func findSlowRequests(ctx context.Context, args FindSlowRequestsParams) (*analysis, error) {
311311
client, err := siftClientFromContext(ctx)
312312
if err != nil {
313313
return nil, fmt.Errorf("creating Sift client: %w", err)
@@ -341,7 +341,7 @@ func findSlowRequests(ctx context.Context, args FindSlowRequestsParams) (*Analys
341341
}
342342

343343
// Find the SlowRequests analysis
344-
var slowRequestsAnalysis *Analysis
344+
var slowRequestsAnalysis *analysis
345345
for i := range analyses {
346346
if analyses[i].Name == string(checkTypeSlowRequests) {
347347
slowRequestsAnalysis = &analyses[i]
@@ -492,7 +492,7 @@ func (c *siftClient) createSiftInvestigation(ctx context.Context, investigation
492492
}
493493

494494
// getSiftAnalyses is a helper method to get all analyses from an investigation
495-
func (c *siftClient) getSiftAnalyses(ctx context.Context, investigationID uuid.UUID) ([]Analysis, error) {
495+
func (c *siftClient) getSiftAnalyses(ctx context.Context, investigationID uuid.UUID) ([]analysis, error) {
496496
path := fmt.Sprintf("/api/plugins/grafana-ml-app/resources/sift/api/v1/investigations/%s/analyses", investigationID)
497497
buf, err := c.makeRequest(ctx, "GET", path, nil)
498498
if err != nil {
@@ -501,7 +501,7 @@ func (c *siftClient) getSiftAnalyses(ctx context.Context, investigationID uuid.U
501501

502502
var response struct {
503503
Status string `json:"status"`
504-
Data []Analysis `json:"data"`
504+
Data []analysis `json:"data"`
505505
}
506506

507507
if err := json.Unmarshal(buf, &response); err != nil {
@@ -512,15 +512,15 @@ func (c *siftClient) getSiftAnalyses(ctx context.Context, investigationID uuid.U
512512
}
513513

514514
// getSiftAnalysis is a helper method to get a specific analysis from an investigation
515-
func (c *siftClient) getSiftAnalysis(ctx context.Context, investigationID, analysisID uuid.UUID) (*Analysis, error) {
515+
func (c *siftClient) getSiftAnalysis(ctx context.Context, investigationID, analysisID uuid.UUID) (*analysis, error) {
516516
// First get all analyses to verify the analysis exists
517517
analyses, err := c.getSiftAnalyses(ctx, investigationID)
518518
if err != nil {
519519
return nil, fmt.Errorf("getting analyses: %w", err)
520520
}
521521

522522
// Find the specific analysis
523-
var targetAnalysis *Analysis
523+
var targetAnalysis *analysis
524524
for _, analysis := range analyses {
525525
if analysis.ID == analysisID {
526526
targetAnalysis = &analysis

0 commit comments

Comments
 (0)