public async Task TestGetServiceAsync_GetsOutputFromCommand() { var expectedResult = new GkeService(); SetupGetJsonOutput(expectedResult); GkeService result = await _objectUnderTest.GetServiceAsync(DefaultServiceName); Assert.AreEqual(expectedResult, result); }
private async Task <Result> DeleteExistingServiceAsync(Options options) { GkeService existingService = await options.KubectlContext.GetServiceAsync(options.DeploymentName); if (existingService == null || await DeleteServiceAsync(existingService.Metadata.Name, options)) { return(Result.SuccessResult); } else { return(Result.FailedResult); } }
private async Task <Result> ExposeOrUpdateServiceAsync(Options options) { GkeService existingService = await options.KubectlContext.GetServiceAsync(options.DeploymentName); if (existingService == null) { return(await ExposeNewServiceAsync(options.DeploymentName, options)); } else { return(await UpdateExistingServiceAsync(existingService, options)); } }
private async Task <Result> UpdateExistingServiceAsync(GkeService existingService, Options options) { string requestedType = options.ExposePublicService ? GkeServiceSpec.LoadBalancerType : GkeServiceSpec.ClusterIpType; string existingServiceName = existingService.Metadata.Name; if (existingService.Spec.Type == requestedType) { return(await GetExposedServiceResultAsync(existingServiceName, options)); } else { if (await DeleteServiceAsync(existingServiceName, options)) { return(await ExposeNewServiceAsync(existingServiceName, options)); } else { return(Result.FailedResult); } } }
/// <summary> /// Gets the public IP address of a service. /// </summary> /// <param name="name">The name of the service to get the public IP address for.</param> /// <returns>The public IP address of the service.</returns> public async Task <string> GetPublicServiceIpAsync(string name) { GkeService service = await GetServiceAsync(name); return(service?.Status?.LoadBalancer?.Ingress?.Select(i => i?.Ip).FirstOrDefault(ip => ip != null)); }
/// <summary> /// Gets the cluster IP address of a service. /// </summary> /// <param name="name">The name of the service to get the cluster IP address of.</param> /// <returns>The cluster IP address of the service.</returns> public async Task <string> GetServiceClusterIpAsync(string name) { GkeService service = await GetServiceAsync(name); return(service?.Spec?.ClusterIp); }