|
8 | 8 | "flag" |
9 | 9 | "log" |
10 | 10 | "os" |
| 11 | + "strconv" |
11 | 12 | "strings" |
12 | 13 |
|
13 | 14 | "github.com/hashicorp/terraform-plugin-framework/providerserver" |
@@ -48,6 +49,7 @@ func main() { |
48 | 49 | var parallelism = flag.Int("parallelism", 1, "The number of threads to use for resource discovery. By default the value is 1") |
49 | 50 | var varsResourceLevel = flag.String("variables_resource_level", "", "[export] List of top-level attributes to be export as variable following format resourceType.attribute, if attribute is present in variables_global_level, it will be excluded for this resourceType") |
50 | 51 | var varsGlobalLevel = flag.String("variables_global_level", "", "[export] List of top-level attributes to be export as variable following format attribute1,attribute2, if attribute present in variables_resource_level, it will be excluded for this resourceType") |
| 52 | + var customApiTimeout = flag.String("custom_api_timeout", "", "[export] The time duration for which API calls will wait for response from the service. By default, we rely on timeout set by SDK") |
51 | 53 |
|
52 | 54 | flag.Parse() |
53 | 55 | globalvar.PrintVersion() |
@@ -141,6 +143,27 @@ func main() { |
141 | 143 | args.Filters = filterFlag |
142 | 144 | } |
143 | 145 |
|
| 146 | + if customApiTimeout != nil && *customApiTimeout != "" { |
| 147 | + if timeInSeconds, err := strconv.Atoi(*customApiTimeout); err != nil || timeInSeconds < 0 { |
| 148 | + log.Printf("[WARNING]: Custom API timeout - %s - found but could not be converted to a postive integer", *customApiTimeout) |
| 149 | + } else { |
| 150 | + log.Printf("[DEBUG]:Setting custom API timeout of %d seconds as ENV variable OCI_CUSTOM_CLIENT_TIMEOUT", timeInSeconds) |
| 151 | + err := os.Setenv("OCI_CUSTOM_CLIENT_TIMEOUT", strconv.Itoa(timeInSeconds)) |
| 152 | + if err != nil { |
| 153 | + log.Printf("[ERROR]: Error while setting custom API Timeout as ENV variable OCI_CUSTOM_CLIENT_TIMEOUT- %s", err) |
| 154 | + } else { |
| 155 | + log.Printf("[DEBUG]: Success setting custom API Timeout as ENV variable OCI_CUSTOM_CLIENT_TIMEOUT- %s", os.Getenv("OCI_CUSTOM_CLIENT_TIMEOUT")) |
| 156 | + } |
| 157 | + } |
| 158 | + } else { |
| 159 | + err := os.Setenv("OCI_CUSTOM_CLIENT_TIMEOUT", "") |
| 160 | + if err != nil { |
| 161 | + log.Printf("[ERROR]: Error while setting default API Timeout as ENV variable OCI_CUSTOM_CLIENT_TIMEOUT to empty string - %s", err) |
| 162 | + } else { |
| 163 | + log.Printf("[DEBUG]: Success setting default API Timeout as ENV variable OCI_CUSTOM_CLIENT_TIMEOUT to empty string - %s", os.Getenv("OCI_CUSTOM_CLIENT_TIMEOUT")) |
| 164 | + } |
| 165 | + } |
| 166 | + |
144 | 167 | err, status := resourcediscovery.RunExportCommand(args) |
145 | 168 | if err != nil { |
146 | 169 | color.Red("%v", err) |
|
0 commit comments