Skip to content

Commit

Permalink
[api] support and document collectbuildenv command
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Nov 11, 2014
1 parent 0ab0db3 commit 844c1a5
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/api/api/api.txt
Expand Up @@ -640,6 +640,21 @@ Parameters:
XmlResult: status


POST /source/<project>/<package>?cmd=collectbuildenv

Creates _buildenv files based on origin package builds. This can be used
to re-use exact older build enviroment even when further new binary packages
got added. For example to re-build an old maintenance update in the same way.

Parameters:

oproject: Origin project to copy from (required)
opackage: Origin package to copy from (required)
comment: Optional comment by the user

XmlResult: status


POST /source/<project>/<package>?cmd=importchannel

Import a kiwi channel file for OBS. Project names will be set
Expand Down
14 changes: 13 additions & 1 deletion src/api/app/controllers/source_controller.rb
Expand Up @@ -341,7 +341,7 @@ def package_command
# valid post commands
valid_commands=%w(diff branch servicediff linkdiff showlinked copy remove_flag set_flag rebuild undelete
wipe runservice commit commitfilelist createSpecFileTemplate deleteuploadrev linktobranch
updatepatchinfo getprojectservices unlock release importchannel)
updatepatchinfo getprojectservices unlock release importchannel collectbuildenv)

@command = params[:cmd]
raise IllegalRequest.new 'invalid_command' unless valid_commands.include?(@command)
Expand Down Expand Up @@ -1344,6 +1344,18 @@ def package_command_showlinked
render :text => xml, :content_type => 'text/xml'
end

# POST /source/<project>/<package>?cmd=collectbuildenv
def package_command_collectbuildenv
required_parameters :oproject, :opackage

Package.get_by_project_and_name(@target_project_name, @target_package_name)

path = request.path
path << build_query_from_hash(params, [:cmd, :user, :comment, :orev, :oproject, :opackage])
pass_to_backend path

end

# POST /source/<project>/<package>?cmd=undelete
def package_command_undelete

Expand Down
49 changes: 49 additions & 0 deletions src/api/test/functional/source_controller_test.rb
Expand Up @@ -2287,6 +2287,55 @@ def test_copy_package
assert_response :success
end

def test_collectbuildenv
login_Iggy
post '/source/home:Iggy/TestPack?cmd=branch&target_project=home:Iggy&target_package=TestPackBranch', nil
assert_response :success
get '/source/home:Iggy/TestPackBranch/_link'
assert_response :success

post '/source/home:Iggy/TestPackBranch?cmd=collectbuildenv'
assert_response 400
assert_xml_tag :tag => 'status', :attributes => { :code => "missing_parameter" }

post '/source/home:Iggy/TestPackBranch?cmd=collectbuildenv&oproject=home:Iggy&opackage=TestPack&comment=my+collectbuildenv', nil
assert_response :success

get '/source/home:Iggy/TestPackBranch/_history'
assert_response :success
assert_xml_tag :tag => 'comment', :content => "my collectbuildenv"

# global fallback _buildenv, contains always an error
get '/source/home:Iggy/TestPackBranch/_buildenv'
assert_response :success
assert_xml_tag :tag => 'error', :content => "no buildenv for this repo/arch"

# specialized buildenv, does not exist in source
get '/source/home:Iggy/TestPackBranch/_buildenv.10.2.i586'
assert_response :success
assert_xml_tag :tag => 'error', :content => "_buildenv missing in home:Iggy/10.2"
get '/source/home:Iggy/TestPackBranch/_buildenv.10.2.x86_64'
assert_response :success
assert_xml_tag :tag => 'error', :content => "_buildenv missing in home:Iggy/10.2"

# from BaseDistro project, we build against
post '/source/home:Iggy/TestPackBranch?cmd=collectbuildenv&oproject=BaseDistro&opackage=pack1&comment=my+collectbuildenv', nil
assert_response :success
# global fallback _buildenv, contains always an error
get '/source/home:Iggy/TestPackBranch/_buildenv'
assert_response :success
assert_xml_tag :tag => 'error', :content => "no buildenv for this repo/arch"

# specialized buildenv, contains the right repo name
get '/source/home:Iggy/TestPackBranch/_buildenv.10.2.i586'
assert_response :success
assert_xml_tag :tag => 'error', :content => "_buildenv missing in BaseDistro/BaseDistro_repo"

#cleanup
delete '/source/home:Iggy/TestPackBranch'
assert_response :success
end

def test_copy_project
# NOTE: copy tests for release projects are part of maintenance tests
login_fred
Expand Down

0 comments on commit 844c1a5

Please sign in to comment.