Skip to content

Commit

Permalink
Merge pull request #1895 from okta/update-sdk-v4
Browse files Browse the repository at this point in the history
fix issue with okta_domain fail instantly after creation
  • Loading branch information
duytiennguyen-okta authored Feb 9, 2024
2 parents 04f6360 + 6e923b3 commit a7a6755
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 161 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
github.com/jarcoal/httpmock v1.3.1
github.com/kelseyhightower/envconfig v1.4.0
github.com/okta/okta-sdk-golang/v3 v3.0.19
github.com/okta/okta-sdk-golang/v4 v4.0.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.8.4
gopkg.in/dnaeon/go-vcr.v3 v3.1.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/okta/okta-sdk-golang/v3 v3.0.19 h1:xedRIGAJ3j89JgE9TSgKjtiN/CNKTTTPqURVDLuMfrI=
github.com/okta/okta-sdk-golang/v3 v3.0.19/go.mod h1:G9c5Rn6odsHI6XSC6PBa91Z5CicB8dv8zOfceeTRaWA=
github.com/okta/okta-sdk-golang/v4 v4.0.0 h1:XwIy1WxIUJJd63q5ObFuJgfxRosXNF++yjXPyay2/4c=
github.com/okta/okta-sdk-golang/v4 v4.0.0/go.mod h1:IIYXqbNgAg3IOuSidey7NJkkg8Ozb1x5QHQTKMZfeHo=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
Expand Down
2 changes: 1 addition & 1 deletion okta/brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"errors"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

var brandDataSourceSchema = map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion okta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
"github.com/okta/terraform-provider-okta/okta/internal/apimutex"
"github.com/okta/terraform-provider-okta/okta/internal/transport"
"github.com/okta/terraform-provider-okta/sdk"
Expand Down
6 changes: 3 additions & 3 deletions okta/customization.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

