@@ -30,23 +30,25 @@ import (
3030
3131// GapicGenerator is used to regenerate gapic libraries.
3232type GapicGenerator struct {
33- googleapisDir string
34- protoDir string
35- googleCloudDir string
36- genprotoDir string
37- gapicToGenerate string
38- regenOnly bool
33+ googleapisDir string
34+ protoDir string
35+ googleCloudDir string
36+ genprotoDir string
37+ gapicToGenerate string
38+ regenOnly bool
39+ onlyGenerateGapic bool
3940}
4041
4142// NewGapicGenerator creates a GapicGenerator.
42- func NewGapicGenerator (googleapisDir , protoDir , googleCloudDir , genprotoDir string , gapicToGenerate string , regenOnly bool ) * GapicGenerator {
43+ func NewGapicGenerator (c * Config ) * GapicGenerator {
4344 return & GapicGenerator {
44- googleapisDir : googleapisDir ,
45- protoDir : protoDir ,
46- googleCloudDir : googleCloudDir ,
47- genprotoDir : genprotoDir ,
48- gapicToGenerate : gapicToGenerate ,
49- regenOnly : regenOnly ,
45+ googleapisDir : c .GoogleapisDir ,
46+ protoDir : c .ProtoDir ,
47+ googleCloudDir : c .GapicDir ,
48+ genprotoDir : c .GenprotoDir ,
49+ gapicToGenerate : c .GapicToGenerate ,
50+ regenOnly : c .RegenOnly ,
51+ onlyGenerateGapic : c .OnlyGenerateGapic ,
5052 }
5153}
5254
@@ -82,6 +84,12 @@ func (g *GapicGenerator) Regen(ctx context.Context) error {
8284 return err
8385 }
8486
87+ if ! g .onlyGenerateGapic {
88+ if err := g .regenSnippets (ctx ); err != nil {
89+ return err
90+ }
91+ }
92+
8593 if err := execv .ForEachMod (g .googleCloudDir , g .addModReplaceGenproto ); err != nil {
8694 return err
8795 }
@@ -102,7 +110,7 @@ func (g *GapicGenerator) Regen(ctx context.Context) error {
102110}
103111
104112// RegenSnippets regenerates the snippets for all GAPICs configured to be generated.
105- func (g * GapicGenerator ) RegenSnippets (ctx context.Context ) error {
113+ func (g * GapicGenerator ) regenSnippets (ctx context.Context ) error {
106114 log .Println ("regenerating snippets" )
107115
108116 snippetDir := filepath .Join (g .googleCloudDir , "internal" , "generated" , "snippets" )
0 commit comments