Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 54552f6

Browse files
committed
~ fix provider warning
1 parent 35884cf commit 54552f6

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

gcore/provider.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,27 @@ func Provider() *schema.Provider {
3030
return &schema.Provider{
3131
Schema: map[string]*schema.Schema{
3232
"user_name": {
33-
Type: schema.TypeString,
34-
Optional: true,
35-
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
36-
DefaultFunc: schema.EnvDefaultFunc("GCORE_USERNAME", nil),
33+
Type: schema.TypeString,
34+
Optional: true,
35+
AtLeastOneOf: []string{ProviderOptPermanentToken, "user_name"},
36+
RequiredWith: []string{"user_name", "password"},
37+
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
38+
DefaultFunc: schema.EnvDefaultFunc("GCORE_USERNAME", nil),
3739
},
3840
"password": {
39-
Type: schema.TypeString,
40-
Optional: true,
41-
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
42-
DefaultFunc: schema.EnvDefaultFunc("GCORE_PASSWORD", nil),
41+
Type: schema.TypeString,
42+
Optional: true,
43+
RequiredWith: []string{"user_name", "password"},
44+
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
45+
DefaultFunc: schema.EnvDefaultFunc("GCORE_PASSWORD", nil),
4346
},
4447
ProviderOptPermanentToken: {
45-
Type: schema.TypeString,
46-
Optional: true,
47-
Sensitive: true,
48-
Description: "A permanent [API-token](https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens)",
49-
DefaultFunc: schema.EnvDefaultFunc("GCORE_PERMANENT_TOKEN", ""),
48+
Type: schema.TypeString,
49+
Optional: true,
50+
AtLeastOneOf: []string{ProviderOptPermanentToken, "user_name"},
51+
Sensitive: true,
52+
Description: "A permanent [API-token](https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens)",
53+
DefaultFunc: schema.EnvDefaultFunc("GCORE_PERMANENT_TOKEN", nil),
5054
},
5155
ProviderOptSingleApiEndpoint: {
5256
Type: schema.TypeString,
@@ -59,9 +63,6 @@ func Provider() *schema.Provider {
5963
Optional: true,
6064
Deprecated: "It doesn't make any effect anymore",
6165
Description: "Should be set to true when you are gonna to use storage resource with permanent API-token only.",
62-
DefaultFunc: func() (interface{}, error) {
63-
return os.Getenv("GCORE_PERMANENT_TOKEN") != "", nil
64-
},
6566
},
6667
"gcore_platform": {
6768
Type: schema.TypeString,

0 commit comments

Comments
 (0)