github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.30.2/go/kubernetes/batch/v1/job.go (about) 1 // Code generated by pulumigen DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package v1 5 6 import ( 7 "context" 8 "reflect" 9 10 metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Job represents the configuration of a single job. 15 // 16 // This resource waits until its status is ready before registering success 17 // for create/update, and populating output properties from the current state of the resource. 18 // The following conditions are used to determine whether the resource creation has 19 // succeeded or failed: 20 // 21 // 1. The Job's '.status.startTime' is set, which indicates that the Job has started running. 22 // 2. The Job's '.status.conditions' has a status of type 'Complete', and a 'status' set 23 // to 'True'. 24 // 3. The Job's '.status.conditions' do not have a status of type 'Failed', with a 25 // 'status' set to 'True'. If this condition is set, we should fail the Job immediately. 26 // 27 // If the Job has not reached a Ready state after 10 minutes, it will 28 // time out and mark the resource update as Failed. You can override the default timeout value 29 // by setting the 'customTimeouts' option on the resource. 30 // 31 // By default, if a resource failed to become ready in a previous update, 32 // Pulumi will continue to wait for readiness on the next update. If you would prefer 33 // to schedule a replacement for an unready resource on the next update, you can add the 34 // "pulumi.com/replaceUnready": "true" annotation to the resource definition. 35 // 36 // ## Example Usage 37 // ### Create a Job with auto-naming 38 // ```go 39 // package main 40 // 41 // import ( 42 // 43 // batchv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/batch/v1" 44 // corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" 45 // metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1" 46 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 47 // 48 // ) 49 // 50 // func main() { 51 // pulumi.Run(func(ctx *pulumi.Context) error { 52 // _, err := batchv1.NewJob(ctx, "job", &batchv1.JobArgs{ 53 // Metadata: nil, 54 // Spec: &batchv1.JobSpecArgs{ 55 // BackoffLimit: pulumi.Int(4), 56 // Template: &corev1.PodTemplateSpecArgs{ 57 // Spec: &corev1.PodSpecArgs{ 58 // Containers: corev1.ContainerArray{ 59 // &corev1.ContainerArgs{ 60 // Command: pulumi.StringArray{ 61 // pulumi.String("perl"), 62 // pulumi.String("-Mbignum=bpi"), 63 // pulumi.String("-wle"), 64 // pulumi.String("print bpi(2000)"), 65 // }, 66 // Image: pulumi.String("perl"), 67 // Name: pulumi.String("pi"), 68 // }, 69 // }, 70 // RestartPolicy: pulumi.String("Never"), 71 // }, 72 // }, 73 // }, 74 // }) 75 // if err != nil { 76 // return err 77 // } 78 // return nil 79 // }) 80 // } 81 // 82 // ``` 83 // ### Create a Job with a user-specified name 84 // ```go 85 // package main 86 // 87 // import ( 88 // 89 // batchv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/batch/v1" 90 // corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" 91 // metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1" 92 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 93 // 94 // ) 95 // 96 // func main() { 97 // pulumi.Run(func(ctx *pulumi.Context) error { 98 // _, err := batchv1.NewJob(ctx, "job", &batchv1.JobArgs{ 99 // Metadata: &metav1.ObjectMetaArgs{ 100 // Name: pulumi.String("pi"), 101 // }, 102 // Spec: &batchv1.JobSpecArgs{ 103 // BackoffLimit: pulumi.Int(4), 104 // Template: &corev1.PodTemplateSpecArgs{ 105 // Spec: &corev1.PodSpecArgs{ 106 // Containers: corev1.ContainerArray{ 107 // &corev1.ContainerArgs{ 108 // Command: pulumi.StringArray{ 109 // pulumi.String("perl"), 110 // pulumi.String("-Mbignum=bpi"), 111 // pulumi.String("-wle"), 112 // pulumi.String("print bpi(2000)"), 113 // }, 114 // Image: pulumi.String("perl"), 115 // Name: pulumi.String("pi"), 116 // }, 117 // }, 118 // RestartPolicy: pulumi.String("Never"), 119 // }, 120 // }, 121 // }, 122 // }) 123 // if err != nil { 124 // return err 125 // } 126 // return nil 127 // }) 128 // } 129 // 130 // ``` 131 type Job struct { 132 pulumi.CustomResourceState 133 134 // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources 135 ApiVersion pulumi.StringPtrOutput `pulumi:"apiVersion"` 136 // Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds 137 Kind pulumi.StringPtrOutput `pulumi:"kind"` 138 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 139 Metadata metav1.ObjectMetaPtrOutput `pulumi:"metadata"` 140 // Specification of the desired behavior of a job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 141 Spec JobSpecPtrOutput `pulumi:"spec"` 142 // Current status of a job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 143 Status JobStatusPtrOutput `pulumi:"status"` 144 } 145 146 // NewJob registers a new resource with the given unique name, arguments, and options. 147 func NewJob(ctx *pulumi.Context, 148 name string, args *JobArgs, opts ...pulumi.ResourceOption) (*Job, error) { 149 if args == nil { 150 args = &JobArgs{} 151 } 152 153 args.ApiVersion = pulumi.StringPtr("batch/v1") 154 args.Kind = pulumi.StringPtr("Job") 155 var resource Job 156 err := ctx.RegisterResource("kubernetes:batch/v1:Job", name, args, &resource, opts...) 157 if err != nil { 158 return nil, err 159 } 160 return &resource, nil 161 } 162 163 // GetJob gets an existing Job resource's state with the given name, ID, and optional 164 // state properties that are used to uniquely qualify the lookup (nil if not required). 165 func GetJob(ctx *pulumi.Context, 166 name string, id pulumi.IDInput, state *JobState, opts ...pulumi.ResourceOption) (*Job, error) { 167 var resource Job 168 err := ctx.ReadResource("kubernetes:batch/v1:Job", name, id, state, &resource, opts...) 169 if err != nil { 170 return nil, err 171 } 172 return &resource, nil 173 } 174 175 // Input properties used for looking up and filtering Job resources. 176 type jobState struct { 177 } 178 179 type JobState struct { 180 } 181 182 func (JobState) ElementType() reflect.Type { 183 return reflect.TypeOf((*jobState)(nil)).Elem() 184 } 185 186 type jobArgs struct { 187 // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources 188 ApiVersion *string `pulumi:"apiVersion"` 189 // Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds 190 Kind *string `pulumi:"kind"` 191 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 192 Metadata *metav1.ObjectMeta `pulumi:"metadata"` 193 // Specification of the desired behavior of a job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 194 Spec *JobSpec `pulumi:"spec"` 195 } 196 197 // The set of arguments for constructing a Job resource. 198 type JobArgs struct { 199 // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources 200 ApiVersion pulumi.StringPtrInput 201 // Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds 202 Kind pulumi.StringPtrInput 203 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 204 Metadata metav1.ObjectMetaPtrInput 205 // Specification of the desired behavior of a job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 206 Spec JobSpecPtrInput 207 } 208 209 func (JobArgs) ElementType() reflect.Type { 210 return reflect.TypeOf((*jobArgs)(nil)).Elem() 211 } 212 213 type JobInput interface { 214 pulumi.Input 215 216 ToJobOutput() JobOutput 217 ToJobOutputWithContext(ctx context.Context) JobOutput 218 } 219 220 func (*Job) ElementType() reflect.Type { 221 return reflect.TypeOf((**Job)(nil)).Elem() 222 } 223 224 func (i *Job) ToJobOutput() JobOutput { 225 return i.ToJobOutputWithContext(context.Background()) 226 } 227 228 func (i *Job) ToJobOutputWithContext(ctx context.Context) JobOutput { 229 return pulumi.ToOutputWithContext(ctx, i).(JobOutput) 230 } 231 232 // JobArrayInput is an input type that accepts JobArray and JobArrayOutput values. 233 // You can construct a concrete instance of `JobArrayInput` via: 234 // 235 // JobArray{ JobArgs{...} } 236 type JobArrayInput interface { 237 pulumi.Input 238 239 ToJobArrayOutput() JobArrayOutput 240 ToJobArrayOutputWithContext(context.Context) JobArrayOutput 241 } 242 243 type JobArray []JobInput 244 245 func (JobArray) ElementType() reflect.Type { 246 return reflect.TypeOf((*[]*Job)(nil)).Elem() 247 } 248 249 func (i JobArray) ToJobArrayOutput() JobArrayOutput { 250 return i.ToJobArrayOutputWithContext(context.Background()) 251 } 252 253 func (i JobArray) ToJobArrayOutputWithContext(ctx context.Context) JobArrayOutput { 254 return pulumi.ToOutputWithContext(ctx, i).(JobArrayOutput) 255 } 256 257 // JobMapInput is an input type that accepts JobMap and JobMapOutput values. 258 // You can construct a concrete instance of `JobMapInput` via: 259 // 260 // JobMap{ "key": JobArgs{...} } 261 type JobMapInput interface { 262 pulumi.Input 263 264 ToJobMapOutput() JobMapOutput 265 ToJobMapOutputWithContext(context.Context) JobMapOutput 266 } 267 268 type JobMap map[string]JobInput 269 270 func (JobMap) ElementType() reflect.Type { 271 return reflect.TypeOf((*map[string]*Job)(nil)).Elem() 272 } 273 274 func (i JobMap) ToJobMapOutput() JobMapOutput { 275 return i.ToJobMapOutputWithContext(context.Background()) 276 } 277 278 func (i JobMap) ToJobMapOutputWithContext(ctx context.Context) JobMapOutput { 279 return pulumi.ToOutputWithContext(ctx, i).(JobMapOutput) 280 } 281 282 type JobOutput struct{ *pulumi.OutputState } 283 284 func (JobOutput) ElementType() reflect.Type { 285 return reflect.TypeOf((**Job)(nil)).Elem() 286 } 287 288 func (o JobOutput) ToJobOutput() JobOutput { 289 return o 290 } 291 292 func (o JobOutput) ToJobOutputWithContext(ctx context.Context) JobOutput { 293 return o 294 } 295 296 // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources 297 func (o JobOutput) ApiVersion() pulumi.StringPtrOutput { 298 return o.ApplyT(func(v *Job) pulumi.StringPtrOutput { return v.ApiVersion }).(pulumi.StringPtrOutput) 299 } 300 301 // Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds 302 func (o JobOutput) Kind() pulumi.StringPtrOutput { 303 return o.ApplyT(func(v *Job) pulumi.StringPtrOutput { return v.Kind }).(pulumi.StringPtrOutput) 304 } 305 306 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 307 func (o JobOutput) Metadata() metav1.ObjectMetaPtrOutput { 308 return o.ApplyT(func(v *Job) metav1.ObjectMetaPtrOutput { return v.Metadata }).(metav1.ObjectMetaPtrOutput) 309 } 310 311 // Specification of the desired behavior of a job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 312 func (o JobOutput) Spec() JobSpecPtrOutput { 313 return o.ApplyT(func(v *Job) JobSpecPtrOutput { return v.Spec }).(JobSpecPtrOutput) 314 } 315 316 // Current status of a job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 317 func (o JobOutput) Status() JobStatusPtrOutput { 318 return o.ApplyT(func(v *Job) JobStatusPtrOutput { return v.Status }).(JobStatusPtrOutput) 319 } 320 321 type JobArrayOutput struct{ *pulumi.OutputState } 322 323 func (JobArrayOutput) ElementType() reflect.Type { 324 return reflect.TypeOf((*[]*Job)(nil)).Elem() 325 } 326 327 func (o JobArrayOutput) ToJobArrayOutput() JobArrayOutput { 328 return o 329 } 330 331 func (o JobArrayOutput) ToJobArrayOutputWithContext(ctx context.Context) JobArrayOutput { 332 return o 333 } 334 335 func (o JobArrayOutput) Index(i pulumi.IntInput) JobOutput { 336 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Job { 337 return vs[0].([]*Job)[vs[1].(int)] 338 }).(JobOutput) 339 } 340 341 type JobMapOutput struct{ *pulumi.OutputState } 342 343 func (JobMapOutput) ElementType() reflect.Type { 344 return reflect.TypeOf((*map[string]*Job)(nil)).Elem() 345 } 346 347 func (o JobMapOutput) ToJobMapOutput() JobMapOutput { 348 return o 349 } 350 351 func (o JobMapOutput) ToJobMapOutputWithContext(ctx context.Context) JobMapOutput { 352 return o 353 } 354 355 func (o JobMapOutput) MapIndex(k pulumi.StringInput) JobOutput { 356 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Job { 357 return vs[0].(map[string]*Job)[vs[1].(string)] 358 }).(JobOutput) 359 } 360 361 func init() { 362 pulumi.RegisterInputType(reflect.TypeOf((*JobInput)(nil)).Elem(), &Job{}) 363 pulumi.RegisterInputType(reflect.TypeOf((*JobArrayInput)(nil)).Elem(), JobArray{}) 364 pulumi.RegisterInputType(reflect.TypeOf((*JobMapInput)(nil)).Elem(), JobMap{}) 365 pulumi.RegisterOutputType(JobOutput{}) 366 pulumi.RegisterOutputType(JobArrayOutput{}) 367 pulumi.RegisterOutputType(JobMapOutput{}) 368 }