Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for brand creation #1677

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/hashicorp/terraform-plugin-mux v0.11.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/okta/okta-sdk-golang/v3 v3.0.12
github.com/okta/okta-sdk-golang/v3 v3.0.13
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 Expand Up @@ -92,5 +92,4 @@ require (
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
336 changes: 2 additions & 334 deletions go.sum

Large diffs are not rendered by default.

46 changes: 2 additions & 44 deletions okta/brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,6 @@ import (
"github.com/okta/okta-sdk-golang/v3/okta"
)

var brandResourceSchema = map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "Brand ID",
},
"brand_id": {
Type: schema.TypeString,
Optional: true,
Description: "Brand ID - Note: Okta API for brands only reads and updates therefore the okta_brand resource needs to act as a quasi data source. Do this by setting brand_id.",
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Brand name",
},
"agree_to_custom_privacy_policy": {
Type: schema.TypeBool,
Optional: true,
Description: "Consent for updating the custom privacy policy URL.",
RequiredWith: []string{"custom_privacy_policy_url"},
},
"custom_privacy_policy_url": {
Type: schema.TypeString,
Optional: true,
Description: "Custom privacy policy URL",
DiffSuppressFunc: suppressDuringCreateFunc("brand_id"),
},
"links": {
Type: schema.TypeString,
Computed: true,
Description: "Link relations for this object - JSON HAL - Discoverable resources related to the brand",
},
"remove_powered_by_okta": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: `Removes "Powered by Okta" from the Okta-hosted sign-in page and "© 2021 Okta, Inc." from the Okta End-User Dashboard`,
DiffSuppressFunc: suppressDuringCreateFunc("brand_id"),
},
}

var brandDataSourceSchema = map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -90,7 +48,7 @@ var brandsDataSourceSchema = map[string]*schema.Schema{
},
}

func flattenBrand(brand *okta.Brand) map[string]interface{} {
func flattenBrand(brand *okta.BrandWithEmbedded) map[string]interface{} {
attrs := map[string]interface{}{}
attrs["id"] = brand.GetId()
attrs["custom_privacy_policy_url"] = ""
Expand All @@ -108,7 +66,7 @@ func flattenBrand(brand *okta.Brand) map[string]interface{} {
return attrs
}

func getDefaultBrand(ctx context.Context, m interface{}) (*okta.Brand, error) {
func getDefaultBrand(ctx context.Context, m interface{}) (*okta.BrandWithEmbedded, error) {
brands, _, err := getOktaV3ClientFromMetadata(m).CustomizationApi.ListBrands(ctx).Execute()
if err != nil {
return nil, err
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 @@ -25,7 +25,7 @@ func dataSourceBrand() *schema.Resource {
}

func dataSourceBrandRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var brand *okta.Brand
var brand *okta.BrandWithEmbedded
var err error
brandID := d.Get("brand_id").(string)

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 @@ -26,7 +26,7 @@ func dataSourceEmailTemplate() *schema.Resource {
}

func dataSourceEmailTemplateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var brand *okta.Brand
var brand *okta.BrandWithEmbedded
var err error
brandID, ok := d.GetOk("brand_id")
if ok {
Expand Down
4 changes: 2 additions & 2 deletions okta/data_source_okta_email_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func dataSourceEmailTemplates() *schema.Resource {
}

func dataSourceEmailTemplatesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var brand *okta.Brand
var brand *okta.BrandWithEmbedded
var err error
brandID, ok := d.GetOk("brand_id")
if ok {
Expand Down Expand Up @@ -58,7 +58,7 @@ func dataSourceEmailTemplatesRead(ctx context.Context, d *schema.ResourceData, m
return nil
}

func collectEmailTempates(ctx context.Context, client *okta.APIClient, brand *okta.Brand) ([]okta.EmailTemplate, error) {
func collectEmailTempates(ctx context.Context, client *okta.APIClient, brand *okta.BrandWithEmbedded) ([]okta.EmailTemplate, error) {
templates, resp, err := client.CustomizationApi.ListEmailTemplates(ctx, brand.GetId()).Limit(int32(defaultPaginationLimit)).Execute()
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions okta/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func (p *FrameworkProvider) DataSources(_ context.Context) []func() datasource.D
// DataSources defines the data sources implemented in the provider.
func (p *FrameworkProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewBrandResource,
NewPolicyDeviceAssuranceAndroidResource,
NewPolicyDeviceAssuranceIOSResource,
NewPolicyDeviceAssuranceChromeOSResource,
Expand Down
1 change: 0 additions & 1 deletion okta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ func Provider() *schema.Provider {
authServerPolicyRule: resourceAuthServerPolicyRule(),
authServerScope: resourceAuthServerScope(),
behavior: resourceBehavior(),
brand: resourceBrand(),
captcha: resourceCaptcha(),
captchaOrgWideSettings: resourceCaptchaOrgWideSettings(),
domain: resourceDomain(),
Expand Down
Loading