OCIConfigExtension.groovy
01 /*
02  * SPDX-License-Identifier: Apache-2.0
03  *
04  * Copyright 2019-2022 Andres Almiray.
05  *
06  * Licensed under the Apache License, Version 2.0 (the "License");
07  * you may not use this file except in compliance with the License.
08  * You may obtain a copy of the License at
09  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 package org.kordamp.gradle.plugin.oci
19 
20 import groovy.transform.CompileStatic
21 import org.gradle.api.Project
22 import org.gradle.api.file.RegularFileProperty
23 import org.gradle.api.provider.Property
24 import org.gradle.api.tasks.Input
25 import org.gradle.api.tasks.Optional
26 
27 /**
28  @author Andres Almiray
29  @since 0.1.0
30  */
31 @CompileStatic
32 class OCIConfigExtension {
33     final Property<String> userId
34     final Property<String> tenantId
35     final Property<String> fingerprint
36     final Property<String> region
37     final RegularFileProperty keyfile
38     final Property<String> passphrase
39 
40     OCIConfigExtension(Project project) {
41         userId = project.objects.property(String)
42         tenantId = project.objects.property(String)
43         fingerprint = project.objects.property(String)
44         region = project.objects.property(String)
45         keyfile = project.objects.fileProperty()
46         passphrase = project.objects.property(String)
47     }
48 
49     @Input
50     @Optional
51     Property<String> getUserId() {
52         this.@userId
53     }
54 
55     @Input
56     @Optional
57     Property<String> getTenantId() {
58         this.@tenantId
59     }
60 
61     @Input
62     @Optional
63     Property<String> getFingerprint() {
64         this.@fingerprint
65     }
66 
67     @Input
68     @Optional
69     Property<String> getRegion() {
70         this.@region
71     }
72 
73     @Input
74     @Optional
75     RegularFileProperty getKeyfile() {
76         this.@keyfile
77     }
78 
79     @Input
80     @Optional
81     Property<String> getPassphrase() {
82         this.@passphrase
83     }
84 
85     boolean isEmpty() {
86         !userId.present &&
87             !tenantId.present &&
88             !fingerprint.present &&
89             !region.present &&
90             !keyfile.present
91     }
92 }