-
Notifications
You must be signed in to change notification settings - Fork 132
/
types_cloud_project_kube_oidc.go
85 lines (75 loc) · 3.32 KB
/
types_cloud_project_kube_oidc.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package ovh
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/ovh/terraform-provider-ovh/ovh/helpers"
)
type CloudProjectKubeOIDCCreateOpts struct {
ClientID string `json:"clientId"`
IssuerUrl string `json:"issuerUrl"`
UsernameClaim string `json:"usernameClaim"`
UsernamePrefix string `json:"usernamePrefix"`
GroupsClaim []string `json:"groupsClaim"`
GroupsPrefix string `json:"groupsPrefix"`
RequiredClaim []string `json:"requiredClaim"`
SigningAlgs []string `json:"signingAlgorithms"`
CaContent string `json:"caContent"`
}
type CloudProjectKubeOIDCUpdateOpts struct {
ClientID string `json:"clientId"`
IssuerUrl string `json:"issuerUrl"`
UsernameClaim string `json:"usernameClaim"`
UsernamePrefix string `json:"usernamePrefix"`
GroupsClaim []string `json:"groupsClaim"`
GroupsPrefix string `json:"groupsPrefix"`
RequiredClaim []string `json:"requiredClaim"`
SigningAlgs []string `json:"signingAlgorithms"`
CaContent string `json:"caContent"`
}
type CloudProjectKubeOIDCResponse struct {
ClientID string `json:"clientId"`
IssuerUrl string `json:"issuerUrl"`
UsernameClaim string `json:"usernameClaim"`
UsernamePrefix string `json:"usernamePrefix"`
GroupsClaim []string `json:"groupsClaim"`
GroupsPrefix string `json:"groupsPrefix"`
RequiredClaim []string `json:"requiredClaim"`
SigningAlgs []string `json:"signingAlgorithms"`
CaContent string `json:"caContent"`
}
func (opts *CloudProjectKubeOIDCCreateOpts) FromResource(d *schema.ResourceData) *CloudProjectKubeOIDCCreateOpts {
opts.ClientID = d.Get("client_id").(string)
opts.IssuerUrl = d.Get("issuer_url").(string)
opts.UsernameClaim = d.Get("oidc_username_claim").(string)
opts.UsernamePrefix = d.Get("oidc_username_prefix").(string)
opts.GroupsClaim, _ = helpers.StringsFromSchema(d, "oidc_groups_claim")
opts.GroupsPrefix = d.Get("oidc_groups_prefix").(string)
opts.RequiredClaim, _ = helpers.StringsFromSchema(d, "oidc_required_claim")
opts.SigningAlgs, _ = helpers.StringsFromSchema(d, "oidc_signing_algs")
opts.CaContent = d.Get("oidc_ca_content").(string)
return opts
}
func (opts *CloudProjectKubeOIDCUpdateOpts) FromResource(d *schema.ResourceData) *CloudProjectKubeOIDCUpdateOpts {
opts.ClientID = d.Get("client_id").(string)
opts.IssuerUrl = d.Get("issuer_url").(string)
opts.UsernameClaim = d.Get("oidc_username_claim").(string)
opts.UsernamePrefix = d.Get("oidc_username_prefix").(string)
opts.GroupsClaim, _ = helpers.StringsFromSchema(d, "oidc_groups_claim")
opts.GroupsPrefix = d.Get("oidc_groups_prefix").(string)
opts.RequiredClaim, _ = helpers.StringsFromSchema(d, "oidc_required_claim")
opts.SigningAlgs, _ = helpers.StringsFromSchema(d, "oidc_signing_algs")
opts.CaContent = d.Get("oidc_ca_content").(string)
return opts
}
func (v CloudProjectKubeOIDCResponse) ToMap() map[string]interface{} {
obj := make(map[string]interface{})
obj["client_id"] = v.ClientID
obj["issuer_url"] = v.IssuerUrl
obj["oidc_username_claim"] = v.UsernameClaim
obj["oidc_username_prefix"] = v.UsernamePrefix
obj["oidc_groups_claim"] = v.GroupsClaim
obj["oidc_groups_prefix"] = v.GroupsPrefix
obj["oidc_required_claim"] = v.RequiredClaim
obj["oidc_signing_algs"] = v.SigningAlgs
obj["oidc_ca_content"] = v.CaContent
return obj
}