From 07268e48e95d48df63dfb7481eb060ee8b811f3f Mon Sep 17 00:00:00 2001
From: mprahl <mprahl@redhat.com>
Date: Oct 18 2017 13:54:08 +0000
Subject: Add support for module commands


Signed-off-by: mprahl <mprahl@redhat.com>

---

diff --git a/conf/bash-completion/fedpkg.bash b/conf/bash-completion/fedpkg.bash
index ae00f39..57edb5c 100644
--- a/conf/bash-completion/fedpkg.bash
+++ b/conf/bash-completion/fedpkg.bash
@@ -36,9 +36,10 @@ _fedpkg()
     local options_value="--dist --release --user --path"
     local commands="build chain-build ci clean clog clone co commit compile \
     container-build diff gimmespec giturl help gitbuildhash import install lint \
-    local mockbuild mock-config new new-sources patch prep pull push retire \
-    scratch-build sources srpm switch-branch tag unused-patches update upload \
-    verify-files verrel"
+    local mockbuild mock-config module-build module-build-cancel \
+    module-build-local module-build-info module-build-watch module-overview \
+    new new-sources patch prep pull push retire scratch-build sources srpm \
+    switch-branch tag unused-patches update upload verify-files verrel"
 
     # parse main options and get command
 
@@ -162,6 +163,18 @@ _fedpkg()
             options="--md5 --no-clean --no-cleanup-after --no-clean-all"
             options_mroot="--root --mock-config"
             ;;
+        module-build)
+            options="--watch"
+            options_string="--optional"
+            ;;
+        module-build-local)
+            options="--skip-tests"
+            options_string="--add-local-build"
+            ;;
+        module-overview)
+            options="--unfinished"
+            options_string="--limit"
+            ;;
         patch)
             options="--rediff"
             options_string="--suffix"
diff --git a/conf/etc/rpkg/fedpkg-stage.conf b/conf/etc/rpkg/fedpkg-stage.conf
index f04c342..e52e97a 100644
--- a/conf/etc/rpkg/fedpkg-stage.conf
+++ b/conf/etc/rpkg/fedpkg-stage.conf
@@ -21,3 +21,11 @@ kerberos_realms = STG.FEDORAPROJECT.ORG
 # Refer to fedpkg.conf
 url = https://bodhi.stg.fedoraproject.org/
 staging = True
+
+[fedpkg-stage.mbs]
+auth_method = oidc
+api_url = https://mbs.stg.fedoraproject.org/module-build-service/1/
+oidc_id_provider = https://id.stg.fedoraproject.org/openidc/
+oidc_client_id = mbs-authorizer
+oidc_client_secret = notsecret
+oidc_scopes = openid,https://id.fedoraproject.org/scope/groups,https://mbs.fedoraproject.org/oidc/submit-build
diff --git a/conf/etc/rpkg/fedpkg.conf b/conf/etc/rpkg/fedpkg.conf
index 966739b..78a8766 100644
--- a/conf/etc/rpkg/fedpkg.conf
+++ b/conf/etc/rpkg/fedpkg.conf
@@ -26,3 +26,11 @@ url = https://bodhi.fedoraproject.org/
 # different instance. Instead, --staging is available to switch to the stage
 # bodhi, and production is used without providing --staging.
 staging = False
+
+[fedpkg.mbs]
+auth_method = oidc
+api_url = https://mbs.fedoraproject.org/module-build-service/1/
+oidc_id_provider = https://id.fedoraproject.org/openidc/
+oidc_client_id = mbs-authorizer
+oidc_client_secret = notsecret
+oidc_scopes = openid,https://id.fedoraproject.org/scope/groups,https://mbs.fedoraproject.org/oidc/submit-build
diff --git a/conf/zsh-completion/_fedpkg b/conf/zsh-completion/_fedpkg
index 808a443..d16d6c1 100644
--- a/conf/zsh-completion/_fedpkg
+++ b/conf/zsh-completion/_fedpkg
@@ -210,6 +210,55 @@ _fedpkg-mock-config () {
     '--arch[override local arch]:arch:_fedpkg_arches'
 }
 
+(( $+functions[_fedpkg-module-build] )) ||
+_fedpkg-module-build () {
+  _arguments -C \
+    '(-h --help)'{-h,--help}'[show help message and exit]' \
+    '(-w --watch)'{-w,--watch}'[Watch the module build]' \
+    '--optional[MBS optional arguments in the form of "key=value"]:optional' \
+    ':scm_url' \
+    ':branch'
+}
+
+(( $+functions[_fedpkg-module-build-cancel] )) ||
+_fedpkg-module-build-cancel () {
+  _arguments -C \
+    '(-h --help)'{-h,--help}'[show help message and exit]' \
+    ':build_id'
+}
+
+(( $+functions[_fedpkg-module-build-info] )) ||
+_fedpkg-module-build-info () {
+  _arguments -C \
+    '(-h --help)'{-h,--help}'[show help message and exit]' \
+    ':build_id'
+}
+
+(( $+functions[_fedpkg-module-build-local] )) ||
+_fedpkg-module-build-local () {
+  _arguments -C \
+    '(-h --help)'{-h,--help}'[show help message and exit]' \
+    '--skip-tests[Adds a macro for skipping the check section]' \
+    '--add-local-build[Import previously finished local module builds into MBS]:build_id' \
+    ':scm_url' \
+    ':branch'
+}
+
+(( $+functions[_fedpkg-module-overview] )) ||
+_fedpkg-module-overview () {
+  _arguments -C \
+    '(-h --help)'{-h,--help}'[show help message and exit]' \
+    '--unfinished[Show unfinished module builds]' \
+    '--limit[The number of most recent module builds to display]:limit'
+}
+
+(( $+functions[_fedpkg-module-build-watch] )) ||
+_fedpkg-module-build-watch () {
+  _arguments -C \
+    '(-h --help)'{-h,--help}'[show help message and exit]' \
+    ':build_id'
+}
+
 (( $+functions[_fedpkg-new] )) ||
 _fedpkg-new () {
   _arguments -C \
@@ -365,6 +414,12 @@ _fedpkg_commands () {
     local:'local test rpmbuild binary'
     mockbuild:'local test build using mock'
     mock-config:'generate a mock config'
+    module-build:'build a module using MBS'
+    module-build-cancel:'cancel an MBS module build'
+    module-build-info:'show information of an MBS module build'
+    module-build-local:'build a module locally using the mbs-manager command'
+    module-build-watch:'watch an MBS build'
+    module-overview:'shows an overview of MBS builds'
     new:'diff against last tag'
     new-sources:'upload new source files'
     patch:'create and add a gendiff patch file'

