public static V1ClusterRole GenerateManagerRbac(IResourceTypeService resourceTypeService) { var entityRbacPolicyRules = resourceTypeService.GetResourceAttributes <EntityRbacAttribute>() .SelectMany(attribute => attribute.CreateRbacPolicies()); var genericRbacPolicyRules = resourceTypeService.GetResourceAttributes <GenericRbacAttribute>() .Select(attribute => attribute.CreateRbacPolicy()); return(new V1ClusterRole( null, $"{V1ClusterRole.KubeGroup}/{V1ClusterRole.KubeApiVersion}", V1ClusterRole.KubeKind, new V1ObjectMeta { Name = "operator-role" }, new List <V1PolicyRule>(Enumerable.Concat(entityRbacPolicyRules, genericRbacPolicyRules)))); }
public static IEnumerable <V1CustomResourceDefinition> GenerateCrds(IResourceTypeService resourceTypeService) { var resourceTypes = resourceTypeService.GetResourceTypesByAttribute <KubernetesEntityAttribute>(); return(resourceTypes .Where(type => !type.GetCustomAttributes <IgnoreEntityAttribute>().Any()) .Select(type => (type.CreateCrd(), type.GetCustomAttributes <StorageVersionAttribute>().Any())) .GroupBy(grp => grp.Item1.Metadata.Name) .Select( group => { if (group.Count(def => def.Item2) > 1) { throw new Exception("There are multiple stored versions on an entity."); } var crd = group.First().Item1; crd.Spec.Versions = group .SelectMany( c => c.Item1.Spec.Versions.Select( v => { v.Served = true; v.Storage = c.Item2; return v; })) .OrderByDescending(v => v.Name, KubernetesVersionComparer.Instance) .ToList(); // when only one version exists, or when no StorageVersion attributes are found // the first version in the list is the stored one. if (crd.Spec.Versions.Count == 1 || group.Count(def => def.Item2) == 0) { crd.Spec.Versions[0].Storage = true; } return crd; })); }
public ResourceTypesController(ScimServerConfiguration serverConfiguration, IResourceTypeService resourceTypeService) : base(serverConfiguration) { _ResourceTypeService = resourceTypeService; }
public Uninstall(IKubernetesClient client, IResourceTypeService resourceTypeService) { _client = client; _resourceTypeService = resourceTypeService; }
public ResourceTypeController(IResourceTypeService resourceTypeService) { _resourceTypeService = resourceTypeService; }
public ResourceTypeController(IResourceTypeService sermonTypeService) { _sermonTypeService = sermonTypeService; }
public RbacGenerator(EntitySerializer serializer, IResourceTypeService resourceTypeService) { _serializer = serializer; _resourceTypeService = resourceTypeService; }
public ResourceTypeController(IResourceTypeService typeService, IItemService itemService) { _typeService = typeService; _itemService = itemService; }