ruby-kubernetes-controller 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Documentation/DOCUMENTATION.md +170 -6
- data/README.md +1 -1
- data/lib/ruby-kubernetes-controller/jobs.rb +181 -0
- data/lib/ruby-kubernetes-controller/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: cd4083fe77c81bb27435d6cb900f0e51992c62ca4a9c6732ff6009b1522d9f72
         | 
| 4 | 
            +
              data.tar.gz: 356c882b4a2b5bb50c73eea1e8e476af8989b750c90342452175392e85a7a530
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 11c56bc7bb24e83453fa6195b6b2d926815efef5d7378c3356be6884d7fd3686c558888ea5720ffd73f02d9e812ebcf4c9dccf8670de22df86ef030383a267b0
         | 
| 7 | 
            +
              data.tar.gz: c1069042e9387925778da31068d294449f3f75a49c608c027e7488a020a8d5a67f843ad989023ea56166588d4dc5aae064c0d458816aae2535b82fd834013e2c
         | 
| @@ -828,8 +828,8 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr | |
| 828 828 | 
             
                puts yaml_client.create_new_deployment(namespace, yaml_file_path) # Returns JSON
         | 
| 829 829 | 
             
            ```
         | 
| 830 830 |  | 
| 831 | 
            -
            #### Get  | 
| 832 | 
            -
            * List all  | 
| 831 | 
            +
            #### Get Deployments
         | 
| 832 | 
            +
            * List all Deployments
         | 
| 833 833 | 
             
            ```ruby
         | 
| 834 834 | 
             
                require 'ruby-kubernetes-controller'
         | 
| 835 835 |  | 
| @@ -839,11 +839,11 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr | |
| 839 839 |  | 
| 840 840 | 
             
                client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl)
         | 
| 841 841 |  | 
| 842 | 
            -
                puts client. | 
| 842 | 
            +
                puts client.get_all_deployments # Returns JSON
         | 
| 843 843 | 
             
            ```
         | 
| 844 844 |  | 
| 845 | 
            -
            #### Get Namespaced  | 
| 846 | 
            -
            * List all existing  | 
| 845 | 
            +
            #### Get Namespaced Deployments
         | 
| 846 | 
            +
            * List all existing Deployments in Namespace
         | 
| 847 847 | 
             
            ```ruby
         | 
| 848 848 | 
             
                require 'ruby-kubernetes-controller'
         | 
| 849 849 |  | 
| @@ -855,7 +855,7 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr | |
| 855 855 |  | 
| 856 856 | 
             
                namespace = "default"
         | 
| 857 857 |  | 
| 858 | 
            -
                puts client. | 
| 858 | 
            +
                puts client.get_all_namespaced_deployments(namespace) # Returns JSON
         | 
| 859 859 | 
             
            ```
         | 
| 860 860 |  | 
| 861 861 | 
             
            #### Get Single Namespaced Deployment
         | 
| @@ -1603,4 +1603,168 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr | |
| 1603 1603 | 
             
                puts yaml_client.delete_persistentvolumeclaim(namespace, persistentvolumeclaim_name, yaml_file_path) # Returns JSON
         | 
| 1604 1604 | 
             
            ```
         | 
| 1605 1605 |  | 
| 1606 | 
            +
             | 
| 1607 | 
            +
            #### Create Job
         | 
| 1608 | 
            +
            * Create new Job
         | 
| 1609 | 
            +
            ```ruby
         | 
| 1610 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1611 | 
            +
                
         | 
| 1612 | 
            +
                endpoint = "localhost"
         | 
| 1613 | 
            +
                bearer_token = "token"
         | 
| 1614 | 
            +
                ssl = false
         | 
| 1615 | 
            +
                
         | 
| 1616 | 
            +
                # With JSON
         | 
| 1617 | 
            +
                json_client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl, yaml = false)
         | 
| 1618 | 
            +
                namespace = "default"
         | 
| 1619 | 
            +
                json_config = 
         | 
| 1620 | 
            +
                '{
         | 
| 1621 | 
            +
                    "kind": "Job",
         | 
| 1622 | 
            +
                    "apiVersion": "extensions/v1beta1",
         | 
| 1623 | 
            +
                     ... 
         | 
| 1624 | 
            +
                 }'   
         | 
| 1625 | 
            +
                
         | 
| 1626 | 
            +
                puts json_client.create_new_job(namespace, json_config) # Returns JSON
         | 
| 1627 | 
            +
                
         | 
| 1628 | 
            +
                # With YAML
         | 
| 1629 | 
            +
                yaml_client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl, yaml = true)
         | 
| 1630 | 
            +
                namespace = "default"
         | 
| 1631 | 
            +
                yaml_file_path = 'path/to/file.yaml'
         | 
| 1632 | 
            +
                
         | 
| 1633 | 
            +
                puts yaml_client.create_new_job(namespace, yaml_file_path) # Returns JSON
         | 
| 1634 | 
            +
            ```
         | 
