Ejemplo n.º 1
0
        public Pod GetPod(string podName, bool mustExist)
        {
            if (string.IsNullOrEmpty(podName))
            {
                throw new ArgumentException(nameof(podName));
            }
            Result <JObject> result = ProcessUtils.Run <JObject>("oc", $"get pod {podName} -o json");

            if (result.IsSuccess)
            {
                return(PodParser.ParsePod(result.Value));
            }
            else
            {
                if (!mustExist && result.ErrorMessage.Contains("NotFound"))
                {
                    return(null);
                }
                throw new FailedException($"Cannot get pod information: {result.ErrorMessage}");
            }
        }
Ejemplo n.º 2
0
        public Pod[] GetPods(string deploymentConfigName, string version)
        {
            Result <JObject> result = ProcessUtils.Run <JObject>("oc", $"get pods -l deploymentconfig={deploymentConfigName} -o json");

            if (result.IsSuccess)
            {
                var pods = new List <Pod>();
                foreach (var item in result.Value["items"])
                {
                    var pod = PodParser.ParsePod(item as JObject);
                    if (version == null || pod.DeploymentConfigLatestVersion == version) // TODO: version == null?
                    {
                        pods.Add(pod);
                    }
                }
                return(pods.ToArray());
            }
            else
            {
                throw new FailedException($"Cannot get pod information: {result.ErrorMessage}");
            }
        }