Example #1
0
        protected void DescribeProjects(int page, CUIPackage package)
        {
            var oc       = (OpenShift)package;
            var pageSize = oc.ItemsPageSize["OPENSHIFT_PROJECTS"];
            var projects = oc.GetItems <Comgithubopenshiftapiprojectv1ProjectList>("PROJECTS");

            var count = projects.Items.Count;
            var pages = count / pageSize + 1;

            if (page > pages)
            {
                SayErrorLine("There are only {0} pages available.", pages);
                return;
            }
            else
            {
                int start = (page - 1) * oc.ItemsPageSize["OPENSHIFT_PROJECTS"];
                int end   = start + oc.ItemsPageSize["OPENSHIFT_PROJECTS"];
                if (end > count)
                {
                    end = count;
                }
                if (Controller.DebugEnabled)
                {
                    SayInfoLine("Count: {0}. Page: {1}. Start: {2}. End: {3}", projects.Items.Count, page, start, end);
                }
                SayInfoLine("Projects page {0} of {1}.", page, pages);
                for (int i = start; i < end; i++)
                {
                    var project = projects.Items[i];
                    oc.SayInfoLine("{0}. Name: {1}, Status: {2}, Requester: {3}, Labels: {4}.", i + 1, project.Metadata.Name, project.Status.Phase,
                                   project.Metadata.Annotations.First(a => a.Key.ToLower().Contains("requester")).Value,
                                   project.Metadata.Labels?.Select(kv => kv.Key + "=" + kv.Value).Aggregate((s1, s2) => s1 + " " + s2) ?? "{}");
                }
                oc.ItemsCurrentPage["OPENSHIFT_PROJECTS"] = page;
            }
        }
Example #2
0
        protected void DescribeBuilds(int page, CUIPackage package)
        {
            var oc       = (OpenShift)package;
            var pageSize = oc.ItemsPageSize["OPENSHIFT_BUILDS"];
            var builds   = oc.GetItems <Comgithubopenshiftapibuildv1BuildList>("BUILDS");
            var count    = builds.Items.Count;
            var pages    = count / pageSize + 1;

            if (page > pages)
            {
                SayErrorLine("There are only {0} pages available.", pages);
                return;
            }
            else
            {
                int start = (page - 1) * oc.ItemsPageSize["OPENSHIFT_BUILDS"];
                int end   = start + oc.ItemsPageSize["OPENSHIFT_BUILDS"];
                if (end > count)
                {
                    end = count;
                }
                if (Controller.DebugEnabled)
                {
                    SayInfoLine("Count: {0}, Page: {1}, Start: {2}, End: {3}", builds.Items.Count, page, start, end);
                }
                SayInfoLine("Builds page {0} of {1}.", page, pages);
                for (int i = start; i < end; i++)
                {
                    var build = builds.Items[i];
                    oc.SayInfoLine("{0}. Name: {1}, Namespace: {2}, Labels: {3}, Status: {4}.", i + 1, build.Metadata.Name, build.Metadata.NamespaceProperty,
                                   build.Metadata.Labels?.Select(kv => kv.Key + "=" + kv.Value).Aggregate((s1, s2) => s1 + " " + s2) ?? "{}",
                                   build.Status.Phase);
                }
                oc.ItemsCurrentPage["OPENSHIFT_BUILDS"] = page;
            }
        }
Example #3
0
 public void SetActivePackage(CUIPackage package)
 {
     this.PreviousPackage = this.ActivePackage;
     this.ActivePackage   = package;
 }