@@ -57,20 +57,23 @@ func InstallDataStreamPipelines(ctx context.Context, api *elasticsearch.API, dat
57
57
58
58
nonce := time .Now ().UnixNano ()
59
59
60
- mainPipeline := getPipelineNameWithNonce (dataStreamManifest .GetPipelineNameOrDefault (), nonce )
61
- pipelines , err := loadIngestPipelineFiles (dataStreamPath , nonce )
60
+ mainPipeline := GetPipelineNameWithNonce (dataStreamManifest .GetPipelineNameOrDefault (), nonce )
61
+ pipelines , err := LoadIngestPipelineFiles (dataStreamPath , nonce )
62
62
if err != nil {
63
63
return "" , nil , fmt .Errorf ("loading ingest pipeline files failed: %w" , err )
64
64
}
65
65
66
- err = installPipelinesInElasticsearch (ctx , api , pipelines )
66
+ err = InstallPipelinesInElasticsearch (ctx , api , pipelines )
67
67
if err != nil {
68
68
return "" , nil , err
69
69
}
70
70
return mainPipeline , pipelines , nil
71
71
}
72
72
73
- func loadIngestPipelineFiles (dataStreamPath string , nonce int64 ) ([]Pipeline , error ) {
73
+ // LoadIngestPipelineFiles returns the set of pipelines found in the directory
74
+ // elasticsearch/ingest_pipeline under the provided data stream path. The names
75
+ // of the pipelines are decorated with the provided nonce.
76
+ func LoadIngestPipelineFiles (dataStreamPath string , nonce int64 ) ([]Pipeline , error ) {
74
77
elasticsearchPath := filepath .Join (dataStreamPath , "elasticsearch" , "ingest_pipeline" )
75
78
76
79
var pipelineFiles []string
@@ -100,7 +103,7 @@ func loadIngestPipelineFiles(dataStreamPath string, nonce int64) ([]Pipeline, er
100
103
return nil
101
104
}
102
105
pipelineTag := s [1 ]
103
- return []byte (getPipelineNameWithNonce (pipelineTag , nonce ))
106
+ return []byte (GetPipelineNameWithNonce (pipelineTag , nonce ))
104
107
})
105
108
if err != nil {
106
109
return nil , err
@@ -114,7 +117,7 @@ func loadIngestPipelineFiles(dataStreamPath string, nonce int64) ([]Pipeline, er
114
117
name := filepath .Base (path )
115
118
pipelines = append (pipelines , Pipeline {
116
119
Path : path ,
117
- Name : getPipelineNameWithNonce (name [:strings .Index (name , "." )], nonce ),
120
+ Name : GetPipelineNameWithNonce (name [:strings .Index (name , "." )], nonce ),
118
121
Format : filepath .Ext (strings .TrimSuffix (path , ".link" ))[1 :],
119
122
Content : cWithRerouteProcessors ,
120
123
ContentOriginal : c ,
@@ -241,7 +244,9 @@ func convertValue(value interface{}, label string) ([]string, error) {
241
244
}
242
245
}
243
246
244
- func installPipelinesInElasticsearch (ctx context.Context , api * elasticsearch.API , pipelines []Pipeline ) error {
247
+ // InstallPipelinesInElasticsearch installs the provided pipelines into the
248
+ // Elasticsearch instance specified by the provided API handle.
249
+ func InstallPipelinesInElasticsearch (ctx context.Context , api * elasticsearch.API , pipelines []Pipeline ) error {
245
250
for _ , p := range pipelines {
246
251
if err := installPipeline (ctx , api , p ); err != nil {
247
252
return err
0 commit comments