| 1635 | 
            +
             | 
| 1636 | 
            +
            #### Get Jobs
         | 
| 1637 | 
            +
            * List all Jobs
         | 
| 1638 | 
            +
            ```ruby
         | 
| 1639 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1640 | 
            +
                
         | 
| 1641 | 
            +
                endpoint = "localhost"
         | 
| 1642 | 
            +
                bearer_token = "token"
         | 
| 1643 | 
            +
                ssl = false
         | 
| 1644 | 
            +
                
         | 
| 1645 | 
            +
                client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl)
         | 
| 1646 | 
            +
                
         | 
| 1647 | 
            +
                puts client.get_all_jobs # Returns JSON
         | 
| 1648 | 
            +
            ```
         | 
| 1649 | 
            +
             | 
| 1650 | 
            +
            #### Get Namespaced Jobs
         | 
| 1651 | 
            +
            * List all existing Jobs in Namespace
         | 
| 1652 | 
            +
            ```ruby
         | 
| 1653 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1654 | 
            +
                
         | 
| 1655 | 
            +
                endpoint = "localhost"
         | 
| 1656 | 
            +
                bearer_token = "token"
         | 
| 1657 | 
            +
                ssl = false
         | 
| 1658 | 
            +
                
         | 
| 1659 | 
            +
                client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl)
         | 
| 1660 | 
            +
                
         | 
| 1661 | 
            +
                namespace = "default"
         | 
| 1662 | 
            +
                
         | 
| 1663 | 
            +
                puts client.get_all_namespaced_jobs(namespace) # Returns JSON
         | 
| 1664 | 
            +
            ```
         | 
| 1665 | 
            +
             | 
| 1666 | 
            +
            #### Get Single Namespaced Job
         | 
| 1667 | 
            +
            * Get details for single Job in Namespace
         | 
| 1668 | 
            +
            ```ruby
         | 
| 1669 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1670 | 
            +
                
         | 
| 1671 | 
            +
                endpoint = "localhost"
         | 
| 1672 | 
            +
                bearer_token = "token"
         | 
| 1673 | 
            +
                ssl = false
         | 
| 1674 | 
            +
                
         | 
| 1675 | 
            +
                client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl)
         | 
| 1676 | 
            +
                
         | 
| 1677 | 
            +
                namespace = "default"
         | 
| 1678 | 
            +
                job_name = "job"
         | 
| 1679 | 
            +
                
         | 
| 1680 | 
            +
                puts client.get_single_namespaced_job(namespace, job_name) # Returns JSON
         | 
| 1681 | 
            +
            ```
         | 
| 1682 | 
            +
             | 
| 1683 | 
            +
            #### Update Job
         | 
| 1684 | 
            +
            * Update existing Job in Namespace
         | 
| 1685 | 
            +
            ```ruby
         | 
| 1686 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1687 | 
            +
                
         | 
| 1688 | 
            +
                endpoint = "localhost"
         | 
| 1689 | 
            +
                bearer_token = "token"
         | 
| 1690 | 
            +
                ssl = false
         | 
| 1691 | 
            +
                
         | 
| 1692 | 
            +
                # With JSON
         | 
| 1693 | 
            +
                json_client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl, yaml = false)
         | 
| 1694 | 
            +
                namespace = "default"
         | 
| 1695 | 
            +
                job_name = "job"
         | 
| 1696 | 
            +
                json_update = 
         | 
| 1697 | 
            +
                '{
         | 
| 1698 | 
            +
                    "kind": "Job",
         | 
| 1699 | 
            +
                    "apiVersion": "extensions/v1beta1",
         | 
| 1700 | 
            +
                     ... 
         | 
| 1701 | 
            +
                 }'    
         | 
| 1702 | 
            +
                
         | 
| 1703 | 
            +
                puts json_client.update_namespaced_job(namespace, job_name, json_update) # Returns JSON
         | 
| 1704 | 
            +
                
         | 
| 1705 | 
            +
                # With YAML
         | 
| 1706 | 
            +
                yaml_client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl, yaml = true)
         | 
| 1707 | 
            +
                namespace = "default"
         | 
| 1708 | 
            +
                job_name = "job"
         | 
| 1709 | 
            +
                yaml_file_path = 'path/to/file.yaml'
         | 
| 1710 | 
            +
                
         | 
| 1711 | 
            +
                puts yaml_client.update_namespaced_job(namespace, job_name, yaml_file_path) # Returns JSON
         | 
| 1712 | 
            +
            ```
         | 
