/
projectCluster.go
492 lines (430 loc) · 19.4 KB
/
projectCluster.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package gitlab
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The `ProjectCluster` resource allows to manage the lifecycle of a project cluster.
//
// > This is deprecated GitLab feature since 14.5
//
// **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/project_clusters.html)
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gitlab/sdk/v4/go/gitlab"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// foo, err := gitlab.NewProject(ctx, "foo", nil)
// if err != nil {
// return err
// }
// _, err = gitlab.NewProjectCluster(ctx, "bar", &gitlab.ProjectClusterArgs{
// Project: foo.ID(),
// Domain: pulumi.String("example.com"),
// Enabled: pulumi.Bool(true),
// KubernetesApiUrl: pulumi.String("https://124.124.124"),
// KubernetesToken: pulumi.String("some-token"),
// KubernetesCaCert: pulumi.String("some-cert"),
// KubernetesNamespace: pulumi.String("namespace"),
// KubernetesAuthorizationType: pulumi.String("rbac"),
// EnvironmentScope: pulumi.String("*"),
// ManagementProjectId: pulumi.String("123456"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// GitLab project clusters can be imported using an id made up of `projectid:clusterid`, e.g.
//
// ```sh
//
// $ pulumi import gitlab:index/projectCluster:ProjectCluster bar 123:321
//
// ```
type ProjectCluster struct {
pulumi.CustomResourceState
// Cluster type.
ClusterType pulumi.StringOutput `pulumi:"clusterType"`
// Create time.
CreatedAt pulumi.StringOutput `pulumi:"createdAt"`
// The base domain of the cluster.
Domain pulumi.StringPtrOutput `pulumi:"domain"`
// Determines if cluster is active or not. Defaults to `true`. This attribute cannot be read.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// The associated environment to the cluster. Defaults to `*`.
EnvironmentScope pulumi.StringPtrOutput `pulumi:"environmentScope"`
// The URL to access the Kubernetes API.
KubernetesApiUrl pulumi.StringOutput `pulumi:"kubernetesApiUrl"`
// The cluster authorization type. Valid values are `rbac`, `abac`, `unknownAuthorization`. Defaults to `rbac`.
KubernetesAuthorizationType pulumi.StringPtrOutput `pulumi:"kubernetesAuthorizationType"`
// TLS certificate (needed if API is using a self-signed TLS certificate).
KubernetesCaCert pulumi.StringPtrOutput `pulumi:"kubernetesCaCert"`
// The unique namespace related to the project.
KubernetesNamespace pulumi.StringPtrOutput `pulumi:"kubernetesNamespace"`
// The token to authenticate against Kubernetes.
KubernetesToken pulumi.StringOutput `pulumi:"kubernetesToken"`
// Determines if cluster is managed by gitlab or not. Defaults to `true`. This attribute cannot be read.
Managed pulumi.BoolPtrOutput `pulumi:"managed"`
// The ID of the management project for the cluster.
ManagementProjectId pulumi.StringPtrOutput `pulumi:"managementProjectId"`
// The name of cluster.
Name pulumi.StringOutput `pulumi:"name"`
// Platform type.
PlatformType pulumi.StringOutput `pulumi:"platformType"`
// The id of the project to add the cluster to.
Project pulumi.StringOutput `pulumi:"project"`
// Provider type.
ProviderType pulumi.StringOutput `pulumi:"providerType"`
}
// NewProjectCluster registers a new resource with the given unique name, arguments, and options.
func NewProjectCluster(ctx *pulumi.Context,
name string, args *ProjectClusterArgs, opts ...pulumi.ResourceOption) (*ProjectCluster, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.KubernetesApiUrl == nil {
return nil, errors.New("invalid value for required argument 'KubernetesApiUrl'")
}
if args.KubernetesToken == nil {
return nil, errors.New("invalid value for required argument 'KubernetesToken'")
}
if args.Project == nil {
return nil, errors.New("invalid value for required argument 'Project'")
}
if args.KubernetesToken != nil {
args.KubernetesToken = pulumi.ToSecret(args.KubernetesToken).(pulumi.StringInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"kubernetesToken",
})
opts = append(opts, secrets)
var resource ProjectCluster
err := ctx.RegisterResource("gitlab:index/projectCluster:ProjectCluster", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProjectCluster gets an existing ProjectCluster resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetProjectCluster(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProjectClusterState, opts ...pulumi.ResourceOption) (*ProjectCluster, error) {
var resource ProjectCluster
err := ctx.ReadResource("gitlab:index/projectCluster:ProjectCluster", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ProjectCluster resources.
type projectClusterState struct {
// Cluster type.
ClusterType *string `pulumi:"clusterType"`
// Create time.
CreatedAt *string `pulumi:"createdAt"`
// The base domain of the cluster.
Domain *string `pulumi:"domain"`
// Determines if cluster is active or not. Defaults to `true`. This attribute cannot be read.
Enabled *bool `pulumi:"enabled"`
// The associated environment to the cluster. Defaults to `*`.
EnvironmentScope *string `pulumi:"environmentScope"`
// The URL to access the Kubernetes API.
KubernetesApiUrl *string `pulumi:"kubernetesApiUrl"`
// The cluster authorization type. Valid values are `rbac`, `abac`, `unknownAuthorization`. Defaults to `rbac`.
KubernetesAuthorizationType *string `pulumi:"kubernetesAuthorizationType"`
// TLS certificate (needed if API is using a self-signed TLS certificate).
KubernetesCaCert *string `pulumi:"kubernetesCaCert"`
// The unique namespace related to the project.
KubernetesNamespace *string `pulumi:"kubernetesNamespace"`
// The token to authenticate against Kubernetes.
KubernetesToken *string `pulumi:"kubernetesToken"`
// Determines if cluster is managed by gitlab or not. Defaults to `true`. This attribute cannot be read.
Managed *bool `pulumi:"managed"`
// The ID of the management project for the cluster.
ManagementProjectId *string `pulumi:"managementProjectId"`
// The name of cluster.
Name *string `pulumi:"name"`
// Platform type.
PlatformType *string `pulumi:"platformType"`
// The id of the project to add the cluster to.
Project *string `pulumi:"project"`
// Provider type.
ProviderType *string `pulumi:"providerType"`
}
type ProjectClusterState struct {
// Cluster type.
ClusterType pulumi.StringPtrInput
// Create time.
CreatedAt pulumi.StringPtrInput
// The base domain of the cluster.
Domain pulumi.StringPtrInput
// Determines if cluster is active or not. Defaults to `true`. This attribute cannot be read.
Enabled pulumi.BoolPtrInput
// The associated environment to the cluster. Defaults to `*`.
EnvironmentScope pulumi.StringPtrInput
// The URL to access the Kubernetes API.
KubernetesApiUrl pulumi.StringPtrInput
// The cluster authorization type. Valid values are `rbac`, `abac`, `unknownAuthorization`. Defaults to `rbac`.
KubernetesAuthorizationType pulumi.StringPtrInput
// TLS certificate (needed if API is using a self-signed TLS certificate).
KubernetesCaCert pulumi.StringPtrInput
// The unique namespace related to the project.
KubernetesNamespace pulumi.StringPtrInput
// The token to authenticate against Kubernetes.
KubernetesToken pulumi.StringPtrInput
// Determines if cluster is managed by gitlab or not. Defaults to `true`. This attribute cannot be read.
Managed pulumi.BoolPtrInput
// The ID of the management project for the cluster.
ManagementProjectId pulumi.StringPtrInput
// The name of cluster.
Name pulumi.StringPtrInput
// Platform type.
PlatformType pulumi.StringPtrInput
// The id of the project to add the cluster to.
Project pulumi.StringPtrInput
// Provider type.
ProviderType pulumi.StringPtrInput
}
func (ProjectClusterState) ElementType() reflect.Type {
return reflect.TypeOf((*projectClusterState)(nil)).Elem()
}
type projectClusterArgs struct {
// The base domain of the cluster.
Domain *string `pulumi:"domain"`
// Determines if cluster is active or not. Defaults to `true`. This attribute cannot be read.
Enabled *bool `pulumi:"enabled"`
// The associated environment to the cluster. Defaults to `*`.
EnvironmentScope *string `pulumi:"environmentScope"`
// The URL to access the Kubernetes API.
KubernetesApiUrl string `pulumi:"kubernetesApiUrl"`
// The cluster authorization type. Valid values are `rbac`, `abac`, `unknownAuthorization`. Defaults to `rbac`.
KubernetesAuthorizationType *string `pulumi:"kubernetesAuthorizationType"`
// TLS certificate (needed if API is using a self-signed TLS certificate).
KubernetesCaCert *string `pulumi:"kubernetesCaCert"`
// The unique namespace related to the project.
KubernetesNamespace *string `pulumi:"kubernetesNamespace"`
// The token to authenticate against Kubernetes.
KubernetesToken string `pulumi:"kubernetesToken"`
// Determines if cluster is managed by gitlab or not. Defaults to `true`. This attribute cannot be read.
Managed *bool `pulumi:"managed"`
// The ID of the management project for the cluster.
ManagementProjectId *string `pulumi:"managementProjectId"`
// The name of cluster.
Name *string `pulumi:"name"`
// The id of the project to add the cluster to.
Project string `pulumi:"project"`
}
// The set of arguments for constructing a ProjectCluster resource.
type ProjectClusterArgs struct {
// The base domain of the cluster.
Domain pulumi.StringPtrInput
// Determines if cluster is active or not. Defaults to `true`. This attribute cannot be read.
Enabled pulumi.BoolPtrInput
// The associated environment to the cluster. Defaults to `*`.
EnvironmentScope pulumi.StringPtrInput
// The URL to access the Kubernetes API.
KubernetesApiUrl pulumi.StringInput
// The cluster authorization type. Valid values are `rbac`, `abac`, `unknownAuthorization`. Defaults to `rbac`.
KubernetesAuthorizationType pulumi.StringPtrInput
// TLS certificate (needed if API is using a self-signed TLS certificate).
KubernetesCaCert pulumi.StringPtrInput
// The unique namespace related to the project.
KubernetesNamespace pulumi.StringPtrInput
// The token to authenticate against Kubernetes.
KubernetesToken pulumi.StringInput
// Determines if cluster is managed by gitlab or not. Defaults to `true`. This attribute cannot be read.
Managed pulumi.BoolPtrInput
// The ID of the management project for the cluster.
ManagementProjectId pulumi.StringPtrInput
// The name of cluster.
Name pulumi.StringPtrInput
// The id of the project to add the cluster to.
Project pulumi.StringInput
}
func (ProjectClusterArgs) ElementType() reflect.Type {
return reflect.TypeOf((*projectClusterArgs)(nil)).Elem()
}
type ProjectClusterInput interface {
pulumi.Input
ToProjectClusterOutput() ProjectClusterOutput
ToProjectClusterOutputWithContext(ctx context.Context) ProjectClusterOutput
}
func (*ProjectCluster) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectCluster)(nil)).Elem()
}
func (i *ProjectCluster) ToProjectClusterOutput() ProjectClusterOutput {
return i.ToProjectClusterOutputWithContext(context.Background())
}
func (i *ProjectCluster) ToProjectClusterOutputWithContext(ctx context.Context) ProjectClusterOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectClusterOutput)
}
// ProjectClusterArrayInput is an input type that accepts ProjectClusterArray and ProjectClusterArrayOutput values.
// You can construct a concrete instance of `ProjectClusterArrayInput` via:
//
// ProjectClusterArray{ ProjectClusterArgs{...} }
type ProjectClusterArrayInput interface {
pulumi.Input
ToProjectClusterArrayOutput() ProjectClusterArrayOutput
ToProjectClusterArrayOutputWithContext(context.Context) ProjectClusterArrayOutput
}
type ProjectClusterArray []ProjectClusterInput
func (ProjectClusterArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectCluster)(nil)).Elem()
}
func (i ProjectClusterArray) ToProjectClusterArrayOutput() ProjectClusterArrayOutput {
return i.ToProjectClusterArrayOutputWithContext(context.Background())
}
func (i ProjectClusterArray) ToProjectClusterArrayOutputWithContext(ctx context.Context) ProjectClusterArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectClusterArrayOutput)
}
// ProjectClusterMapInput is an input type that accepts ProjectClusterMap and ProjectClusterMapOutput values.
// You can construct a concrete instance of `ProjectClusterMapInput` via:
//
// ProjectClusterMap{ "key": ProjectClusterArgs{...} }
type ProjectClusterMapInput interface {
pulumi.Input
ToProjectClusterMapOutput() ProjectClusterMapOutput
ToProjectClusterMapOutputWithContext(context.Context) ProjectClusterMapOutput
}
type ProjectClusterMap map[string]ProjectClusterInput
func (ProjectClusterMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectCluster)(nil)).Elem()
}
func (i ProjectClusterMap) ToProjectClusterMapOutput() ProjectClusterMapOutput {
return i.ToProjectClusterMapOutputWithContext(context.Background())
}
func (i ProjectClusterMap) ToProjectClusterMapOutputWithContext(ctx context.Context) ProjectClusterMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectClusterMapOutput)
}
type ProjectClusterOutput struct{ *pulumi.OutputState }
func (ProjectClusterOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectCluster)(nil)).Elem()
}
func (o ProjectClusterOutput) ToProjectClusterOutput() ProjectClusterOutput {
return o
}
func (o ProjectClusterOutput) ToProjectClusterOutputWithContext(ctx context.Context) ProjectClusterOutput {
return o
}
// Cluster type.
func (o ProjectClusterOutput) ClusterType() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.ClusterType }).(pulumi.StringOutput)
}
// Create time.
func (o ProjectClusterOutput) CreatedAt() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.CreatedAt }).(pulumi.StringOutput)
}
// The base domain of the cluster.
func (o ProjectClusterOutput) Domain() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringPtrOutput { return v.Domain }).(pulumi.StringPtrOutput)
}
// Determines if cluster is active or not. Defaults to `true`. This attribute cannot be read.
func (o ProjectClusterOutput) Enabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
}
// The associated environment to the cluster. Defaults to `*`.
func (o ProjectClusterOutput) EnvironmentScope() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringPtrOutput { return v.EnvironmentScope }).(pulumi.StringPtrOutput)
}
// The URL to access the Kubernetes API.
func (o ProjectClusterOutput) KubernetesApiUrl() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.KubernetesApiUrl }).(pulumi.StringOutput)
}
// The cluster authorization type. Valid values are `rbac`, `abac`, `unknownAuthorization`. Defaults to `rbac`.
func (o ProjectClusterOutput) KubernetesAuthorizationType() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringPtrOutput { return v.KubernetesAuthorizationType }).(pulumi.StringPtrOutput)
}
// TLS certificate (needed if API is using a self-signed TLS certificate).
func (o ProjectClusterOutput) KubernetesCaCert() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringPtrOutput { return v.KubernetesCaCert }).(pulumi.StringPtrOutput)
}
// The unique namespace related to the project.
func (o ProjectClusterOutput) KubernetesNamespace() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringPtrOutput { return v.KubernetesNamespace }).(pulumi.StringPtrOutput)
}
// The token to authenticate against Kubernetes.
func (o ProjectClusterOutput) KubernetesToken() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.KubernetesToken }).(pulumi.StringOutput)
}
// Determines if cluster is managed by gitlab or not. Defaults to `true`. This attribute cannot be read.
func (o ProjectClusterOutput) Managed() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.BoolPtrOutput { return v.Managed }).(pulumi.BoolPtrOutput)
}
// The ID of the management project for the cluster.
func (o ProjectClusterOutput) ManagementProjectId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringPtrOutput { return v.ManagementProjectId }).(pulumi.StringPtrOutput)
}
// The name of cluster.
func (o ProjectClusterOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Platform type.
func (o ProjectClusterOutput) PlatformType() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.PlatformType }).(pulumi.StringOutput)
}
// The id of the project to add the cluster to.
func (o ProjectClusterOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
// Provider type.
func (o ProjectClusterOutput) ProviderType() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectCluster) pulumi.StringOutput { return v.ProviderType }).(pulumi.StringOutput)
}
type ProjectClusterArrayOutput struct{ *pulumi.OutputState }
func (ProjectClusterArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectCluster)(nil)).Elem()
}
func (o ProjectClusterArrayOutput) ToProjectClusterArrayOutput() ProjectClusterArrayOutput {
return o
}
func (o ProjectClusterArrayOutput) ToProjectClusterArrayOutputWithContext(ctx context.Context) ProjectClusterArrayOutput {
return o
}
func (o ProjectClusterArrayOutput) Index(i pulumi.IntInput) ProjectClusterOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ProjectCluster {
return vs[0].([]*ProjectCluster)[vs[1].(int)]
}).(ProjectClusterOutput)
}
type ProjectClusterMapOutput struct{ *pulumi.OutputState }
func (ProjectClusterMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectCluster)(nil)).Elem()
}
func (o ProjectClusterMapOutput) ToProjectClusterMapOutput() ProjectClusterMapOutput {
return o
}
func (o ProjectClusterMapOutput) ToProjectClusterMapOutputWithContext(ctx context.Context) ProjectClusterMapOutput {
return o
}
func (o ProjectClusterMapOutput) MapIndex(k pulumi.StringInput) ProjectClusterOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ProjectCluster {
return vs[0].(map[string]*ProjectCluster)[vs[1].(string)]
}).(ProjectClusterOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProjectClusterInput)(nil)).Elem(), &ProjectCluster{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectClusterArrayInput)(nil)).Elem(), ProjectClusterArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectClusterMapInput)(nil)).Elem(), ProjectClusterMap{})
pulumi.RegisterOutputType(ProjectClusterOutput{})
pulumi.RegisterOutputType(ProjectClusterArrayOutput{})
pulumi.RegisterOutputType(ProjectClusterMapOutput{})
}