コード例 #1
0
        public ImageStreamTag[] GetImageTagVersions(string name, string ocNamespace)
        {
            string           arguments = $"get is -o json {NamespaceArg(ocNamespace)} {name}";
            Result <JObject> result    = ProcessUtils.Run <JObject>("oc", arguments);

            if (result.IsSuccess)
            {
                return(ImageStreamParser.GetTags(result.Value));
            }
            else
            {
                if (result.ErrorMessage.Contains("NotFound"))
                {
                    return(Array.Empty <ImageStreamTag>());
                }
                else
                {
                    throw new FailedException($"Unable to retrieve image stream tags: {result.ErrorMessage}");
                }
            }
        }
コード例 #2
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}");
            }
        }
コード例 #3
0
        public S2iBuildConfig[] GetS2iBuildConfigs(string imageName)
        {
            Result <JObject> result = ProcessUtils.Run <JObject>("oc", $"get bc -o json");

            if (result.IsSuccess)
            {
                var buildConfigs = new List <S2iBuildConfig>();
                foreach (var item in result.Value["items"])
                {
                    var buildConfig = BuildConfigParser.ParseS2iBuildConfig(item as JObject);
                    if (buildConfig != null && buildConfig.ImageName == imageName)
                    {
                        buildConfigs.Add(buildConfig);
                    }
                }
                return(buildConfigs.ToArray());
            }
            else
            {
                throw new FailedException($"Cannot get build configurations: {result.ErrorMessage}");
            }
        }
コード例 #4
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}");
            }
        }