| 1713 | 
            +
             | 
| 1714 | 
            +
            #### Patch Job
         | 
| 1715 | 
            +
            * Patch existing Job
         | 
| 1716 | 
            +
            * Patch Format documentation available at: http://jsonpatch.com/
         | 
| 1717 | 
            +
            ```ruby
         | 
| 1718 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1719 | 
            +
                
         | 
| 1720 | 
            +
                endpoint = "localhost"
         | 
| 1721 | 
            +
                bearer_token = "token"
         | 
| 1722 | 
            +
                ssl = false
         | 
| 1723 | 
            +
                
         | 
| 1724 | 
            +
                client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl)
         | 
| 1725 | 
            +
                
         | 
| 1726 | 
            +
                namespace = "default"
         | 
| 1727 | 
            +
                job_name = "job"
         | 
| 1728 | 
            +
                patch = 
         | 
| 1729 | 
            +
                '[
         | 
| 1730 | 
            +
                  { "op": "replace", "path": "/baz", "value": "boo" },
         | 
| 1731 | 
            +
                  { "op": "add", "path": "/hello", "value": ["world"] },
         | 
| 1732 | 
            +
                  { "op": "remove", "path": "/foo" }
         | 
| 1733 | 
            +
                ]'    
         | 
| 1734 | 
            +
                
         | 
| 1735 | 
            +
                puts client.patch_job(namespace, job_name, patch) # Returns JSON
         | 
| 1736 | 
            +
            ```
         | 
| 1737 | 
            +
             | 
| 1738 | 
            +
            #### Delete Job
         | 
| 1739 | 
            +
            * Delete existing Job
         | 
| 1740 | 
            +
            * Delete options documentation available at: https://kubernetes.io/docs/reference/federation/v1/definitions/#_v1_deleteoptions
         | 
| 1741 | 
            +
            ```ruby
         | 
| 1742 | 
            +
                require 'ruby-kubernetes-controller'
         | 
| 1743 | 
            +
                
         | 
| 1744 | 
            +
                endpoint = "localhost"
         | 
| 1745 | 
            +
                bearer_token = "token"
         | 
| 1746 | 
            +
                ssl = false
         | 
| 1747 | 
            +
                
         | 
| 1748 | 
            +
                # With JSON
         | 
| 1749 | 
            +
                json_client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl, yaml = false)
         | 
| 1750 | 
            +
                namespace = "default"
         | 
| 1751 | 
            +
                job_name = "job"
         | 
| 1752 | 
            +
                json_options = 
         | 
| 1753 | 
            +
                '{
         | 
| 1754 | 
            +
                    "kind": "Job",
         | 
| 1755 | 
            +
                    "apiVersion": "extensions/v1beta1",
         | 
| 1756 | 
            +
                     ... 
         | 
| 1757 | 
            +
                 }'    
         | 
| 1758 | 
            +
                
         | 
| 1759 | 
            +
                puts json_client.delete_job(namespace, job_name, json_options) # Returns JSON
         | 
| 1760 | 
            +
                
         | 
| 1761 | 
            +
                # With YAML
         | 
| 1762 | 
            +
                yaml_client = ::RubyKubernetesController::Client.new(endpoint, bearer_token, ssl, yaml = true)
         | 
| 1763 | 
            +
                namespace = "default"
         | 
| 1764 | 
            +
                job_name = "job"
         | 
| 1765 | 
            +
                yaml_file_path = 'path/to/file.yaml'
         | 
| 1766 | 
            +
                
         | 
| 1767 | 
            +
                puts yaml_client.delete_job(namespace, job_name, yaml_file_path) # Returns JSON
         | 
| 1768 | 
            +
            ```
         | 
| 1769 | 
            +
             | 
