66 "net/http"
77
88 "github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/flags"
9- "github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/log "
9+ "github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/logger "
1010 "github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/modulegen"
1111 "github.com/mongodb/atlas-cli-core/config"
1212 "github.com/mongodb/atlas-cli-core/transport"
@@ -21,15 +21,15 @@ const (
2121// TODO@non-spike: Support tracking plugin versions, used in UserAgent header.
2222var Version = "dev"
2323
24- type ModuleImportOpts struct {
24+ type Opts struct {
25+ httpClient * http.Client
2526 input string
2627 output string
27- atlasBaseUrl string
28- httpClient * http.Client
28+ atlasBaseURL string
2929}
3030
3131func Builder () * cobra.Command {
32- opts := & ModuleImportOpts {}
32+ opts := & Opts {}
3333 cmd := & cobra.Command {
3434 Use : "module-import" ,
3535 Short : "Generate Terraform module configurations" ,
@@ -38,27 +38,33 @@ func Builder() *cobra.Command {
3838 RunE : opts .Run ,
3939 }
4040
41- cmd .Flags ().StringVarP (& opts .input , flags .Input , flags .InputShort , "" , "path to the input file" )
41+ cmd .Flags ().StringVarP (
42+ & opts .input , flags .Input , flags .InputShort , "" ,
43+ "path to the input file" ,
44+ )
4245 _ = cmd .MarkFlagRequired (flags .Input )
43- cmd .Flags ().StringVarP (& opts .output , flags .Output , flags .OutputShort , "" , "path where to the directory where to generate the output files" )
46+ cmd .Flags ().StringVarP (
47+ & opts .output , flags .Output , flags .OutputShort , "" ,
48+ "path where to the directory where to generate the output files" ,
49+ )
4450 _ = cmd .MarkFlagRequired (flags .Output )
4551 return cmd
4652}
4753
48- func (opts * ModuleImportOpts ) PreRun (cmd * cobra.Command , args []string ) error {
49- _ , _ = log .Debugln ("[module-import] PreRunE" )
54+ func (opts * Opts ) PreRun (cmd * cobra.Command , args []string ) error {
55+ _ , _ = logger .Debugln ("[module-import] PreRunE" )
5056
5157 profile , err := config .LoadAtlasCLIConfig ()
5258 if err != nil {
5359 return err
5460 }
5561
5662 // Use user-overridden url, otherwise if gov use gov url, otherwise use default.
57- if opts .atlasBaseUrl = profile .OpsManagerURL (); opts .atlasBaseUrl == "" {
63+ if opts .atlasBaseURL = profile .OpsManagerURL (); opts .atlasBaseURL == "" {
5864 if profile .Service () == config .CloudService {
59- opts .atlasBaseUrl = CloudGovServiceURL
65+ opts .atlasBaseURL = CloudGovServiceURL
6066 } else {
61- opts .atlasBaseUrl = CloudServiceURL
67+ opts .atlasBaseURL = CloudServiceURL
6268 }
6369 }
6470
@@ -78,18 +84,19 @@ func (opts *ModuleImportOpts) PreRun(cmd *cobra.Command, args []string) error {
7884 return err
7985}
8086
81- func (opts * ModuleImportOpts ) Run (cmd * cobra.Command , args []string ) error {
82- _ , _ = log .Debugln ("[module-import] RunE" )
87+ func (opts * Opts ) Run (cmd * cobra.Command , args []string ) error {
88+ _ , _ = logger .Debugln ("[module-import] RunE" )
8389 err := modulegen .Run (
8490 cmd .Context (),
85- & modulegen.ModuleGenArgs {
91+ & modulegen.GenArgs {
8692 InputPath : opts .input ,
8793 OutputPath : opts .output ,
8894 },
8995 & modulegen.AtlasClientArgs {
90- AtlasBaseUrl : opts .atlasBaseUrl ,
91- UserAgent : config .UserAgent (Version ), // TODO@non-spike: Look into differentiating the plugin's UserAgent from the cli one
92- HttpClient : opts .httpClient ,
96+ AtlasBaseURL : opts .atlasBaseURL ,
97+ // TODO@non-spike: Look into differentiating the plugin's UserAgent from the cli one
98+ UserAgent : config .UserAgent (Version ),
99+ HTTPClient : opts .httpClient ,
93100 },
94101 )
95102 return err
0 commit comments