Skip to content

Commit 4a17629

Browse files
committed
minor fixes
Signed-off-by: Sivaanand Murugesan <[email protected]>
1 parent e43da27 commit 4a17629

File tree

10 files changed

+126
-89
lines changed

10 files changed

+126
-89
lines changed

docs/resources/password_policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "spectrocloud_password_policy" "policy_regex" {
4848
- `min_password_length` (Number) The minimum length required for the password. Enforces a stronger password policy by ensuring a minimum number of characters. Default minimum length is `6`.
4949
- `min_special_characters` (Number) The minimum number of special characters (e.g., !, @, #, $, %) required in the password. This increases the password's security level by including symbols. Minimum special characters should be `1`.
5050
- `min_uppercase_letters` (Number) The minimum number of uppercase letters (A-Z) required in the password. Helps ensure password complexity with a mix of case-sensitive characters. Minimum length of upper case should be `1`.
51-
- `password_expiry_days` (Number) The number of days before the password expires. Must be between 1 and 1000 days. Defines how often passwords must be changed. Default is `999` days for expiry.
51+
- `password_expiry_days` (Number) The number of days before the password expires. Must be between 1 and 1000 days. Defines how often passwords must be changed. Default is `999` days for expiry. Conflicts with `min_password_length`, `min_uppercase_letters`, `min_digits`, `min_lowercase_letters`, `min_special_characters`
5252
- `password_regex` (String) A regular expression (regex) to define custom password patterns, such as enforcing specific characters or sequences in the password.
5353
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
5454

docs/resources/platform_setting.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ resource "spectrocloud_platform_setting" "platform_settings" {
5050
- `cluster_auto_remediation` (Boolean) Enables automatic remediation for unhealthy nodes in Palette-provisioned clusters by replacing them with new nodes. Disabling this feature prevents auto-remediation. Not applicable to `EKS`, `AKS`, or `TKE` clusters.
5151
- `context` (String) Defines the scope of the platform setting. Valid values are `project` or `tenant`. By default, it is set to `tenant`. If the `project` context is specified, the project name will sourced from the provider configuration parameter [`project_name`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs#schema).
5252
- `enable_auto_remediation` (Boolean) Enables automatic remediation. set only with `project' context
53-
- `login_banner` (Block List, Max: 1) Configure a login banner that users must acknowledge before signing in. (see [below for nested schema](#nestedblock--login_banner))
54-
- `non_fips_addon_pack` (Boolean) Allows users in this tenant to use non-FIPS-compliant addon packs when creating cluster profiles. The `non_fips_addon_pack` only supported in palette vertex environment.
55-
- `non_fips_cluster_import` (Boolean) Allows users in this tenant to import clusters, but the imported clusters may not be FIPS-compliant. The `non_fips_cluster_import` only supported in palette vertex environment.
56-
- `non_fips_features` (Boolean) Allows users in this tenant to access non-FIPS-compliant features such as backup, restore, and scans. The `non_fips_features` only supported in palette vertex environment.
53+
- `login_banner` (Block List, Max: 1) Configure a login banner that users must acknowledge before signing in. Allowed only for `tenant` context (see [below for nested schema](#nestedblock--login_banner))
54+
- `non_fips_addon_pack` (Boolean) Allows users in this tenant to use non-FIPS-compliant addon packs when creating cluster profiles. The `non_fips_addon_pack` only supported in palette vertex environment. Allowed only for `tenant` context
55+
- `non_fips_cluster_import` (Boolean) Allows users in this tenant to import clusters, but the imported clusters may not be FIPS-compliant. The `non_fips_cluster_import` only supported in palette vertex environment. Allowed only for `tenant` context
56+
- `non_fips_features` (Boolean) Allows users in this tenant to access non-FIPS-compliant features such as backup, restore, and scans. The `non_fips_features` only supported in palette vertex environment. Allowed only for `tenant` context
5757
- `pause_agent_upgrades` (String) Controls automatic upgrades for Palette components and agents in clusters deployed under a tenant or project. Setting it to `lock` disables automatic upgrades, while `unlock` (default) allows automatic upgrades.
58-
- `session_timeout` (Number) Specifies the duration (in minutes) of inactivity before a user is automatically logged out. The default is 240 minutes allowed in Palette
58+
- `session_timeout` (Number) Specifies the duration (in minutes) of inactivity before a user is automatically logged out. The default is 240 minutes allowed in Palette. Allowed only for `tenant` context
5959
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
6060

6161
### Read-Only

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/spectrocloud/terraform-provider-spectrocloud
22

3-
go 1.23.8
3+
go 1.23.10
4+
5+
toolchain go1.24.0
46

57
require (
68
github.com/Masterminds/semver/v3 v3.1.1
@@ -11,7 +13,7 @@ require (
1113
github.com/hashicorp/terraform-plugin-docs v0.16.0
1214
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
1315
github.com/robfig/cron v1.2.0
14-
github.com/spectrocloud/palette-sdk-go v0.0.0-20250609000517-b8c846462a23
16+
github.com/spectrocloud/palette-sdk-go v0.0.0-20250613174329-bb4a896f985c
1517
github.com/stretchr/testify v1.10.0
1618
gotest.tools v2.2.0+incompatible
1719
k8s.io/api v0.23.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
597597
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
598598
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
599599
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
600-
github.com/spectrocloud/palette-sdk-go v0.0.0-20250609000517-b8c846462a23 h1:zOML/YwK2glLhECgsAaDzhCa2UnT+L+rC6P8sVUeabY=
601-
github.com/spectrocloud/palette-sdk-go v0.0.0-20250609000517-b8c846462a23/go.mod h1:3/NvYC0TKTbjvnyfaNj+A5r3nVhwDJ26B3PF86RZ/cc=
600+
github.com/spectrocloud/palette-sdk-go v0.0.0-20250613174329-bb4a896f985c h1:iKoY+a/T3+ZVmrnQgyDiOvBt/FAI2TmcFXOYl83bgQQ=
601+
github.com/spectrocloud/palette-sdk-go v0.0.0-20250613174329-bb4a896f985c/go.mod h1:wIt8g7I7cmcQvTo5ktwhSF0/bWq6uRdxGBs9dwTpleU=
602602
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
603603
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
604604
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=

spectrocloud/common_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
const (
2828
negativeHost = "127.0.0.1:8888"
29-
host = "127.0.0.1:8080"
29+
host = "127.0.0.1:8088"
3030
trace = false
3131
retryAttempts = 10
3232
apiKey = "12345"
@@ -127,7 +127,7 @@ func checkMockServerHealth() error {
127127

128128
for i := 0; i < maxRetries; i++ {
129129
// Create a new HTTP request
130-
req, err := http.NewRequest("GET", "https://127.0.0.1:8080/v1/health", nil)
130+
req, err := http.NewRequest("GET", "https://127.0.0.1:8088/v1/health", nil)
131131
if err != nil {
132132
return err
133133
}
@@ -172,7 +172,7 @@ func setup() error {
172172
return err
173173
}
174174

175-
fmt.Printf("\033[1;36m%s\033[0m", "> Started Mock Api Server at https://127.0.0.1:8080 & https://127.0.0.1:8888 \n")
175+
fmt.Printf("\033[1;36m%s\033[0m", "> Started Mock Api Server at https://127.0.0.1:8088 & https://127.0.0.1:8888 \n")
176176
unitTestMockAPIClient, _ = unitTestProviderConfigure(ctx)
177177
unitTestMockAPINegativeClient, _ = unitTestNegativeCaseProviderConfigure(ctx)
178178
fmt.Printf("\033[1;36m%s\033[0m", "> Setup completed \n")

spectrocloud/provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func prepareBaseProviderConfig() *schema.ResourceData {
6363
}
6464

6565
d := basSchema.TestResourceData()
66-
_ = d.Set("host", "127.0.0.1:8080")
66+
_ = d.Set("host", "127.0.0.1:8088")
6767
_ = d.Set("project_name", "Default")
6868
_ = d.Set("ignore_insecure_tls_error", true)
6969
_ = d.Set("api_key", "12345")

spectrocloud/resource_password_policy.go

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package spectrocloud
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
79
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
810
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
911
"github.com/spectrocloud/palette-sdk-go/api/models"
10-
"time"
1112
)
1213

1314
func resourcePasswordPolicy() *schema.Resource {
@@ -19,6 +20,7 @@ func resourcePasswordPolicy() *schema.Resource {
1920
Importer: &schema.ResourceImporter{
2021
StateContext: resourcePasswordPolicyImport,
2122
},
23+
// CustomizeDiff: resourcePasswordPolicyCustomizeDiff,
2224

2325
Timeouts: &schema.ResourceTimeout{
2426
Create: schema.DefaultTimeout(10 * time.Minute),
@@ -28,20 +30,17 @@ func resourcePasswordPolicy() *schema.Resource {
2830
SchemaVersion: 2,
2931
Schema: map[string]*schema.Schema{
3032
"password_regex": {
31-
Type: schema.TypeString,
32-
Optional: true,
33-
Default: "",
34-
ConflictsWith: []string{"min_password_length", "min_uppercase_letters",
35-
"min_digits", "min_lowercase_letters", "min_special_characters"},
36-
RequiredWith: []string{"password_expiry_days", "first_reminder_days"},
37-
Description: "A regular expression (regex) to define custom password patterns, such as enforcing specific characters or sequences in the password.",
33+
Type: schema.TypeString,
34+
Optional: true,
35+
Default: "",
36+
Description: "A regular expression (regex) to define custom password patterns, such as enforcing specific characters or sequences in the password.",
3837
},
3938
"password_expiry_days": {
4039
Type: schema.TypeInt,
4140
Optional: true,
4241
Default: 999,
4342
ValidateFunc: validation.IntBetween(1, 1000),
44-
Description: "The number of days before the password expires. Must be between 1 and 1000 days. Defines how often passwords must be changed. Default is `999` days for expiry.",
43+
Description: "The number of days before the password expires. Must be between 1 and 1000 days. Defines how often passwords must be changed. Default is `999` days for expiry. Conflicts with `min_password_length`, `min_uppercase_letters`, `min_digits`, `min_lowercase_letters`, `min_special_characters`",
4544
},
4645
"first_reminder_days": {
4746
Type: schema.TypeInt,
@@ -78,6 +77,38 @@ func resourcePasswordPolicy() *schema.Resource {
7877
}
7978
}
8079

80+
// enable validation in later part of the code
81+
// func resourcePasswordPolicyCustomizeDiff(ctx context.Context, diff *schema.ResourceDiff, v interface{}) error {
82+
// passwordRegex := diff.Get("password_regex").(string)
83+
84+
// // If password_regex is set, check that the individual password requirements are not set
85+
// if passwordRegex != "" {
86+
// conflictingFields := []string{
87+
// "min_password_length",
88+
// "min_uppercase_letters",
89+
// "min_digits",
90+
// "min_lowercase_letters",
91+
// "min_special_characters",
92+
// }
93+
94+
// for _, field := range conflictingFields {
95+
// if val := diff.Get(field); val != nil && val != 0 {
96+
// return fmt.Errorf("password_regex cannot be used together with %s. Use either password_regex for custom patterns or the individual minimum requirements", field)
97+
// }
98+
// }
99+
100+
// // When using password_regex, password_expiry_days and first_reminder_days are required
101+
// if diff.Get("password_expiry_days").(int) == 0 {
102+
// return fmt.Errorf("password_expiry_days is required when using password_regex")
103+
// }
104+
// if diff.Get("first_reminder_days").(int) == 0 {
105+
// return fmt.Errorf("first_reminder_days is required when using password_regex")
106+
// }
107+
// }
108+
109+
// return nil
110+
// }
111+
81112
func toPasswordPolicy(d *schema.ResourceData) (*models.V1TenantPasswordPolicyEntity, error) {
82113
if d.Get("password_regex").(string) != "" {
83114
return &models.V1TenantPasswordPolicyEntity{

spectrocloud/resource_platform_setting.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package spectrocloud
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
79
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
810
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
911
"github.com/spectrocloud/palette-sdk-go/api/models"
10-
"time"
1112
)
1213

1314
func resourcePlatformSetting() *schema.Resource {
@@ -38,7 +39,7 @@ func resourcePlatformSetting() *schema.Resource {
3839
"session_timeout": {
3940
Type: schema.TypeInt,
4041
Optional: true,
41-
Description: "Specifies the duration (in minutes) of inactivity before a user is automatically logged out. The default is 240 minutes allowed in Palette",
42+
Description: "Specifies the duration (in minutes) of inactivity before a user is automatically logged out. The default is 240 minutes allowed in Palette. Allowed only for `tenant` context",
4243
},
4344
"pause_agent_upgrades": {
4445
Type: schema.TypeString,
@@ -64,23 +65,23 @@ func resourcePlatformSetting() *schema.Resource {
6465
"non_fips_addon_pack": {
6566
Type: schema.TypeBool,
6667
Optional: true,
67-
Description: "Allows users in this tenant to use non-FIPS-compliant addon packs when creating cluster profiles. The `non_fips_addon_pack` only supported in palette vertex environment.",
68+
Description: "Allows users in this tenant to use non-FIPS-compliant addon packs when creating cluster profiles. The `non_fips_addon_pack` only supported in palette vertex environment. Allowed only for `tenant` context",
6869
},
6970
"non_fips_features": {
7071
Type: schema.TypeBool,
7172
Optional: true,
72-
Description: "Allows users in this tenant to access non-FIPS-compliant features such as backup, restore, and scans. The `non_fips_features` only supported in palette vertex environment.",
73+
Description: "Allows users in this tenant to access non-FIPS-compliant features such as backup, restore, and scans. The `non_fips_features` only supported in palette vertex environment. Allowed only for `tenant` context",
7374
},
7475
"non_fips_cluster_import": {
7576
Type: schema.TypeBool,
7677
Optional: true,
77-
Description: "Allows users in this tenant to import clusters, but the imported clusters may not be FIPS-compliant. The `non_fips_cluster_import` only supported in palette vertex environment.",
78+
Description: "Allows users in this tenant to import clusters, but the imported clusters may not be FIPS-compliant. The `non_fips_cluster_import` only supported in palette vertex environment. Allowed only for `tenant` context",
7879
},
7980
"login_banner": {
8081
Type: schema.TypeList,
8182
MaxItems: 1,
8283
Optional: true,
83-
Description: "Configure a login banner that users must acknowledge before signing in.",
84+
Description: "Configure a login banner that users must acknowledge before signing in. Allowed only for `tenant` context",
8485
Elem: &schema.Resource{
8586
Schema: map[string]*schema.Schema{
8687
"title": {
@@ -97,24 +98,25 @@ func resourcePlatformSetting() *schema.Resource {
9798
},
9899
},
99100
},
100-
CustomizeDiff: validateContextDependencies,
101+
// CustomizeDiff: validateContextDependencies,
101102
}
102103
}
103104

104-
func validateContextDependencies(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
105-
contextVal := d.Get("context").(string)
106-
107-
if contextVal == "project" {
108-
disallowedFields := []string{"session_timeout", "login_banner", "non_fips_addon_pack", "non_fips_features", "non_fips_cluster_import"}
109-
110-
for _, field := range disallowedFields {
111-
if _, exists := d.GetOk(field); exists {
112-
return fmt.Errorf("attribute %q is not allowed when context is set to 'project'", field)
113-
}
114-
}
115-
}
116-
return nil
117-
}
105+
// disabled for now as it is not working as expected in crossplane
106+
// func validateContextDependencies(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
107+
// contextVal := d.Get("context").(string)
108+
109+
// if contextVal == "project" {
110+
// disallowedFields := []string{"session_timeout", "login_banner", "non_fips_addon_pack", "non_fips_features", "non_fips_cluster_import"}
111+
112+
// for _, field := range disallowedFields {
113+
// if _, exists := d.GetOk(field); exists {
114+
// return fmt.Errorf("attribute %q is not allowed when context is set to 'project'", field)
115+
// }
116+
// }
117+
// }
118+
// return nil
119+
// }
118120

119121
func updatePlatformSettings(d *schema.ResourceData, m interface{}) diag.Diagnostics {
120122
platformSettingContext := d.Get("context").(string)

spectrocloud/resource_sso.go

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import (
44
"context"
55
"encoding/base64"
66
"fmt"
7+
"regexp"
8+
"strings"
9+
"time"
10+
711
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
812
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
913
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1014
"github.com/spectrocloud/palette-sdk-go/api/models"
1115
"github.com/spectrocloud/palette-sdk-go/client"
12-
"regexp"
13-
"strings"
14-
"time"
1516
)
1617

1718
func resourceSSO() *schema.Resource {
@@ -336,7 +337,7 @@ func resourceSSO() *schema.Resource {
336337
},
337338
},
338339
},
339-
CustomizeDiff: customDiffValidation,
340+
// CustomizeDiff: customDiffValidation,
340341
}
341342
}
342343

@@ -594,39 +595,40 @@ func resourceSSODelete(ctx context.Context, d *schema.ResourceData, m interface{
594595
return diags
595596
}
596597

597-
func customDiffValidation(ctx context.Context, d *schema.ResourceDiff, v interface{}) error {
598-
ssoAuthType, ok := d.GetOk("sso_auth_type")
599-
if !ok {
600-
return nil // No validation needed if not set
601-
}
602-
603-
authType := ssoAuthType.(string)
604-
_, samlExists := d.GetOk("saml")
605-
_, oidcExists := d.GetOk("oidc")
606-
607-
switch authType {
608-
case "none":
609-
if samlExists || oidcExists {
610-
return fmt.Errorf("sso_auth_type is set to 'none', so 'saml' and 'oidc' should not be defined")
611-
}
612-
case "saml":
613-
if oidcExists {
614-
return fmt.Errorf("sso_auth_type is set to 'saml', so 'oidc' should not be defined")
615-
}
616-
if !samlExists {
617-
return fmt.Errorf("sso_auth_type is set to 'saml', so 'saml' should be defined")
618-
}
619-
case "oidc":
620-
if samlExists {
621-
return fmt.Errorf("sso_auth_type is set to 'oidc', so 'saml' should not be defined")
622-
}
623-
if !oidcExists {
624-
return fmt.Errorf("sso_auth_type is set to 'oidc', so 'oidc' should be defined")
625-
}
626-
}
627-
628-
return nil
629-
}
598+
// disabled for now as it is not working as expected in crossplane
599+
// func customDiffValidation(ctx context.Context, d *schema.ResourceDiff, v interface{}) error {
600+
// ssoAuthType, ok := d.GetOk("sso_auth_type")
601+
// if !ok {
602+
// return nil // No validation needed if not set
603+
// }
604+
605+
// authType := ssoAuthType.(string)
606+
// _, samlExists := d.GetOk("saml")
607+
// _, oidcExists := d.GetOk("oidc")
608+
609+
// switch authType {
610+
// case "none":
611+
// if samlExists || oidcExists {
612+
// return fmt.Errorf("sso_auth_type is set to 'none', so 'saml' and 'oidc' should not be defined")
613+
// }
614+
// case "saml":
615+
// if oidcExists {
616+
// return fmt.Errorf("sso_auth_type is set to 'saml', so 'oidc' should not be defined")
617+
// }
618+
// if !samlExists {
619+
// return fmt.Errorf("sso_auth_type is set to 'saml', so 'saml' should be defined")
620+
// }
621+
// case "oidc":
622+
// if samlExists {
623+
// return fmt.Errorf("sso_auth_type is set to 'oidc', so 'saml' should not be defined")
624+
// }
625+
// if !oidcExists {
626+
// return fmt.Errorf("sso_auth_type is set to 'oidc', so 'oidc' should be defined")
627+
// }
628+
// }
629+
630+
// return nil
631+
// }
630632

631633
func toStringSlice(input []interface{}) []string {
632634
result := make([]string, len(input))

0 commit comments

Comments
 (0)