Skip to content

Commit 6f8aae4

Browse files
committed
Add DSL for all API Groups
1 parent dbb0bda commit 6f8aae4

File tree

44 files changed

+2044
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2044
-67
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ Swift client for talking to a [Kubernetes](http://kubernetes.io/) cluster via a
3838
- [x] Covers all Kubernetes API Groups in v1.19.8
3939
- [x] Automatic configuration discovery
4040
- [x] DSL style API
41-
- [x] Highest API version for the most common API Groups
42-
- [ ] Cover all API Groups/Versions
41+
- [x] For all API Groups/Versions
4342
- [x] Generic client support
4443
- [x] Swift-Logging support
4544
- [x] Loading resources from external sources
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - AdmissionRegistrationV1API
21+
22+
public protocol AdmissionRegistrationV1API {
23+
24+
var mutatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1.MutatingWebhookConfiguration> { get }
25+
26+
var validatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1.ValidatingWebhookConfiguration> { get }
27+
}
28+
29+
/// DSL for `admissionregistration.v1` API Group
30+
public extension KubernetesClient {
31+
32+
class AdmissionRegistrationV1: AdmissionRegistrationV1API {
33+
private var client: KubernetesClient
34+
35+
internal init(_ client: KubernetesClient) {
36+
self.client = client
37+
}
38+
39+
public var mutatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1.MutatingWebhookConfiguration> {
40+
client.clusterScoped(for: admissionregistration.v1.MutatingWebhookConfiguration.self)
41+
}
42+
43+
public var validatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1.ValidatingWebhookConfiguration> {
44+
client.clusterScoped(for: admissionregistration.v1.ValidatingWebhookConfiguration.self)
45+
}
46+
}
47+
48+
var admissionRegistrationV1: AdmissionRegistrationV1API {
49+
AdmissionRegistrationV1(self)
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - AdmissionRegistrationV1Beta1API
21+
22+
public protocol AdmissionRegistrationV1Beta1API {
23+
24+
var mutatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1beta1.ValidatingWebhookConfiguration> { get }
25+
26+
var validatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1beta1.MutatingWebhookConfiguration> { get }
27+
}
28+
29+
/// DSL for `admissionregistration.v1beta1` API Group
30+
public extension KubernetesClient {
31+
32+
class AdmissionRegistrationV1Beta1: AdmissionRegistrationV1Beta1API {
33+
private var client: KubernetesClient
34+
35+
internal init(_ client: KubernetesClient) {
36+
self.client = client
37+
}
38+
39+
public var mutatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1beta1.ValidatingWebhookConfiguration> {
40+
client.clusterScoped(for: admissionregistration.v1beta1.ValidatingWebhookConfiguration.self)
41+
}
42+
43+
public var validatingWebhookConfigurations: ClusterScopedGenericKubernetesClient<admissionregistration.v1beta1.MutatingWebhookConfiguration> {
44+
client.clusterScoped(for: admissionregistration.v1beta1.MutatingWebhookConfiguration.self)
45+
}
46+
}
47+
48+
var admissionRegistrationV1Beta1: AdmissionRegistrationV1Beta1API {
49+
AdmissionRegistrationV1Beta1(self)
50+
}
51+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - APIExtensionsV1API
21+
22+
public protocol APIExtensionsV1API {
23+
24+
var customResourceDefinitions: ClusterScopedGenericKubernetesClient<apiextensions.v1.CustomResourceDefinition> { get }
25+
}
26+
27+
/// DSL for `apiextensions.v1` API Group
28+
public extension KubernetesClient {
29+
30+
class APIExtensionsV1: APIExtensionsV1API {
31+
private var client: KubernetesClient
32+
33+
internal init(_ client: KubernetesClient) {
34+
self.client = client
35+
}
36+
37+
public var customResourceDefinitions: ClusterScopedGenericKubernetesClient<apiextensions.v1.CustomResourceDefinition> {
38+
client.clusterScoped(for: apiextensions.v1.CustomResourceDefinition.self)
39+
}
40+
}
41+
42+
var apiExtensionsV1: APIExtensionsV1API {
43+
APIExtensionsV1(self)
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - APIExtensionsV1Beta1API
21+
22+
public protocol APIExtensionsV1Beta1API {
23+
24+
var customResourceDefinitions: ClusterScopedGenericKubernetesClient<apiextensions.v1beta1.CustomResourceDefinition> { get }
25+
}
26+
27+
/// DSL for `APIExtensions.v1beta1` API Group
28+
public extension KubernetesClient {
29+
30+
class APIExtensionsV1Beta1: APIExtensionsV1Beta1API {
31+
private var client: KubernetesClient
32+
33+
internal init(_ client: KubernetesClient) {
34+
self.client = client
35+
}
36+
37+
public var customResourceDefinitions: ClusterScopedGenericKubernetesClient<apiextensions.v1beta1.CustomResourceDefinition> {
38+
client.clusterScoped(for: apiextensions.v1beta1.CustomResourceDefinition.self)
39+
}
40+
}
41+
42+
var apiExtensionsV1Beta1: APIExtensionsV1Beta1API {
43+
APIExtensionsV1Beta1(self)
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - APIRegistrationV1API
21+
22+
public protocol APIRegistrationV1API {
23+
24+
var apiServices: ClusterScopedGenericKubernetesClient<apiregistration.v1.APIService> { get }
25+
}
26+
27+
/// DSL for `apiregistrationV1` API Group
28+
public extension KubernetesClient {
29+
30+
class APIRegistrationV1: APIRegistrationV1API {
31+
private var client: KubernetesClient
32+
33+
internal init(_ client: KubernetesClient) {
34+
self.client = client
35+
}
36+
37+
public var apiServices: ClusterScopedGenericKubernetesClient<apiregistration.v1.APIService> {
38+
client.clusterScoped(for: apiregistration.v1.APIService.self)
39+
}
40+
}
41+
42+
var apiRegistrationV1: APIRegistrationV1API {
43+
APIRegistrationV1(self)
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - APIRegistrationV1Beta1API
21+
22+
public protocol APIRegistrationV1Beta1API {
23+
24+
var apiServices: ClusterScopedGenericKubernetesClient<apiregistration.v1beta1.APIService> { get }
25+
}
26+
27+
/// DSL for `apiregistrationV1Beta1` API Group
28+
public extension KubernetesClient {
29+
30+
class APIRegistrationV1Beta1: APIRegistrationV1Beta1API {
31+
private var client: KubernetesClient
32+
33+
internal init(_ client: KubernetesClient) {
34+
self.client = client
35+
}
36+
37+
public var apiServices: ClusterScopedGenericKubernetesClient<apiregistration.v1beta1.APIService> {
38+
client.clusterScoped(for: apiregistration.v1beta1.APIService.self)
39+
}
40+
}
41+
42+
var apiRegistrationV1Beta1: APIRegistrationV1Beta1API {
43+
APIRegistrationV1Beta1(self)
44+
}
45+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// Copyright 2020 Swiftkube Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import Foundation
18+
import SwiftkubeModel
19+
20+
// MARK: - AppsV1API
21+
22+
public protocol AppsV1API {
23+
24+
var statefulSets: NamespacedGenericKubernetesClient<apps.v1.StatefulSet> { get }
25+
26+
var replicaSets: NamespacedGenericKubernetesClient<apps.v1.ReplicaSet> { get }
27+
28+
var deployments: NamespacedGenericKubernetesClient<apps.v1.Deployment> { get }
29+
30+
var controllerRevisions: NamespacedGenericKubernetesClient<apps.v1.ControllerRevision> { get }
31+
32+
var daemonSets: NamespacedGenericKubernetesClient<apps.v1.DaemonSet> { get }
33+
}
34+
35+
/// DSL for `apps.v1` API Group
36+
public extension KubernetesClient {
37+
38+
class AppsV1: AppsV1API {
39+
private var client: KubernetesClient
40+
41+
internal init(_ client: KubernetesClient) {
42+
self.client = client
43+
}
44+
45+
public var statefulSets: NamespacedGenericKubernetesClient<apps.v1.StatefulSet> {
46+
client.namespaceScoped(for: apps.v1.StatefulSet.self)
47+
}
48+
49+
public var replicaSets: NamespacedGenericKubernetesClient<apps.v1.ReplicaSet> {
50+
client.namespaceScoped(for: apps.v1.ReplicaSet.self)
51+
}
52+
53+
public var deployments: NamespacedGenericKubernetesClient<apps.v1.Deployment> {
54+
client.namespaceScoped(for: apps.v1.Deployment.self)
55+
}
56+
57+
public var controllerRevisions: NamespacedGenericKubernetesClient<apps.v1.ControllerRevision> {
58+
client.namespaceScoped(for: apps.v1.ControllerRevision.self)
59+
}
60+
61+
public var daemonSets: NamespacedGenericKubernetesClient<apps.v1.DaemonSet> {
62+
client.namespaceScoped(for: apps.v1.DaemonSet.self)
63+
}
64+
}
65+
66+
var appsV1: AppsV1API {
67+
AppsV1(self)
68+
}
69+
}

0 commit comments

Comments
 (0)