generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 40
/
jenkins_data_source.go
100 lines (91 loc) · 2.9 KB
/
jenkins_data_source.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package connector
import (
"context"
"github.com/harness/harness-go-sdk/harness/nextgen"
"github.com/harness/terraform-provider-harness/helpers"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func DataSourceConnectorJenkins() *schema.Resource {
resource := &schema.Resource{
Description: "Datasource for looking up a Jenkins connector.",
ReadContext: dataConnectorJenkinsRead,
Schema: map[string]*schema.Schema{
"jenkins_url": {
Description: "Jenkins Url.",
Type: schema.TypeString,
Computed: true,
},
"delegate_selectors": {
Description: "Tags to filter delegates for connection.",
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"auth": {
Description: "This entity contains the details for Jenkins Authentication.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Description: "Can be one of UsernamePassword, Anonymous, BearerToken",
Type: schema.TypeString,
Computed: true,
},
"jenkins_bearer_token": {
Description: "Authenticate to App Dynamics using bearer token.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"token_ref": {
Description: "Reference of the token." + secret_ref_text,
Type: schema.TypeString,
Computed: true,
},
},
},
},
"jenkins_user_name_password": {
Description: "Authenticate to App Dynamics using user name and password.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"username": {
Description: "Username to use for authentication.",
Type: schema.TypeString,
Computed: true,
},
"username_ref": {
Description: "Username reference to use for authentication.",
Type: schema.TypeString,
Computed: true,
},
"password_ref": {
Description: "Reference to a secret containing the password to use for authentication." + secret_ref_text,
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
},
},
},
}
helpers.SetMultiLevelDatasourceSchemaIdentifierRequired(resource.Schema)
return resource
}
func dataConnectorJenkinsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn, err := dataConnectorReadBase(ctx, d, meta, nextgen.ConnectorTypes.Jenkins)
if err != nil {
return err
}
if err := readConnectorJenkins(d, conn); err != nil {
return diag.FromErr(err)
}
return nil
}