type signinPageModel struct {
Expand Down Expand Up @@ -96,7 +96,7 @@ func mapSignInPageToState(ctx context.Context, data *okta.SignInPage, state *sig
widgetCustomizations.AuthenticatorPageCustomLinkLabel = types.StringPointerValue(customization.AuthenticatorPageCustomLinkLabel)
widgetCustomizations.AuthenticatorPageCustomLinkURL = types.StringPointerValue(customization.AuthenticatorPageCustomLinkUrl)
widgetCustomizations.ClassicRecoveryFlowEmailOrUsernameLabel = types.StringPointerValue(customization.ClassicRecoveryFlowEmailOrUsernameLabel)
widgetCustomizations.WidgetGeneration = types.StringPointerValue((*string)(customization.WidgetGeneration.Ptr()))
widgetCustomizations.WidgetGeneration = types.StringPointerValue(customization.WidgetGeneration)
}
customizationValue, diags := types.ObjectValueFrom(ctx, state.WidgetCustomizations.AttributeTypes(ctx), widgetCustomizations)
if diags.HasError() {
Expand Down Expand Up @@ -136,7 +136,7 @@ func buildSignInPageRequest(ctx context.Context, model signinPageModel) (okta.Si
wc.AuthenticatorPageCustomLinkLabel = wcm.AuthenticatorPageCustomLinkLabel.ValueStringPointer()
wc.AuthenticatorPageCustomLinkUrl = wcm.AuthenticatorPageCustomLinkURL.ValueStringPointer()
wc.ClassicRecoveryFlowEmailOrUsernameLabel = wcm.ClassicRecoveryFlowEmailOrUsernameLabel.ValueStringPointer()
wc.SetWidgetGeneration(okta.WidgetGeneration(wcm.WidgetGeneration.ValueString()))
wc.SetWidgetGeneration(wcm.WidgetGeneration.ValueString())

sp.SetWidgetCustomizations(wc)
return sp, nil
Expand Down
2 changes: 1 addition & 1 deletion okta/data_source_okta_auth_server_scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func dataSourceAuthServerScopes() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion okta/data_source_okta_brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func dataSourceBrand() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion okta/data_source_okta_email_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func dataSourceEmailTemplate() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion okta/data_source_okta_email_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func dataSourceEmailTemplates() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion okta/data_source_okta_log_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func NewLogStreamDataSource() datasource.DataSource {
Expand Down
2 changes: 1 addition & 1 deletion okta/email_customization.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

var emailCustomizationsDataSourceSchema = map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion okta/email_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

var emailTemplatesDataSourceSchema = map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion okta/provider_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
"github.com/okta/terraform-provider-okta/sdk"
"github.com/okta/terraform-provider-okta/sdk/query"
)
Expand Down
2 changes: 1 addition & 1 deletion okta/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
"github.com/okta/terraform-provider-okta/sdk"
"gopkg.in/dnaeon/go-vcr.v3/cassette"
"gopkg.in/dnaeon/go-vcr.v3/recorder"
Expand Down
2 changes: 1 addition & 1 deletion okta/resource_okta_app_access_policy_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down
14 changes: 3 additions & 11 deletions okta/resource_okta_auth_server_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func resourceAuthServerScope() *schema.Resource {
Expand Down Expand Up @@ -126,19 +126,11 @@ func resourceAuthServerScopeDelete(ctx context.Context, d *schema.ResourceData,
func buildAuthServerScope(d *schema.ResourceData) (okta.OAuth2Scope, error) {
scope := okta.OAuth2Scope{}
if consent, ok := d.GetOk("consent"); ok {
consentStr, err := okta.NewOAuth2ScopeConsentTypeFromValue(consent.(string))
if err != nil {
return okta.OAuth2Scope{}, err
}
scope.SetConsent(*consentStr)
scope.SetConsent(consent.(string))
}
scope.SetDescription(d.Get("description").(string))
if metadataPublish, ok := d.GetOk("metadata_publish"); ok {
metadataPublishStr, err := okta.NewOAuth2ScopeMetadataPublishFromValue(metadataPublish.(string))
if err != nil {
return okta.OAuth2Scope{}, err
}
scope.SetMetadataPublish(*metadataPublishStr)
scope.SetMetadataPublish(metadataPublish.(string))
}
scope.SetName(d.Get("name").(string))
scope.SetDisplayName(d.Get("display_name").(string))
Expand Down
2 changes: 1 addition & 1 deletion okta/resource_okta_brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func NewBrandResource() resource.Resource {
Expand Down
10 changes: 3 additions & 7 deletions okta/resource_okta_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func resourceDomain() *schema.Resource {
Expand Down Expand Up @@ -132,7 +132,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, m interface
if err != nil {
return diag.Errorf("failed to set DNS records: %v", err)
}
if domain.GetValidationStatus() == okta.DOMAINVALIDATIONSTATUS_COMPLETED || domain.GetValidationStatus() == okta.DOMAINVALIDATIONSTATUS_IN_PROGRESS || domain.GetValidationStatus() == okta.DOMAINVALIDATIONSTATUS_COMPLETED {
if domain.GetValidationStatus() == "IN_PROGRESS" || domain.GetValidationStatus() == "VERIFIED" || domain.GetValidationStatus() == "COMPLETED" {
return nil
}

Expand Down Expand Up @@ -172,12 +172,8 @@ func validateDomain(ctx context.Context, d *schema.ResourceData, m interface{},
}

func buildDomain(d *schema.ResourceData) (okta.DomainRequest, error) {
certSourceType, err := okta.NewDomainCertificateSourceTypeFromValue(d.Get("certificate_source_type").(string))
if err != nil {
return okta.DomainRequest{}, err
}
return okta.DomainRequest{
Domain: d.Get("name").(string),
CertificateSourceType: *certSourceType,
CertificateSourceType: (d.Get("certificate_source_type").(string)),
}, nil
}
2 changes: 1 addition & 1 deletion okta/resource_okta_email_customization.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func resourceEmailCustomization() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion okta/resource_okta_email_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

func resourceEmailDomain() *schema.Resource {
Expand Down
14 changes: 7 additions & 7 deletions okta/resource_okta_log_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

const (
Expand Down Expand Up @@ -410,7 +410,7 @@ func buildLogStreamCreateBody(ctx context.Context, m *logStreamModel) *okta.List
Id: m.ID.ValueString(),
Name: m.Name.ValueString(),
Status: m.Status.ValueString(),
Type: okta.LogStreamType(m.Type.ValueString()),
Type: m.Type.ValueString(),
}

settings := &logStreamSettingsModel{}
Expand All @@ -421,7 +421,7 @@ func buildLogStreamCreateBody(ctx context.Context, m *logStreamModel) *okta.List
var settingAws okta.LogStreamSettingsAws
settingAws.AccountId = settings.AccountID.ValueString()
settingAws.EventSourceName = settings.EventSourceName.ValueString()
settingAws.Region = okta.AwsRegion(settings.Region.ValueString())
settingAws.Region = settings.Region.ValueString()
return &okta.ListLogStreams200ResponseInner{
LogStreamAws: &okta.LogStreamAws{
LogStream: ls,
Expand All @@ -430,7 +430,7 @@ func buildLogStreamCreateBody(ctx context.Context, m *logStreamModel) *okta.List
}
case logStreamTypeSplunk:
var settingSplunk okta.LogStreamSettingsSplunk
settingSplunk.Edition = okta.SplunkEdition(settings.Edition.ValueString())
settingSplunk.Edition = settings.Edition.ValueString()
settingSplunk.Host = settings.Host.ValueString()
settingSplunk.Token = settings.Token.ValueString()
return &okta.ListLogStreams200ResponseInner{
Expand All @@ -447,7 +447,7 @@ func buildLogStreamReplaceBody(ctx context.Context, m *logStreamModel) *okta.Rep
_type := m.Type.ValueString()
ls := okta.LogStreamPutSchema{
Name: m.Name.ValueString(),
Type: okta.LogStreamType(m.Type.ValueString()),
Type: m.Type.ValueString(),
}

settings := &logStreamSettingsModel{}
Expand All @@ -458,7 +458,7 @@ func buildLogStreamReplaceBody(ctx context.Context, m *logStreamModel) *okta.Rep
var settingAws okta.LogStreamSettingsAws
settingAws.AccountId = settings.AccountID.ValueString()
settingAws.EventSourceName = settings.EventSourceName.ValueString()
settingAws.Region = okta.AwsRegion(settings.Region.ValueString())
settingAws.Region = settings.Region.ValueString()
return &okta.ReplaceLogStreamRequest{
LogStreamAwsPutSchema: &okta.LogStreamAwsPutSchema{
LogStreamPutSchema: ls,
Expand All @@ -467,7 +467,7 @@ func buildLogStreamReplaceBody(ctx context.Context, m *logStreamModel) *okta.Rep
}
case logStreamTypeSplunk:
var settingSplunk okta.LogStreamSettingsSplunkPut
settingSplunk.Edition = okta.SplunkEdition(settings.Edition.ValueString())
settingSplunk.Edition = settings.Edition.ValueString()
settingSplunk.Host = settings.Host.ValueString()
return &okta.ReplaceLogStreamRequest{
LogStreamSplunkPutSchema: &okta.LogStreamSplunkPutSchema{
Expand Down
22 changes: 7 additions & 15 deletions okta/resource_okta_policy_device_assurance_android_os.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/okta/okta-sdk-golang/v3/okta"
"github.com/okta/okta-sdk-golang/v4/okta"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -280,30 +280,22 @@ func (r *policyDeviceAssuranceAndroidResource) Update(ctx context.Context, req r
func buildDeviceAssuranceAndroidPolicyRequest(model policyDeviceAssuranceAndroidResourceModel) (okta.ListDeviceAssurancePolicies200ResponseInner, error) {
android := &okta.DeviceAssuranceAndroidPlatform{}
android.SetName(model.Name.ValueString())
android.SetPlatform(okta.PLATFORM_ANDROID)
android.SetPlatform("ANDROID")
if len(model.DiskEncryptionType) > 0 {
diskEncryptionType := make([]okta.DiskEncryptionTypeAndroid, 0)
diskEncryptionType := make([]string, 0)
for _, det := range model.DiskEncryptionType {
v, err := okta.NewDiskEncryptionTypeAndroidFromValue(det.ValueString())
if err != nil {
return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceAndroidPlatform: android}, err
}
diskEncryptionType = append(diskEncryptionType, *v)
diskEncryptionType = append(diskEncryptionType, det.ValueString())
}
android.DiskEncryptionType = &okta.DeviceAssuranceAndroidPlatformAllOfDiskEncryptionType{Include: diskEncryptionType}
}
android.Jailbreak = model.JailBreak.ValueBoolPointer()
if !model.OsVersion.IsNull() {
android.OsVersion = &okta.OSVersionFourComponents{Minimum: model.OsVersion.ValueStringPointer()}
android.OsVersion = &okta.OSVersion{Minimum: model.OsVersion.ValueStringPointer()}
}
if len(model.ScreenLockType) > 0 {
screenlockType := make([]okta.ScreenLockType, 0)
screenlockType := make([]string, 0)
for _, det := range model.ScreenLockType {
v, err := okta.NewScreenLockTypeFromValue(det.ValueString())
if err != nil {
return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceAndroidPlatform: android}, err
}
screenlockType = append(screenlockType, *v)
screenlockType = append(screenlockType, det.ValueString())
}
android.ScreenLockType = &okta.DeviceAssuranceAndroidPlatformAllOfScreenLockType{Include: screenlockType}
}
Expand Down
Loading

0 comments on commit a7a6755

Please sign in to comment.