-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor/DEVTOOLING-395 - adding architect_schedules package * Addressed PR comments * added caching in schedules
- Loading branch information
1 parent
263568b
commit acb60f7
Showing
18 changed files
with
729 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
genesyscloud/architect_schedules/data_source_genesyscloud_architect_schedules.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package architect_schedules | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"terraform-provider-genesyscloud/genesyscloud/provider" | ||
"terraform-provider-genesyscloud/genesyscloud/util" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceArchitectSchedulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
sdkConfig := m.(*provider.ProviderMeta).ClientConfig | ||
proxy := newArchitectSchedulesProxy(sdkConfig) | ||
|
||
name := d.Get("name").(string) | ||
|
||
return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { | ||
scheduleId, retryable, proxyResponse, err := proxy.getArchitectSchedulesIdByName(ctx, name) | ||
|
||
if err != nil && !retryable { | ||
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error searching architect schedules %s | error: %s", name, err), proxyResponse)) | ||
} | ||
|
||
if retryable { | ||
return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("No architect schedules found with name %s", name), proxyResponse)) | ||
} | ||
|
||
d.SetId(scheduleId) | ||
return nil | ||
}) | ||
} |
2 changes: 1 addition & 1 deletion
2
..._genesyscloud_architect_schedules_test.go → ..._genesyscloud_architect_schedules_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package genesyscloud | ||
package architect_schedules | ||
|
||
import ( | ||
"fmt" | ||
|
62 changes: 62 additions & 0 deletions
62
genesyscloud/architect_schedules/genesyscloud_architect_schedules_init_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package architect_schedules | ||
|
||
import ( | ||
"sync" | ||
gcloud "terraform-provider-genesyscloud/genesyscloud" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
The genesyscloud_architect_schedules_init_test.go file is used to initialize the data sources and resources | ||
used in testing the architect_schedules resource. | ||
*/ | ||
|
||
// providerDataSources holds a map of all registered datasources | ||
var providerDataSources map[string]*schema.Resource | ||
|
||
// providerResources holds a map of all registered resources | ||
var providerResources map[string]*schema.Resource | ||
|
||
type registerTestInstance struct { | ||
resourceMapMutex sync.RWMutex | ||
datasourceMapMutex sync.RWMutex | ||
} | ||
|
||
// registerTestResources registers all resources used in the tests | ||
func (r *registerTestInstance) registerTestResources() { | ||
r.resourceMapMutex.Lock() | ||
defer r.resourceMapMutex.Unlock() | ||
|
||
providerResources[resourceName] = ResourceArchitectSchedules() | ||
providerResources["genesyscloud_auth_division"] = gcloud.ResourceAuthDivision() | ||
} | ||
|
||
// registerTestDataSources registers all data sources used in the tests. | ||
func (r *registerTestInstance) registerTestDataSources() { | ||
r.datasourceMapMutex.Lock() | ||
defer r.datasourceMapMutex.Unlock() | ||
|
||
providerDataSources[resourceName] = DataSourceArchitectScheduls() | ||
} | ||
|
||
// initTestResources initializes all test resources and data sources. | ||
func initTestResources() { | ||
providerDataSources = make(map[string]*schema.Resource) | ||
providerResources = make(map[string]*schema.Resource) | ||
|
||
regInstance := ®isterTestInstance{} | ||
|
||
regInstance.registerTestResources() | ||
regInstance.registerTestDataSources() | ||
} | ||
|
||
// TestMain is a "setup" function called by the testing framework when run the test | ||
func TestMain(m *testing.M) { | ||
// Run setup function before starting the test suite for the architect_schedulegroups package | ||
initTestResources() | ||
|
||
// Run the test suite for the architect_schedulegroups package | ||
m.Run() | ||
} |
Oops, something went wrong.