// SPDX-License-Identifier: Apache-2.0
import { V1ClusterRole, V1ObjectMeta } from '@kubernetes/client-node';
export class K8ClientClusterRole {
    name;
    rules;
    labels;
    constructor(name, rules, labels) {
        this.name = name;
        this.rules = rules;
        this.labels = labels;
    }
    toV1ClusterRole() {
        const v1ClusterRole = new V1ClusterRole();
        v1ClusterRole.apiVersion = 'rbac.authorization.k8s.io/v1';
        v1ClusterRole.kind = 'ClusterRole';
        const metadata = new V1ObjectMeta();
        metadata.name = this.name;
        if (this.labels) {
            metadata.labels = this.labels;
        }
        v1ClusterRole.metadata = metadata;
        v1ClusterRole.rules = this.rules.map((rule) => ({
            apiGroups: rule.apiGroups,
            resources: rule.resources,
            verbs: rule.verbs,
        }));
        return v1ClusterRole;
    }
}
//# sourceMappingURL=k8-client-cluster-role.js.map