| 1606 1770 | 
             
            [SERVICEACCOUNT]: https://github.com/IBM/ruby-kubernetes-controller/blob/master/Documentation/serviceaccount.yaml
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # Ruby Kubernetes Controller
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            [](https://circleci.com/gh/IBM/ruby-kubernetes-controller) [](https://badge.fury.io/rb/ruby-kubernetes-controller) [](https://rubygems.org/gems/ruby-kubernetes-controller) [](https://github.com/IBM/ruby-kubernetes-controller/blob/master/LICENSE.txt) 
         | 
| 4 4 |  | 
| 5 5 | 
             
            `Ruby Kubernetes Controller` is a Client-Side library which allows users to 
         | 
| 6 6 | 
             
            interact with core Kubernetes APIs natively from within their 
         | 
| @@ -0,0 +1,181 @@ | |
| 1 | 
            +
            require 'net/http'
         | 
| 2 | 
            +
            require 'uri'
         | 
| 3 | 
            +
            require 'openssl'
         | 
| 4 | 
            +
            require 'json'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require_relative 'generic'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module Jobs
         | 
| 9 | 
            +
                include Generic
         | 
| 10 | 
            +
                
         | 
| 11 | 
            +
                # Create new Job
         | 
| 12 | 
            +
                def create_new_job(namespace, config)
         | 
| 13 | 
            +
                    extension = "/apis/batch/v1/namespaces/#{namespace}/jobs"
         | 
| 14 | 
            +
                    
         | 
| 15 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 16 | 
            +
                    
         | 
| 17 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token,  "POST")
         | 
| 18 | 
            +
                    request.content_type = "application/json"
         | 
| 19 | 
            +
                    
         | 
| 20 | 
            +
                    if @yaml
         | 
| 21 | 
            +
                        request.body = yaml_file_to_json(config)
         | 
| 22 | 
            +
                        else
         | 
| 23 | 
            +
                        request.body = config
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                    
         | 
| 26 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 27 | 
            +
                    
         | 
| 28 | 
            +
                    begin
         | 
| 29 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 30 | 
            +
                            http.request(request)
         | 
| 31 | 
            +
                        end
         | 
| 32 | 
            +
                        return response.body
         | 
| 33 | 
            +
                        
         | 
| 34 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 35 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
                
         | 
| 39 | 
            +
                # Get all Jobs
         | 
| 40 | 
            +
                def get_all_jobs
         | 
| 41 | 
            +
                    extension = "/apis/batch/v1/jobs"
         | 
| 42 | 
            +
                    
         | 
| 43 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 44 | 
            +
                    
         | 
| 45 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token, "GET")
         | 
| 46 | 
            +
                    
         | 
| 47 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 48 | 
            +
                    
         | 
| 49 | 
            +
                    begin
         | 
| 50 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 51 | 
            +
                            http.request(request)
         | 
| 52 | 
            +
                        end
         | 
| 53 | 
            +
                        return response.body
         | 
| 54 | 
            +
                        
         | 
| 55 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 56 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 57 | 
            +
                    end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
                
         | 
| 60 | 
            +
                # Get all existing Jobs in Namespace
         | 
| 61 | 
            +
                def get_all_namespaced_jobs(namespace)
         | 
| 62 | 
            +
                    extension = "/apis/batch/v1/namespaces/#{namespace}/jobs"
         | 
| 63 | 
            +
                    
         | 
| 64 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 65 | 
            +
                    
         | 
| 66 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token, "GET")
         | 
| 67 | 
            +
                    
         | 
| 68 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 69 | 
            +
                    
         | 
| 70 | 
            +
                    begin
         | 
| 71 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 72 | 
            +
                            http.request(request)
         | 
| 73 | 
            +
                        end
         | 
| 74 | 
            +
                        return response.body
         | 
| 75 | 
            +
                        
         | 
| 76 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 77 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 78 | 
            +
                    end
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
                
         | 
| 81 | 
            +
                # Get single Job in Namespace
         | 
| 82 | 
            +
                def get_single_namespaced_job(namespace, job_name)
         | 
| 83 | 
            +
                    extension = "/apis/batch/v1/namespaces/#{namespace}/jobs/#{job_name}"
         | 
| 84 | 
            +
                    
         | 
| 85 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 86 | 
            +
                    
         | 
| 87 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token, "GET")
         | 
| 88 | 
            +
                    
         | 
| 89 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 90 | 
            +
                    
         | 
| 91 | 
            +
                    begin
         | 
| 92 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 93 | 
            +
                            http.request(request)
         | 
| 94 | 
            +
                        end
         | 
| 95 | 
            +
                        return response.body
         | 
| 96 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 97 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 98 | 
            +
                    end
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
                
         | 
| 101 | 
            +
                # Update existing Job in Namespace
         | 
| 102 | 
            +
                def update_namespaced_job(namespace, job_name, update)
         | 
| 103 | 
            +
                    extension = "/apis/batch/v1/namespaces/#{namespace}/jobs/#{job_name}"
         | 
| 104 | 
            +
                    
         | 
| 105 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 106 | 
            +
                    
         | 
| 107 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token, "PUT")
         | 
| 108 | 
            +
                    request.content_type = "application/json"
         | 
| 109 | 
            +
                    
         | 
| 110 | 
            +
                    if @yaml
         | 
