rs-api-tools 0.0.4 → 0.0.5
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/bin/rs-create-org-repositories +1 -1
- data/bin/rs-create-repository +126 -0
- metadata +5 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5a6a5dfe281f32afa20501f99d0047fcce12cf6d
         | 
| 4 | 
            +
              data.tar.gz: aa48cd124c4b8962347d8879280ce51d69f1fc62
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 523702bffa6d20055dc2b5cdaec5cf93adce261738afb95b47fa3b9e70e471cff35daa65aa183febf810bebe9cc21e83f523d5e7752fd6ae17305f0b6c75d30f
         | 
| 7 | 
            +
              data.tar.gz: e3506e740e229c9cb8e5bef780285ac89b359ce59a2ece0403846a96af4d687b209bbf5b7b6dad3cbf6d788124d41550f3a8fa31ccc4dde7aeadee34856a1b43
         | 
| @@ -6,7 +6,7 @@ require 'rubygems' | |
| 6 6 | 
             
            require 'getoptlong'
         | 
| 7 7 |  | 
| 8 8 | 
             
            def usage
         | 
| 9 | 
            -
              puts "usage: rs-create-org-repositories [--org <github_org>] [[--dry]] [[--master]] [[-- | 
| 9 | 
            +
              puts "usage: rs-create-org-repositories [--org <github_org>] [[--dry]] [[--master]] [[--noninteractive]] [[--verbose]] [[--help]] [[--user]] [[--password]]"
         | 
| 10 10 | 
             
              puts ''
         | 
| 11 11 | 
             
              puts "See rs-create-org-repositories --help for more information on usage."
         | 
| 12 12 | 
             
            end
         | 
| @@ -0,0 +1,126 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # rs-create-repository [--source <source>] [[--ref <source_ref>]]
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'rubygems'
         | 
| 6 | 
            +
            require 'getoptlong'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            def usage
         | 
| 9 | 
            +
              puts "usage: rs-create-repository [--name <repos_name>] [--source <source>] [[--ref <source_ref>]] [[--help]]"
         | 
| 10 | 
            +
              puts ''
         | 
| 11 | 
            +
              puts "See rs-create-org-repository --help for more information on usage."
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            def usage_exit
         | 
| 15 | 
            +
              usage; exit
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            def help_info
         | 
| 19 | 
            +
              puts("#{$0}")
         | 
| 20 | 
            +
              puts ''
         | 
| 21 | 
            +
              puts "Creates a RightScale Repository from a remote source repository."
         | 
| 22 | 
            +
              puts ''
         | 
| 23 | 
            +
              puts "examples:  rs-create-repository --name 'aws_developer_tools master' --source 'https://github.com/flaccid/aws_developer_tools.git' --ref master"
         | 
| 24 | 
            +
              puts "           rs-create-repository --name 'ruby 0.9.2' --source https://github.com/jtimberman/ruby-cookbook.git --ref '0.9.2'"
         | 
| 25 | 
            +
              puts ''  
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            name = false
         | 
| 29 | 
            +
            source = false
         | 
| 30 | 
            +
            ref = 'master'
         | 
| 31 | 
            +
            dry = false
         | 
| 32 | 
            +
            interactive = true
         | 
| 33 | 
            +
            json = false
         | 
| 34 | 
            +
            xml = false
         | 
| 35 | 
            +
            verbose = false
         | 
