-
Notifications
You must be signed in to change notification settings - Fork 9
/
base.go
64 lines (60 loc) · 2.63 KB
/
base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package sqlLogin
import (
"fmt"
"github.com/PGSSoft/terraform-provider-mssql/internal/services/common"
"github.com/PGSSoft/terraform-provider-mssql/internal/sql"
"github.com/PGSSoft/terraform-provider-mssql/internal/validators"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
)
var attributes = map[string]tfsdk.Attribute{
"id": {
MarkdownDescription: "Login SID. Can be retrieved using `SELECT SUSER_SID('<login_name>')`.",
Type: types.StringType,
},
"name": {
MarkdownDescription: fmt.Sprintf("Login name. %s and cannot contain `\\ `", common.RegularIdentifiersDoc),
Type: types.StringType,
Validators: validators.LoginNameValidators,
},
"must_change_password": {
MarkdownDescription: "When true, password change will be forced on first logon.",
Type: types.BoolType,
},
"default_database_id": {
MarkdownDescription: "ID of login's default DB. The ID can be retrieved using `mssql_database` data resource.",
Type: types.StringType,
},
"default_language": {
Description: "Default language assigned to login.",
Type: types.StringType,
},
"check_password_expiration": {
MarkdownDescription: "When `true`, password expiration policy is enforced for this login.",
Type: types.BoolType,
},
"check_password_policy": {
MarkdownDescription: "When `true`, the Windows password policies of the computer on which SQL Server is running are enforced on this login.",
Type: types.BoolType,
},
}
type dataSourceData struct {
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
MustChangePassword types.Bool `tfsdk:"must_change_password"`
DefaultDatabaseId types.String `tfsdk:"default_database_id"`
DefaultLanguage types.String `tfsdk:"default_language"`
CheckPasswordExpiration types.Bool `tfsdk:"check_password_expiration"`
CheckPasswordPolicy types.Bool `tfsdk:"check_password_policy"`
}
func (d dataSourceData) withSettings(settings sql.SqlLoginSettings) dataSourceData {
return dataSourceData{
Id: d.Id,
Name: types.String{Value: settings.Name},
MustChangePassword: types.Bool{Value: settings.MustChangePassword},
DefaultDatabaseId: types.String{Value: fmt.Sprint(settings.DefaultDatabaseId)},
DefaultLanguage: types.String{Value: settings.DefaultLanguage},
CheckPasswordExpiration: types.Bool{Value: settings.CheckPasswordExpiration},
CheckPasswordPolicy: types.Bool{Value: settings.CheckPasswordPolicy},
}
}