| 111 | 
            +
                        request.body = yaml_file_to_json(update)
         | 
| 112 | 
            +
                        else
         | 
| 113 | 
            +
                        request.body = update
         | 
| 114 | 
            +
                    end
         | 
| 115 | 
            +
                    
         | 
| 116 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 117 | 
            +
                    
         | 
| 118 | 
            +
                    begin
         | 
| 119 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 120 | 
            +
                            http.request(request)
         | 
| 121 | 
            +
                        end
         | 
| 122 | 
            +
                        return response.body
         | 
| 123 | 
            +
                        
         | 
| 124 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 125 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 126 | 
            +
                    end
         | 
| 127 | 
            +
                    
         | 
| 128 | 
            +
                end
         | 
| 129 | 
            +
                
         | 
| 130 | 
            +
                # Patch existing Job in Namespace
         | 
| 131 | 
            +
                def patch_job(namespace, job_name, patch)
         | 
| 132 | 
            +
                    extension = "/apis/batch/v1/namespaces/#{namespace}/jobs/#{job_name}"
         | 
| 133 | 
            +
                    
         | 
| 134 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 135 | 
            +
                    
         | 
| 136 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token, "PATCH")
         | 
| 137 | 
            +
                    request.content_type = "application/json-patch+json"
         | 
| 138 | 
            +
                    
         | 
| 139 | 
            +
                    request.body = patch
         | 
| 140 | 
            +
                    
         | 
| 141 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 142 | 
            +
                    
         | 
| 143 | 
            +
                    begin
         | 
| 144 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 145 | 
            +
                            http.request(request)
         | 
| 146 | 
            +
                        end
         | 
| 147 | 
            +
                        return response.body
         | 
| 148 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 149 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 150 | 
            +
                    end
         | 
| 151 | 
            +
                end
         | 
| 152 | 
            +
                
         | 
| 153 | 
            +
                # Delete existing Job in Namespace
         | 
| 154 | 
            +
                def delete_job(namespace, job_name, options = '')
         | 
| 155 | 
            +
                    extension = "/apis/batch/v1/namespaces/#{namespace}/jobs/#{job_name}"
         | 
| 156 | 
            +
                    
         | 
| 157 | 
            +
                    uri = prepareURI(@endpoint, extension)
         | 
| 158 | 
            +
                    
         | 
| 159 | 
            +
                    request = prepareGenericRequest(uri, @bearer_token, "DELETE")
         | 
| 160 | 
            +
                    request.content_type = "application/json"
         | 
| 161 | 
            +
                    
         | 
| 162 | 
            +
                    if @yaml
         | 
| 163 | 
            +
                        request.body = yaml_file_to_json(options)
         | 
| 164 | 
            +
                        else
         | 
| 165 | 
            +
                        request.body = options
         | 
| 166 | 
            +
                    end
         | 
| 167 | 
            +
                    
         | 
| 168 | 
            +
                    req_options = prepareGenericRequestOptions(@ssl, uri)
         | 
| 169 | 
            +
                    
         | 
| 170 | 
            +
                    begin
         | 
| 171 | 
            +
                        response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
         | 
| 172 | 
            +
                            http.request(request)
         | 
| 173 | 
            +
                        end
         | 
| 174 | 
            +
                        return response.body
         | 
| 175 | 
            +
                        
         | 
| 176 | 
            +
                        rescue Errno::ECONNREFUSED
         | 
| 177 | 
            +
                        raise "Connection for host #{uri.hostname} refused"
         | 
| 178 | 
            +
                    end
         | 
| 179 | 
            +
                end
         | 
| 180 | 
            +
                
         | 
| 181 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ruby-kubernetes-controller
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1 | 
| 4 | 
            +
              version: 0.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Shivansh Vij (ShivanshVij)
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: exe
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2019- | 
| 13 | 
            +
            date: 2019-08-01 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: bundler
         | 
| @@ -105,6 +105,7 @@ files: | |
| 105 105 | 
             
            - lib/ruby-kubernetes-controller/endpoints.rb
         | 
| 106 106 | 
             
            - lib/ruby-kubernetes-controller/generic.rb
         | 
| 107 107 | 
             
            - lib/ruby-kubernetes-controller/ingresses.rb
         | 
| 108 | 
            +
            - lib/ruby-kubernetes-controller/jobs.rb
         | 
| 108 109 | 
             
            - lib/ruby-kubernetes-controller/namespaces.rb
         | 
| 109 110 | 
             
            - lib/ruby-kubernetes-controller/nodes.rb
         | 
| 110 111 | 
             
            - lib/ruby-kubernetes-controller/persistentvolumeclaims.rb
         |