| 36 | 
            +
            help = false
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            opts = GetoptLong.new(
         | 
| 39 | 
            +
              [ '--name', '-N', GetoptLong::REQUIRED_ARGUMENT ],
         | 
| 40 | 
            +
              [ '--source', '-s', GetoptLong::REQUIRED_ARGUMENT ],
         | 
| 41 | 
            +
              [ '--ref', '-r', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 42 | 
            +
              [ '--dry', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 43 | 
            +
              [ '--master', '-m', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 44 | 
            +
              [ '--noninteractive', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 45 | 
            +
              [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 46 | 
            +
              [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 47 | 
            +
              [ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
         | 
| 48 | 
            +
              [ '--help', '-h', GetoptLong::NO_ARGUMENT ]
         | 
| 49 | 
            +
            )
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            opts.each do |opt, arg|
         | 
| 52 | 
            +
              case opt
         | 
| 53 | 
            +
              when '--name'
         | 
| 54 | 
            +
                name = arg
         | 
| 55 | 
            +
              when '--source'
         | 
| 56 | 
            +
                source = arg
         | 
| 57 | 
            +
              when '--ref'
         | 
| 58 | 
            +
                ref = arg
         | 
| 59 | 
            +
              when '--dry'
         | 
| 60 | 
            +
                dry = true
         | 
| 61 | 
            +
              when '--master'
         | 
| 62 | 
            +
                master = arg
         | 
| 63 | 
            +
              when '--noninteractive'
         | 
| 64 | 
            +
                interactive = false
         | 
| 65 | 
            +
                puts 'Warning: non-interactive mode.'
         | 
| 66 | 
            +
              when '--help'
         | 
| 67 | 
            +
                help = true
         | 
| 68 | 
            +
              when '--json'
         | 
| 69 | 
            +
                json = true
         | 
| 70 | 
            +
              when '--verbose'
         | 
| 71 | 
            +
                verbose = true
         | 
| 72 | 
            +
              when '--xml'
         | 
| 73 | 
            +
                xml = true
         | 
| 74 | 
            +
            	end
         | 
| 75 | 
            +
            end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            if help
         | 
| 78 | 
            +
              help_info
         | 
| 79 | 
            +
              exit
         | 
| 80 | 
            +
            end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            usage_exit if !(source)
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            def yesno
         | 
| 85 | 
            +
              begin
         | 
| 86 | 
            +
                system("stty raw -echo")
         | 
| 87 | 
            +
                str = STDIN.getc
         | 
| 88 | 
            +
              ensure
         | 
| 89 | 
            +
                system("stty -raw echo")
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
              if str.downcase == "y"
         | 
| 92 | 
            +
                return true
         | 
| 93 | 
            +
              elsif str.downcase == "n"
         | 
| 94 | 
            +
                return false
         | 
| 95 | 
            +
              else
         | 
| 96 | 
            +
                raise "Invalid response. Please enter y/n."
         | 
| 97 | 
            +
              end
         | 
| 98 | 
            +
            end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            #require 'octokit'
         | 
| 101 | 
            +
            require 'json'
         | 
| 102 | 
            +
            require 'yaml'
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            # log into RightScale first, no point continuing if this is not possible
         | 
| 105 | 
            +
            require 'right_api_client'
         | 
| 106 | 
            +
            rs_client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            # create profile of the repository to add
         | 
| 109 | 
            +
            # http://reference.rightscale.com/api1.5/resources/ResourceRepositories.html#create
         | 
| 110 | 
            +
            repository = Hash.new
         | 
| 111 | 
            +
            repository['source_type'] = 'git'     # only git supported so far
         | 
| 112 | 
            +
            repository['auto_import'] = true
         | 
| 113 | 
            +
            repository['source'] = source
         | 
| 114 | 
            +
                
         | 
| 115 | 
            +
            # not yet supported
         | 
| 116 | 
            +
            repository['credentials'] = Hash.new
         | 
| 117 | 
            +
            repository['credentials']['ssh_key'] = 'text:'
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            repository['name'] = "#{name}"
         | 
| 120 | 
            +
            repository['commit_reference'] = ref
         | 
| 121 | 
            +
            repository['description'] = ""
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            puts repository if verbose
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            puts "Creating RightScale repository, '#{repository['name']}'."
         | 
| 126 | 
            +
            rs_client.repositories.create({ :repository => repository })
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rs-api-tools
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Chris Fordham
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013-10- | 
| 11 | 
            +
            date: 2013-10-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: json
         | 
| @@ -85,6 +85,7 @@ executables: | |
| 85 85 | 
             
            - rs-terminate-all
         | 
| 86 86 | 
             
            - rs-describe-servers
         | 
| 87 87 | 
             
            - rs-update-server-array
         | 
| 88 | 
            +
            - rs-create-repository
         | 
| 88 89 | 
             
            - rs-fetch-executables
         | 
| 89 90 | 
             
            - rs-relaunch-deployment
         | 
| 90 91 | 
             
            - rs-run-all-boot-executables
         | 
| @@ -149,6 +150,7 @@ files: | |
| 149 150 | 
             
            - bin/rs-terminate-all
         | 
| 150 151 | 
             
            - bin/rs-describe-servers
         | 
| 151 152 | 
             
            - bin/rs-update-server-array
         | 
| 153 | 
            +
            - bin/rs-create-repository
         | 
| 152 154 | 
             
            - bin/rs-fetch-executables
         | 
| 153 155 | 
             
            - bin/rs-relaunch-deployment
         | 
| 154 156 | 
             
            - bin/rs-run-all-boot-executables
         | 
| @@ -214,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 214 216 | 
             
                  version: '0'
         | 
| 215 217 | 
             
            requirements: []
         | 
| 216 218 | 
             
            rubyforge_project: 
         | 
| 217 | 
            -
            rubygems_version: 2. | 
| 219 | 
            +
            rubygems_version: 2.1.9
         | 
| 218 220 | 
             
            signing_key: 
         | 
| 219 221 | 
             
            specification_version: 4
         | 
| 220 222 | 
             
            summary: rs-api-tools
         |