private static Option <V1ContainerStatus> GetContainerByName(string name, V1Pod pod) { string containerName = KubeUtils.SanitizeDNSValue(name); return(pod.Status?.ContainerStatuses .Where(status => string.Equals(status.Name, containerName, StringComparison.OrdinalIgnoreCase)) .Select(status => Option.Some(status)) .FirstOrDefault() ?? Option.None <V1ContainerStatus>()); }
public CrdWatchOperator( string iotHubHostname, string deviceId, string edgeHostname, string proxyImage, string proxyConfigPath, string proxyConfigVolumeName, string serviceAccountName, string k8sNamespace, string workloadApiVersion, Uri workloadUri, Uri managementUri, PortMapServiceType defaultMapServiceType, IKubernetes client, IModuleIdentityLifecycleManager moduleIdentityLifecycleManager) { this.iotHubHostname = Preconditions.CheckNonWhiteSpace(iotHubHostname, nameof(iotHubHostname)); this.deviceId = Preconditions.CheckNonWhiteSpace(deviceId, nameof(deviceId)); this.edgeHostname = Preconditions.CheckNonWhiteSpace(edgeHostname, nameof(edgeHostname)); this.proxyImage = Preconditions.CheckNonWhiteSpace(proxyImage, nameof(proxyImage)); this.proxyConfigPath = Preconditions.CheckNonWhiteSpace(proxyConfigPath, nameof(proxyConfigPath)); this.proxyConfigVolumeName = Preconditions.CheckNonWhiteSpace(proxyConfigVolumeName, nameof(proxyConfigVolumeName)); this.serviceAccountName = Preconditions.CheckNonWhiteSpace(serviceAccountName, nameof(serviceAccountName)); this.k8sNamespace = Preconditions.CheckNonWhiteSpace(k8sNamespace, nameof(k8sNamespace)); this.workloadApiVersion = Preconditions.CheckNonWhiteSpace(workloadApiVersion, nameof(workloadApiVersion)); this.workloadUri = Preconditions.CheckNotNull(workloadUri, nameof(workloadUri)); this.managementUri = Preconditions.CheckNotNull(managementUri, nameof(managementUri)); this.defaultMapServiceType = Preconditions.CheckNotNull(defaultMapServiceType, nameof(defaultMapServiceType)).ToString(); this.client = Preconditions.CheckNotNull(client, nameof(client)); this.podWatch = Option.None <Watcher <V1Pod> >(); this.resourceName = KubeUtils.SanitizeK8sValue(this.iotHubHostname) + Constants.K8sNameDivider + KubeUtils.SanitizeK8sValue(this.deviceId); this.deploymentSelector = Constants.K8sEdgeDeviceLabel + " = " + KubeUtils.SanitizeK8sValue(this.deviceId) + "," + Constants.K8sEdgeHubNameLabel + "=" + KubeUtils.SanitizeK8sValue(this.iotHubHostname); var deserializerTypesMap = new Dictionary <Type, IDictionary <string, Type> > { [typeof(IModule)] = new Dictionary <string, Type> { ["docker"] = typeof(CombinedDockerModule) } }; this.deploymentSerde = new TypeSpecificSerDe <EdgeDeploymentDefinition <TConfig> >(deserializerTypesMap, new CamelCasePropertyNamesContractResolver()); this.moduleIdentityLifecycleManager = moduleIdentityLifecycleManager; }
public static string PvcName(KubernetesModule module, Mount mount) { return(KubeUtils.SanitizeK8sValue($"{module.Name}-{mount.Source}")); }
public override string ToString() => KubeUtils.SanitizeK8sValue(this.Hostname) + Constants.K8sNameDivider + KubeUtils.SanitizeK8sValue(this.DeviceId);
public static string DeploymentName(this IModuleIdentity identity) => KubeUtils.SanitizeK8sValue(identity.ModuleId);