@@ -30,23 +30,27 @@ func Provider() *schema.Provider {
30
30
return & schema.Provider {
31
31
Schema : map [string ]* schema.Schema {
32
32
"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 ),
37
39
},
38
40
"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 ),
43
46
},
44
47
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 ),
50
54
},
51
55
ProviderOptSingleApiEndpoint : {
52
56
Type : schema .TypeString ,
@@ -59,9 +63,6 @@ func Provider() *schema.Provider {
59
63
Optional : true ,
60
64
Deprecated : "It doesn't make any effect anymore" ,
61
65
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
- },
65
66
},
66
67
"gcore_platform" : {
67
68
Type : schema .TypeString ,
0 commit comments