Skip to content

Commit

Permalink
Add NamespacedResource and ClusterScopedResource protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
iabudiab committed Nov 12, 2020
1 parent c60e74f commit fecef12
Show file tree
Hide file tree
Showing 84 changed files with 95 additions and 83 deletions.
12 changes: 12 additions & 0 deletions Sources/Model/KubernetesResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ public protocol ListableResource: KubernetesResource {
/// The associated type of a `KubernetesResourceList`.
associatedtype List: KubernetesResourceList
}

///
/// A marker protocol for all namespace-scoped API resources.
///
/// For example a `Pod` or an `Ingress` are `NamespacedResource`s.
public protocol NamespacedResource {}

///
/// A marker protocol for all cluster-scoped API resources.
///
/// For example a `Node` or a `ClusterRole` are ClusterScopedResource`s.
public protocol ClusterScopedResource {}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension admissionregistration.v1 {
///
/// MutatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and may change the object.
///
struct MutatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct MutatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension admissionregistration.v1 {
///
/// ValidatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and object without changing it.
///
struct ValidatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct ValidatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension admissionregistration.v1beta1 {
///
/// MutatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and may change the object. Deprecated in v1.16, planned for removal in v1.19. Use admissionregistration.k8s.io/v1 MutatingWebhookConfiguration instead.
///
struct MutatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct MutatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension admissionregistration.v1beta1 {
///
/// ValidatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and object without changing it. Deprecated in v1.16, planned for removal in v1.19. Use admissionregistration.k8s.io/v1 ValidatingWebhookConfiguration instead.
///
struct ValidatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct ValidatingWebhookConfiguration: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apiextensions.v1 {
///
/// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format <.spec.name>.<.spec.group>.
///
struct CustomResourceDefinition: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct CustomResourceDefinition: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apiextensions.v1beta1 {
///
/// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format <.spec.name>.<.spec.group>. Deprecated in v1.16, planned for removal in v1.19. Use apiextensions.k8s.io/v1 CustomResourceDefinition instead.
///
struct CustomResourceDefinition: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct CustomResourceDefinition: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apiregistration.v1 {
///
/// APIService represents a server for a particular GroupVersion. Name must be "version.group".
///
struct APIService: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct APIService: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apiregistration.v1beta1 {
///
/// APIService represents a server for a particular GroupVersion. Name must be "version.group".
///
struct APIService: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct APIService: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/apps/v1/ControllerRevision+apps.v1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apps.v1 {
///
/// ControllerRevision implements an immutable snapshot of state data. Clients are responsible for serializing and deserializing the objects that contain their internal state. Once a ControllerRevision has been successfully created, it can not be updated. The API Server will fail validation of all requests that attempt to mutate the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, it may be subject to name and representation changes in future releases, and clients should not depend on its stability. It is primarily for internal use by controllers.
///
struct ControllerRevision: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct ControllerRevision: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/apps/v1/DaemonSet+apps.v1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apps.v1 {
///
/// DaemonSet represents the configuration of a daemon set.
///
struct DaemonSet: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct DaemonSet: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/apps/v1/Deployment+apps.v1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apps.v1 {
///
/// Deployment enables declarative updates for Pods and ReplicaSets.
///
struct Deployment: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct Deployment: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/apps/v1/ReplicaSet+apps.v1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension apps.v1 {
///
/// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
///
struct ReplicaSet: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct ReplicaSet: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/apps/v1/StatefulSet+apps.v1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public extension apps.v1 {
/// - Storage: As many VolumeClaims as requested.
/// The StatefulSet guarantees that a given network identity will always map to the same storage identity.
///
struct StatefulSet: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct StatefulSet: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authentication.v1 {
///
/// TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver.
///
struct TokenReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct TokenReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authentication.v1beta1 {
///
/// TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver.
///
struct TokenReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct TokenReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1 {
///
/// LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.
///
struct LocalSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct LocalSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, NamespacedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1 {
///
/// SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means "in all namespaces". Self is a special case, because users should always be able to check whether they can perform an action
///
struct SelfSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct SelfSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1 {
///
/// SelfSubjectRulesReview enumerates the set of actions the current user can perform within a namespace. The returned list of actions may be incomplete depending on the server's authorization mode, and any errors experienced during the evaluation. SelfSubjectRulesReview should be used by UIs to show/hide actions, or to quickly let an end user reason about their permissions. It should NOT Be used by external systems to drive authorization decisions as this raises confused deputy, cache lifetime/revocation, and correctness concerns. SubjectAccessReview, and LocalAccessReview are the correct way to defer authorization decisions to the API server.
///
struct SelfSubjectRulesReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct SelfSubjectRulesReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1 {
///
/// SubjectAccessReview checks whether or not a user or group can perform an action.
///
struct SubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct SubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1beta1 {
///
/// LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.
///
struct LocalSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct LocalSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, NamespacedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1beta1 {
///
/// SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means "in all namespaces". Self is a special case, because users should always be able to check whether they can perform an action
///
struct SelfSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct SelfSubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1beta1 {
///
/// SelfSubjectRulesReview enumerates the set of actions the current user can perform within a namespace. The returned list of actions may be incomplete depending on the server's authorization mode, and any errors experienced during the evaluation. SelfSubjectRulesReview should be used by UIs to show/hide actions, or to quickly let an end user reason about their permissions. It should NOT Be used by external systems to drive authorization decisions as this raises confused deputy, cache lifetime/revocation, and correctness concerns. SubjectAccessReview, and LocalAccessReview are the correct way to defer authorization decisions to the API server.
///
struct SelfSubjectRulesReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct SelfSubjectRulesReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension authorization.v1beta1 {
///
/// SubjectAccessReview checks whether or not a user or group can perform an action.
///
struct SubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource {
struct SubjectAccessReview: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ClusterScopedResource {
///
/// 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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension autoscaling.v1 {
///
/// configuration of a horizontal pod autoscaler.
///
struct HorizontalPodAutoscaler: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct HorizontalPodAutoscaler: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension autoscaling.v2beta1 {
///
/// HorizontalPodAutoscaler is the configuration for a horizontal pod autoscaler, which automatically manages the replica count of any resource implementing the scale subresource based on the metrics specified.
///
struct HorizontalPodAutoscaler: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct HorizontalPodAutoscaler: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension autoscaling.v2beta2 {
///
/// HorizontalPodAutoscaler is the configuration for a horizontal pod autoscaler, which automatically manages the replica count of any resource implementing the scale subresource based on the metrics specified.
///
struct HorizontalPodAutoscaler: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct HorizontalPodAutoscaler: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/batch/v1/Job+batch.v1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension batch.v1 {
///
/// Job represents the configuration of a single job.
///
struct Job: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct Job: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/batch/v1beta1/CronJob+batch.v1beta1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension batch.v1beta1 {
///
/// CronJob represents the configuration of a single cron job.
///
struct CronJob: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct CronJob: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/batch/v2alpha1/CronJob+batch.v2alpha1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension batch.v2alpha1 {
///
/// CronJob represents the configuration of a single cron job.
///
struct CronJob: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct CronJob: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, NamespacedResource {
///
/// ListableResource.List associated type
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension certificates.v1beta1 {
///
/// Describes a certificate signing request
///
struct CertificateSigningRequest: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource {
struct CertificateSigningRequest: KubernetesResource, KubernetesAPIResource, MetadataHavingResource, ListableResource, ClusterScopedResource {
///
/// ListableResource.List associated type
///
Expand Down
Loading

0 comments on commit fecef12

Please sign in to comment.