#1445 beaker-tests, cli, frontend, python: use use_bootstrap and use_bootstrap_image
Closed 3 years ago by praiskup. Opened 3 years ago by dturecek.
copr/ dturecek/copr bootstrap-rfe  into  master

@@ -472,13 +472,13 @@ 

  

          # test use_bootstrap_container setting

          rlRun "copr-cli create ${NAME_PREFIX}BootstrapProject --use-bootstrap on --chroot $CHROOT"

-         rlAssertEquals "" `curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}BootstrapProject/detail/ |jq '.detail.use_bootstrap_container'` true

+         rlAssertEquals "" `curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}BootstrapProject/detail/ |jq '.detail.bootstrap_config'` true

          rlRun -s "copr-cli build ${NAME_PREFIX}BootstrapProject $HELLO --nowait"

          rlRun "parse_build_id"

          rlRun "copr watch-build $BUILD_ID"

          rlRun "curl $BACKEND_URL/results/${NAME_PREFIX}BootstrapProject/$CHROOT/`printf %08d $BUILD_ID`-hello/configs.tar.gz | tar xz -O '*configs/child.cfg' | grep \"config_opts\['use_bootstrap'\] = True\""

          rlRun "copr-cli modify ${NAME_PREFIX}BootstrapProject --use-bootstrap off"

-         rlAssertEquals "" `curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}BootstrapProject/detail/ |jq '.detail.use_bootstrap_container'` false

+         rlAssertEquals "" `curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}BootstrapProject/detail/ |jq '.detail.bootstrap_config'` false

  

          ## test building in copr dirs

          rlRun "copr-cli create --chroot $CHROOT ${NAME_PREFIX}CoprDirTest"

file modified
+36 -4
@@ -49,6 +49,14 @@ 

      None: None,

  }

  

+ BOOTSTRAP_MAP = {

+     "default": "default",

+     "on": "enabled",

+     "off": "disabled",

+     "image": "image",

+     None: "default",

+ }

+ 

  no_config_warning = """

  ================= WARNING: =======================

  File '{0}' is missing or incorrect.
@@ -376,7 +384,9 @@ 

              enable_net=ON_OFF_MAP[args.enable_net],

              persistent=args.persistent,

              auto_prune=ON_OFF_MAP[args.auto_prune],

-             use_bootstrap_container=ON_OFF_MAP[args.use_bootstrap_container],

+             use_bootstrap="image" if args.bootstrap_image else \

+                           BOOTSTRAP_MAP[args.use_bootstrap],

+             bootstrap_image=args.bootstrap_image,

              delete_after_days=args.delete_after_days,

              multilib=ON_OFF_MAP[args.multilib],

              module_hotfixes=ON_OFF_MAP[args.module_hotfixes],
@@ -398,7 +408,9 @@ 

              unlisted_on_hp=ON_OFF_MAP[args.unlisted_on_hp],

              enable_net=ON_OFF_MAP[args.enable_net],

              auto_prune=ON_OFF_MAP[args.auto_prune],

-             use_bootstrap_container=ON_OFF_MAP[args.use_bootstrap_container],

+             use_bootstrap="image" if args.bootstrap_image else \

+                           BOOTSTRAP_MAP[args.use_bootstrap],

+             bootstrap_image=args.bootstrap_image,

              chroots=args.chroots,

              delete_after_days=args.delete_after_days,

              multilib=ON_OFF_MAP[args.multilib],
@@ -879,8 +891,12 @@ 

      parser_create.add_argument("--auto-prune", choices=["on", "off"], default="on",

                                 help="If auto-deletion of project's obsoleted builds should be enabled (default is on).\

                                 This option can only be specified by a COPR admin.")

-     parser_create.add_argument("--use-bootstrap", choices=["on", "off"], dest="use_bootstrap_container",

+     parser_create.add_argument("--use-bootstrap", choices=["default", "on", "off", "image"],

+                                dest="use_bootstrap",

                                 help="If mock bootstrap container is used to initialize the buildroot.")

+     parser_create.add_argument("--bootstrap-image", dest="bootstrap_image",

+                                help="Which image is set for bootstrap container.\

+                                (Implies --use-bootstrap=image)")

      parser_create.add_argument("--delete-after-days", default=None, metavar='DAYS',

                                 help="Delete the project after the specfied period of time")

      parser_create.add_argument("--module-hotfixes", choices=["on", "off"], default="off",
@@ -916,8 +932,12 @@ 

      parser_modify.add_argument("--auto-prune", choices=["on", "off"],

                                 help="If auto-deletion of project's obsoleted builds should be enabled.\

                                 This option can only be specified by a COPR admin.")

-     parser_modify.add_argument("--use-bootstrap", choices=["on", "off"], dest="use_bootstrap_container",

+     parser_modify.add_argument("--use-bootstrap", choices=["default", "on", "off", "image"],

+                                dest="use_bootstrap",

                                 help="If mock bootstrap container is used to initialize the buildroot.")

+     parser_modify.add_argument("--bootstrap-image", dest="bootstrap_image",

+                                help="Which image is set for bootstrap container.\

+                                (Implies --use-bootstrap=image)")

      parser_modify.add_argument("--delete-after-days", default=None, metavar='DAYS',

                                 help=("Delete the project after the specfied "

                                       "period of time, empty or -1 disables, "
@@ -1034,6 +1054,12 @@ 

                                           help="Build packages to a specified copr")

      parser_build.add_argument("pkgs", nargs="+",

                                help="filename of SRPM or URL of packages to build")

+     parser_build.add_argument("--use-bootstrap", choices=["default", "on", "off", "image"],

+                               dest="use_bootstrap",

+                               help="If mock bootstrap container is used to initialize the buildroot.")

+     parser_build.add_argument("--bootstrap-image", dest="bootstrap_image",

+                               help="Which image is set for bootstrap container.\

+                               (Implies --use-bootstrap=image)")

      parser_build.set_defaults(func="action_build")

  

      # create the parser for the "buildpypi" command
@@ -1112,6 +1138,12 @@ 

                                        help="space separated string of package names to be added to buildroot")

      parser_edit_chroot.add_argument("--repos",

                                        help="space separated string of additional repo urls for chroot")

+     parser_edit_chroot.add_argument("--use-bootstrap", choices=["default", "on", "off", "image"],

+                                     dest="use_bootstrap",

+                                     help="If mock bootstrap container is used to initialize the buildroot.")

+     parser_edit_chroot.add_argument("--bootstrap-image", dest="bootstrap_image",

+                                     help="Which image is set for bootstrap container.\

+                                     (Implies --use-bootstrap=image)")

      parser_edit_chroot.set_defaults(func="action_edit_chroot")

  

      parser_get_chroot = subparsers.add_parser("get-chroot", help="Get chroot of a project")

@@ -0,0 +1,72 @@ 

+ """

+ add bootstrap-config columns

+ 

+ Revision ID: 63db6872060f

+ Revises: de903581465c

+ Create Date: 2020-06-29 08:59:07.525039

+ """

+ 

+ import sqlalchemy as sa

+ from alembic import op

+ 

+ 

+ revision = '63db6872060f'

+ down_revision = 'de903581465c'

+ 

+ def upgrade():

+     op.add_column('copr', sa.Column('bootstrap_config', sa.Text()))

+     op.add_column('copr', sa.Column('bootstrap_image', sa.Text()))

+     op.add_column('copr_chroot', sa.Column('bootstrap_config', sa.Text()))

+     op.add_column('copr_chroot', sa.Column('bootstrap_image', sa.Text()))

+     op.add_column('build', sa.Column('bootstrap_config', sa.Text()))

+     op.add_column('build', sa.Column('bootstrap_image', sa.Text()))

+ 

+ 

+     op.execute("""

+     UPDATE

+         copr

+     SET

+         bootstrap_config = 'enabled'

+     WHERE

+         use_bootstrap_container = true

+     """)

+ 

+     op.execute("""

+     UPDATE

+         copr

+     SET

+         bootstrap_config = 'disabled'

+     WHERE

+         use_bootstrap_container = false

+     """)

+ 

+     op.drop_column('copr', 'use_bootstrap_container')

+ 

+ def downgrade():

+     op.add_column('copr', sa.Column('use_bootstrap_container', sa.Boolean(),

+                   nullable=False, server_default='f'))

+ 

+     op.execute("""

+     UPDATE

+         copr

+     SET

+         use_bootstrap_container = true

+     WHERE

+         bootstrap_config = 'enabled'

+     """)

+ 

+     op.execute("""

+     UPDATE

+         copr

+     SET

+         use_bootstrap_container = false

+     WHERE

+         bootstrap_config = 'disabled'

+     """)

+ 

+     op.drop_column('copr', 'bootstrap_config')

+     op.drop_column('copr', 'bootstrap_image')

+     op.drop_column('copr_chroot', 'bootstrap_config')

+     op.drop_column('copr_chroot', 'bootstrap_image')

+     op.drop_column('build', 'bootstrap_config')

+     op.drop_column('build', 'bootstrap_image')

@@ -54,6 +54,33 @@ 

          raise exceptions.UnknownSourceTypeException("Invalid source type")

  

  

+ def create_mock_bootstrap_config_field(description=""):

+     return wtforms.SelectField(

+         "Mock bootstrap",

+         choices=[

+             ('default', 'Default mock-core-configs configuration'),

+             ('disabled', 'Bootstrap chroot disabled'),

+             ('enabled', 'Bootstrap chroot enabled'),

+             ('image', 'Bootstrap image enabled.'),

+             ('custom_image', 'Custom bootstrap image (specified in "Mock ' +

+              'bootstrap image" field)')],

+         description=description,

+     )

+ 

+ 

+ def create_mock_bootstrap_image_field(description=""):

+     return wtforms.TextField(

+         "Mock bootstrap image",

+         validators=[

+             wtforms.validators.Optional(),

+             wtforms.validators.Regexp(

+                 r"^\w+:\w+$",

+                 message=("Enter valid bootstrap image id "

+                          "(<distribution>:<version>)."))],

+         description=description,

+     )

+ 

+ 

  class MultiCheckboxField(wtforms.SelectMultipleField):

      widget = wtforms.widgets.ListWidget(prefix_label=False)

      option_widget = wtforms.widgets.CheckboxInput()
@@ -362,14 +389,8 @@ 

                      newer build (with respect to package version) and it is

                      older than 14 days""")

  

-             use_bootstrap_container = wtforms.BooleanField(

-                     "Enable mock's use_bootstrap_container experimental feature",

-                     description="""This will make the build slower but it has an

-                     advantage that the dnf _from_ the given chroot will be used

-                     to setup the chroot (otherwise host system dnf and rpm is

-                     used)""",

-                     default=False,

-                     false_values=FALSE_VALUES)

+             bootstrap_config = create_mock_bootstrap_config_field()

+             bootstrap_image = create_mock_bootstrap_image_field()

  

              follow_fedora_branching = wtforms.BooleanField(

                      "Follow Fedora branching",
@@ -979,6 +1000,10 @@ 

                  UrlListValidator(),

                  UrlSrpmListValidator()],

              filters=[StringListFilter()])

+ 

+         form.bootstrap_config = create_mock_bootstrap_config_field()

+         form.bootstrap_image = create_mock_bootstrap_image_field()

+ 

          return form

  

  
@@ -1065,6 +1090,9 @@ 

      with_opts = wtforms.StringField("With options")

      without_opts = wtforms.StringField("Without options")

  

+     bootstrap_config = create_mock_bootstrap_config_field()

+     bootstrap_image = create_mock_bootstrap_image_field()

+ 

  

  class CoprChrootExtend(FlaskForm):

      extend = wtforms.StringField("Chroot name")
@@ -1154,7 +1182,8 @@ 

      disable_createrepo = wtforms.BooleanField(validators=[wtforms.validators.Optional()], false_values=FALSE_VALUES)

      unlisted_on_hp = wtforms.BooleanField(validators=[wtforms.validators.Optional()], false_values=FALSE_VALUES)

      auto_prune = wtforms.BooleanField(validators=[wtforms.validators.Optional()], false_values=FALSE_VALUES)

-     use_bootstrap_container = wtforms.BooleanField(validators=[wtforms.validators.Optional()], false_values=FALSE_VALUES)

+     bootstrap_config = create_mock_bootstrap_config_field()

+     bootstrap_image = create_mock_bootstrap_image_field()

      follow_fedora_branching = wtforms.BooleanField(validators=[wtforms.validators.Optional()], false_values=FALSE_VALUES)

      follow_fedora_branching = wtforms.BooleanField(default=True, false_values=FALSE_VALUES)

      delete_after_days = wtforms.IntegerField(

@@ -404,7 +404,8 @@ 

              'additional_packages': packages.split(),

              'repos': repos,

              'chroot': chroot_id,

-             'use_bootstrap_container': copr.use_bootstrap_container,

+             'bootstrap_config': copr.bootstrap_config,

+             'bootstrap_image': copr.bootstrap_image,

              'with_opts': chroot.with_opts.split(),

              'without_opts': chroot.without_opts.split(),

          }

@@ -218,7 +218,8 @@ 

      @classmethod

      def add(cls, user, name, selected_chroots, repos=None, description=None,

              instructions=None, check_for_duplicates=False, group=None, persistent=False,

-             auto_prune=True, use_bootstrap_container=False, follow_fedora_branching=False, **kwargs):

+             auto_prune=True, bootstrap_config="default", follow_fedora_branching=False,

+             bootstrap_image=None, **kwargs):

  

          if not flask.g.user.admin and flask.g.user != user:

              msg = ("You were authorized as '{0}' user without permissions to access "
@@ -242,7 +243,8 @@ 

                             created_on=int(time.time()),

                             persistent=persistent,

                             auto_prune=auto_prune,

-                            use_bootstrap_container=use_bootstrap_container,

+                            bootstrap_config=bootstrap_config,

+                            bootstrap_image=bootstrap_image,

                             follow_fedora_branching=follow_fedora_branching,

                             **kwargs)

  
@@ -678,7 +680,8 @@ 

  

      @classmethod

      def update_chroot(cls, user, copr_chroot, buildroot_pkgs=None, repos=None, comps=None, comps_name=None,

-                       with_opts="", without_opts="", delete_after=None, delete_notify=None, module_toggle=""):

+                       with_opts="", without_opts="", delete_after=None, delete_notify=None, module_toggle="",

+                       bootstrap_config="", bootstrap_image=""):

          """

          :type user: models.User

          :type copr_chroot: models.CoprChroot
@@ -688,12 +691,14 @@ 

              "Only owners and admins may update their projects.")

  

          cls._update_chroot(buildroot_pkgs, repos, comps, comps_name,

-                            copr_chroot, with_opts, without_opts, delete_after, delete_notify, module_toggle)

+                            copr_chroot, with_opts, without_opts, delete_after, delete_notify, module_toggle,

+                            bootstrap_config, bootstrap_image)

          return copr_chroot

  

      @classmethod

      def _update_chroot(cls, buildroot_pkgs, repos, comps, comps_name,

-                        copr_chroot, with_opts, without_opts, delete_after, delete_notify, module_toggle):

+                        copr_chroot, with_opts, without_opts, delete_after, delete_notify, module_toggle,

+                        bootstrap_config, bootstrap_image):

          if buildroot_pkgs is not None:

              copr_chroot.buildroot_pkgs = buildroot_pkgs

  
@@ -720,6 +725,12 @@ 

          if module_toggle is not None:

              copr_chroot.module_toggle = module_toggle

  

+         if bootstrap_config is not None:

+             copr_chroot.bootstrap_config = bootstrap_config

+ 

+         if bootstrap_image is not None:

+             copr_chroot.bootstrap_image = bootstrap_image

+ 

          db.session.add(copr_chroot)

  

      @classmethod

@@ -296,8 +296,8 @@ 

      # if backend deletion script should be run for the project's builds

      auto_prune = db.Column(db.Boolean, default=True, nullable=False, server_default="1")

  

-     # use mock's bootstrap container feature

-     use_bootstrap_container = db.Column(db.Boolean, default=False, nullable=False, server_default="0")

+     bootstrap_config = db.Column(db.Text, default="default")

+     bootstrap_image = db.Column(db.Text, default="default")

  

      # if chroots for the new branch should be auto-enabled and populated from rawhide ones

      follow_fedora_branching = db.Column(db.Boolean, default=True, nullable=False, server_default="1")
@@ -921,6 +921,9 @@ 

      source_status = db.Column(db.Integer, default=StatusEnum("waiting"))

      srpm_url = db.Column(db.Text)

  

+     bootstrap_config = db.Column(db.Text)

+     bootstrap_image = db.Column(db.Text)

+ 

      # relations

      user_id = db.Column(db.Integer, db.ForeignKey("user.id"), index=True)

      user = db.relationship("User", backref=db.backref("builds"))
@@ -1451,6 +1454,9 @@ 

      delete_after = db.Column(db.DateTime, index=True)

      delete_notify = db.Column(db.DateTime, index=True)

  

+     bootstrap_config = db.Column(db.Text)

+     bootstrap_image = db.Column(db.Text)

+ 

      def update_comps(self, comps_xml):

          if isinstance(comps_xml, str):

              data = comps_xml.encode("utf-8")

@@ -34,6 +34,23 @@ 

    {% endif %}

  {% endmacro %}

  

+ {% macro render_dropdown_field(field, values) %}

+   {{ values }}

+   <div class="form-group">

+     <label class="col-sm-2 control-label">

+       {{ field.label }}:

+     </label>

+     <div class="col-sm-10" id="bootstrap_config">

+       <select name="value" class="input">

+         {% for value in values %}

+           {% set selected = 'selected' %}

+           <option value="{{ value }}">{{ value }}</option>

+         {% endfor %}

+       </select>

+     </div>

+   </div>

+ {% endmacro %}

+ 

  {% macro render_checkbox_field(title, items) %}

  <div class="form-group">

    <label class="col-sm-2 control-label" for="textInput-markup">
@@ -575,6 +592,15 @@ 

      {{ render_field(form.memory_reqs, hidden = True) }}

      {{ render_field(form.timeout, hidden = True) }}

    {% endif %}

+ 

+   {{ render_field(form.bootstrap_config, rows=1, cols=35, placeholder='default') }}

+   <div style="display:none" id="bootstrap_image">

+     {{ render_field(form.bootstrap_image, rows=5, cols=50, placeholder='Used when "custom image" is set in Mock Bootstrap. Enter in <distribution>:<version> format (e.g. fedora:32)') }}

+   </div>

+   <noscript>

+     {{ render_field(form.bootstrap_image, rows=5, cols=50, placeholder='Used when "custom image" is set in Mock Bootstrap. Enter in <distribution>:<version> format (e.g. fedora:32)') }}

+   </noscript>

+ 

    <div class="form-group">

      <label class="col-sm-2 control-label" for="textInput-markup" style="text-align: left">

      Other Options
@@ -587,6 +613,23 @@ 

        </div>

      </div>

    </div>

+ 

+ 

+   <script>

+     $(document).ready(function() {

+       if ($("#bootstrap_config").value == "custom_image") {

+         $("#bootstrap_image").show();

+       }

+       $("#bootstrap_config").change(function() {

+         if (this.value == "custom_image") {

+           $("#bootstrap_image").show();

+         }

+         else {

+           $("#bootstrap_image").hide();

+         }

+       });

+     });

+   </script>

  {% endmacro %}

  

  

@@ -1,4 +1,5 @@ 

- {% from "_helpers.html" import render_field, render_checkbox_field, render_form_errors, copr_details_href, copr_url %}

+ {% from "_helpers.html" import render_field, render_checkbox_field,

+ render_form_errors, copr_details_href, copr_url, render_dropdown_field %}

  

  {% macro copr_form(form, view, copr = None, username = None, group = None, comments = None) %}

    {# if using for updating, we need to pass name to url_for, but otherwise we need to pass nothing #}
@@ -142,7 +143,6 @@ 

          [form.auto_prune, g.user.admin],

          [form.unlisted_on_hp],

          [form.persistent, g.user.admin],

-         [form.use_bootstrap_container],

          [form.follow_fedora_branching],

          [form.multilib],

          [form.module_hotfixes],
@@ -153,12 +153,35 @@ 

              placeholder='Optional',

              info='Delete the project after the specfied period of time (empty = disabled)') }}

  

+     {{ render_field(form.bootstrap_config, rows=1, cols=35, placeholder='default') }}

+     <div style="display:none" id="bootstrap_image">

+       {{ render_field(form.bootstrap_image, rows=5, cols=50, placeholder='Used when "custom image" is set in Mock Bootstrap. Enter in <distribution>:<version> format (e.g. fedora:32)') }}

+     </div>

+     <noscript>

+     {{ render_field(form.bootstrap_image, rows=5, cols=50, placeholder='Used when "custom image" is set in Mock Bootstrap. Enter in <distribution>:<version> format (e.g. fedora:32)') }}

You can set this in render_kw={'placeholder'}, directly in form (preferred).

+     </noscript>

+ 

      {{ render_field(form.runtime_dependencies, rows=5, cols=50, placeholder='Optional - URL to additional yum repos, which can be used as runtime dependencies. Space separated. This should be baseurl from .repo file. E.g.: http://copr-be.cloud.fedoraproject.org/results/rhughes/f20-gnome-3-12/fedora-$releasever-$basearch/') }}

      </div>

    </div>

  

      <input class="btn btn-primary" type="submit" value="{% if copr %}Update{% else %}Create{% endif %}">

    </form>

+   <script> 

+     $(document).ready(function() {

+       if ($("#bootstrap_config").value == "custom_image") {

+         $("#bootstrap_image").show();

+       }

+       $("#bootstrap_config").change(function() {

+         if (this.value == "custom_image") {

+           $("#bootstrap_image").show();

+         }

+         else {

+           $("#bootstrap_image").hide();

+         }

+       });

+     });

+   </script>

  {% endmacro %}

  

  {% macro copr_delete_form(form, copr) %}

@@ -56,6 +56,26 @@ 

         )

      }}

  

+     {{ render_field(

+         form.bootstrap_config, rows=1, cols=35, placeholder='default'

+        )

+     }}

+ 

+     <div style="display:none" id="bootstrap_image">

+       {{ render_field(

+           form.bootstrap_image, rows=5, cols=50,

+           placeholder='Used when "custom image" is set in Mock Bootstrap. Enter in <distribution>:<version> format (e.g. fedora:32)'

+          )

+       }}

+     </div>

+     <noscript>

+       {{ render_field(

+           form.bootstrap_image, rows=5, cols=50,

+           placeholder='Used when "custom image" is set in Mock Bootstrap. Enter in <distribution>:<version> format (e.g. fedora:32)'

+          )

+       }}

+     </noscript>

+ 

      <div class="form-group">

        <label class="col-sm-2 control-label" for="textInput-markup">

          comps.xml
@@ -86,6 +106,21 @@ 

      <input class="btn btn-primary" type="submit" name="submit" value="update">

      <a class="btn btn-default" href="{{ copr_url('coprs_ns.copr_edit', copr) }}">Cancel</a>

    </form>

- 

+   <script>

+     $(document).ready(function() {

+       if ($("#bootstrap_config").value == "custom_image") {

+         $("#bootstrap_image").show();

+       }

+       $("#bootstrap_config").change(function() {

+         if (this.value == "custom_image") {

+           $("#bootstrap_image").show();

+         }

+         else {

+           $("#bootstrap_image").hide();

+         }

+       });

+     });

+   </script>

+ {

  

  {% endblock %}

@@ -139,9 +139,9 @@ 

          if "auto_prune" in flask.request.form:

              auto_prune = form.auto_prune.data

  

-         use_bootstrap_container = True

-         if "use_bootstrap_container" in flask.request.form:

-             use_bootstrap_container = form.use_bootstrap_container.data

+         bootstrap_config = "default"

+         if "bootstrap_config" in flask.request.form:

+             bootstrap_config = form.bootstrap_config.data

  

          try:

              copr = CoprsLogic.add(
@@ -158,7 +158,8 @@ 

                  group=group,

                  persistent=form.persistent.data,

                  auto_prune=auto_prune,

-                 use_bootstrap_container=use_bootstrap_container,

+                 bootstrap_config=bootstrap_config,

+                 bootstrap_image=form.bootstrap_image.data,

              )

              infos.append("New project was successfully created.")

  
@@ -344,7 +345,8 @@ 

          "persistent": copr.persistent,

          "unlisted_on_hp": copr.unlisted_on_hp,

          "auto_prune": copr.auto_prune,

-         "use_bootstrap_container": copr.use_bootstrap_container,

+         "bootstrap_config": copr.bootstrap_config,

+         "bootstrap_image": copr.bootstrap_image,

      }

      return flask.jsonify(output)

  
@@ -696,8 +698,8 @@ 

          copr.build_enable_net = form.build_enable_net.data

      if "auto_prune" in flask.request.form:

          copr.auto_prune = form.auto_prune.data

-     if "use_bootstrap_container" in flask.request.form:

-         copr.use_bootstrap_container = form.use_bootstrap_container.data

+     if "bootstrap_config" in flask.request.form:

+         copr.bootstrap_config = form.bootstrap_config.data

      if "chroots" in  flask.request.form:

          coprs_logic.CoprChrootsLogic.update_from_names(

              flask.g.user, copr, form.chroots.data)

@@ -24,7 +24,7 @@ 

          "repos": config.get("repos"),

          "additional_repos": BuildConfigLogic.generate_additional_repos(copr_chroot),

          "additional_packages": config.get("additional_packages"),

-         "use_bootstrap_container": config.get("use_bootstrap_container"),

+         "bootstrap_config": config.get("bootstrap_config"),

          "with_opts": config.get("with_opts"),

          "without_opts": config.get("without_opts"),

          "memory_limit": build_chroot.build.memory_reqs,

@@ -30,7 +30,8 @@ 

          "repos": config["repos"],

          "additional_repos": BuildConfigLogic.generate_additional_repos(project_chroot),

          "additional_packages": (project_chroot.buildroot_pkgs or "").split(),

-         "use_bootstrap_container": project_chroot.copr.use_bootstrap_container,

+         "bootstrap_config": project_chroot.copr.bootstrap_config,

+         "bootstrap_inmage": project_chroot.copr.bootstrap_image,

          "enable_net": project_chroot.copr.enable_net,

          "with_opts":  str_to_list(project_chroot.with_opts),

          "without_opts": str_to_list(project_chroot.without_opts),

@@ -29,7 +29,8 @@ 

          "chroot_repos": CoprsLogic.get_yum_repos(copr, empty=True),

          "additional_repos": copr.repos_list,

          "enable_net": copr.build_enable_net,

-         "use_bootstrap_container": copr.use_bootstrap_container,

+         "bootstrap_config": copr.bootstrap_config,

+         "bootstrap_image": copr.bootstrap_image,

          "module_hotfixes": copr.module_hotfixes,

      }

  
@@ -141,7 +142,7 @@ 

              group=group,

              persistent=form.persistent.data,

              auto_prune=form.auto_prune.data,

-             use_bootstrap_container=form.use_bootstrap_container.data,

+             bootstrap_config=form.bootstrap_config.data,

              homepage=form.homepage.data,

              contact=form.contact.data,

              disable_createrepo=form.disable_createrepo.data,
@@ -161,6 +162,8 @@ 

  @apiv3_ns.route("/project/edit/<ownername>/<projectname>", methods=PUT)

  @api_login_required

  def edit_project(ownername, projectname):

+     import ipdb;

+     ipdb.set_trace()

small leftover

      copr = get_copr(ownername, projectname)

      data = rename_fields(get_form_compatible_data())

      form = forms.CoprModifyForm(data, meta={'csrf': False})
@@ -176,6 +179,8 @@ 

              continue

          setattr(copr, field.name, field.data)

  

+     ipdb.set_trace()

+ 

      if form.chroots.data:

          CoprChrootsLogic.update_from_names(

              flask.g.user, copr, form.chroots.data)

@@ -131,7 +131,8 @@ 

          build_config = BuildConfigLogic.generate_build_config(task.build.copr, task.mock_chroot.name)

          build_record["repos"] = build_config.get("repos")

          build_record["buildroot_pkgs"] = build_config.get("additional_packages")

-         build_record["use_bootstrap_container"] = build_config.get("use_bootstrap_container")

+         build_record["bootstrap_container"] = build_config.get("bootstrap_config")

+         build_record["bootstrap_image"] = build_config.get("bootstrap_image")

          build_record["with_opts"] = build_config.get("with_opts")

          build_record["without_opts"] = build_config.get("without_opts")

  

@@ -30,7 +30,9 @@ 

  

      form = forms.ChrootForm(buildroot_pkgs=chroot.buildroot_pkgs, repos=chroot.repos,

                              module_toggle=chroot.module_toggle, with_opts=chroot.with_opts,

-                             without_opts=chroot.without_opts)

+                             without_opts=chroot.without_opts,

+                             bootstrap_config=chroot.bootstrap_config,

+                             bootstrap_image=chroot.bootstrap_image)

      # FIXME - test if chroot belongs to copr

      if flask.g.user.can_build_in(copr):

          return render_template("coprs/detail/edit_chroot.html",
@@ -75,7 +77,9 @@ 

                      form.repos.data,

                      comps=comps_xml, comps_name=comps_name,

                      with_opts=form.with_opts.data, without_opts=form.without_opts.data,

-                     module_toggle=form.module_toggle.data

+                     module_toggle=form.module_toggle.data,

+                     bootstrap_config=form.bootstrap_config.data,

+                     bootstrap_image=form.bootstrap_image.data,

                  )

  

              elif action == "delete_comps":

@@ -192,11 +192,12 @@ 

                  group=group,

                  persistent=form.persistent.data,

                  auto_prune=(form.auto_prune.data if flask.g.user.admin else True),

-                 use_bootstrap_container=form.use_bootstrap_container.data,

                  follow_fedora_branching=form.follow_fedora_branching.data,

                  delete_after_days=form.delete_after_days.data,

                  multilib=form.multilib.data,

                  runtime_dependencies=form.runtime_dependencies.data.replace("\n", " "),

+                 bootstrap_config=form.bootstrap_config.data,

+                 bootstrap_image=form.bootstrap_image.data,

              )

  

              db.session.commit()
@@ -504,12 +505,13 @@ 

      copr.disable_createrepo = form.disable_createrepo.data

      copr.build_enable_net = form.build_enable_net.data

      copr.unlisted_on_hp = form.unlisted_on_hp.data

-     copr.use_bootstrap_container = form.use_bootstrap_container.data

      copr.follow_fedora_branching = form.follow_fedora_branching.data

      copr.delete_after_days = form.delete_after_days.data

      copr.multilib = form.multilib.data

      copr.module_hotfixes = form.module_hotfixes.data

      copr.runtime_dependencies = form.runtime_dependencies.data.replace("\n", " ")

+     copr.bootstrap_config = form.bootstrap_config.data

+     copr.bootstrap_image = form.bootstrap_image.data

      if flask.g.user.admin:

          copr.auto_prune = form.auto_prune.data

      else:

@@ -59,8 +59,9 @@ 

  

      def add(self, ownername, projectname, chroots, description=None, instructions=None, homepage=None,

              contact=None, additional_repos=None, unlisted_on_hp=False, enable_net=True, persistent=False,

-             auto_prune=True, use_bootstrap_container=False, devel_mode=False,

-             delete_after_days=None, multilib=False, module_hotfixes=False):

+             auto_prune=True, use_bootstrap="default", devel_mode=False,

+             delete_after_days=None, multilib=False, module_hotfixes=False,

+             bootstrap_image=None):

          """

          Create a project

  
@@ -76,13 +77,16 @@ 

          :param bool enable_net: if builder can access net for builds in this project

          :param bool persistent: if builds and the project are undeletable

          :param bool auto_prune: if backend auto-deletion script should be run for the project

-         :param bool use_bootstrap_container: if mock bootstrap container is used to initialize the buildroot

I'd much rather keep this option here, and either ignore it (in the worst case) or simply map it to the new use_bootstrap. Simply to not break the API.

+         :param str use_bootstrap: if mock bootstrap container is used to initialize the buildroot.

+                                   Possible values: default, on, off, image

          :param bool devel_mode: if createrepo should run automatically

          :param int delete_after_days: delete the project after the specfied period of time

          :param bool module_hotfixes: make packages from this project available

                                       on along with packages from the active module streams.

+         :param str bootstrap_image: name of an image for bootstrap container.

          :return: Munch

          """

+         import ipdb; ipdb.set_trace()

          endpoint = "/project/add/{ownername}"

          params = {

              "ownername": ownername,
@@ -99,7 +103,8 @@ 

              "enable_net": enable_net,

              "persistent": persistent,

              "auto_prune": auto_prune,

-             "use_bootstrap_container": use_bootstrap_container,

+             "bootstrap_config": use_bootstrap,

+             "bootstrap_image": bootstrap_image,

              "devel_mode": devel_mode,

              "delete_after_days": delete_after_days,

              "multilib": multilib,
@@ -112,8 +117,9 @@ 

  

      def edit(self, ownername, projectname, chroots=None, description=None, instructions=None, homepage=None,

               contact=None, additional_repos=None, unlisted_on_hp=None, enable_net=None,

-              auto_prune=None, use_bootstrap_container=None, devel_mode=None,

-              delete_after_days=None, multilib=None, module_hotfixes=None):

+              auto_prune=None, use_bootstrap="default", devel_mode=None,

+              delete_after_days=None, multilib=None, module_hotfixes=None,

+              bootstrap_image=None):

          """

          Edit a project

  
@@ -128,13 +134,16 @@ 

          :param bool unlisted_on_hp: project will not be shown on Copr homepage

          :param bool enable_net: if builder can access net for builds in this project

          :param bool auto_prune: if backend auto-deletion script should be run for the project

-         :param bool use_bootstrap_container: if mock bootstrap container is used to initialize the buildroot

+         :param str use_bootstrap: if mock bootstrap container is used to initialize the buildroot.

+                                             Possible values: default, on, off, image.

          :param bool devel_mode: if createrepo should run automatically

          :param int delete_after_days: delete the project after the specfied period of time

          :param bool module_hotfixes: make packages from this project available

                                       on along with packages from the active module streams.

+         :param str bootstrap_image: name of an image for bootstrap container.

          :return: Munch

          """

+         import ipdb; ipdb.set_trace()

          endpoint = "/project/edit/{ownername}/{projectname}"

          params = {

              "ownername": ownername,
@@ -150,7 +159,8 @@ 

              "unlisted_on_hp": unlisted_on_hp,

              "enable_net": enable_net,

              "auto_prune": auto_prune,

-             "use_bootstrap_container": use_bootstrap_container,

+             "bootstrap_config": use_bootstrap,

+             "bootstrap_image": bootstrap_image,

              "devel_mode": devel_mode,

              "delete_after_days": delete_after_days,

              "multilib": multilib,

@@ -21,6 +21,7 @@ 

          self.enable_net = task.get("enable_net")

          self.repos = task.get("repos")

          self.use_bootstrap_container = task.get("use_bootstrap_container")

+         self.bootstrap_image = task.get("bootstrap_image")

          self.timeout = task.get("timeout", 3600)

          self.with_opts = task.get("with_opts", [])

          self.without_opts = task.get("without_opts", [])
@@ -66,6 +67,7 @@ 

          template = jinja_env.get_template("mock.cfg.j2")

          return template.render(chroot=self.chroot, task_id=self.task_id, buildroot_pkgs=self.buildroot_pkgs,

                                 enable_net=self.enable_net, use_bootstrap_container=self.use_bootstrap_container,

+                                bootstrap_image=self.bootstrap_image,

                                 repos=self.repos,

                                 copr_username=self.copr_username, copr_projectname=self.copr_projectname,

                                 modules=self.enable_modules,

file modified
+2
@@ -18,6 +18,8 @@ 

  config_opts['macros']['%buildtag'] = '.copr{{ copr_build_id }}'

  

  config_opts['use_bootstrap'] = {{ 'True' if use_bootstrap_container else 'False' }}

Probably use_bootstrap_container here needs a change.

+ config_opts['use_bootstrap_image'] = {{ 'True' if use_bootstrap_container == 'image' else 'False' }}

+ config_opts['bootstrap_image'] = {{ bootstrap_image if use_bootstrap_container == 'custom_image' else '' }}

  

  {% if use_bootstrap_container %}

  config_opts['bootstrap_chroot_additional_packages'] = []

Metadata Update from @dturecek:
- Pull-request tagged with: needs-work

3 years ago

I sort of expected that we could drop the old config option here, and introduce new one like:
bootstrap=on|off|image|image=<image>|default
(per discussion in the corresponding issue).

rebased onto 6bd024b

3 years ago

Metadata Update from @praiskup:
- Pull-request untagged with: needs-work

3 years ago

You can set this in render_kw={'placeholder'}, directly in form (preferred).

I'd much rather keep this option here, and either ignore it (in the worst case) or simply map it to the new use_bootstrap. Simply to not break the API.

Probably use_bootstrap_container here needs a change.

Very good progress, can we add a beaker test for the image?

pretty please pagure-ci rebuild

3 years ago

pretty please pagure-ci rebuild

3 years ago

The frontend/coprs_frontend/coprs/templates/._helpers.html.swo file breaks Jenkins CI.

Gently ping on this, should we hand-over the PR to someone else?

I'm working on follow-up patches here. Closing, and thank you for this PR!

Pull-Request has been closed by praiskup

3 years ago
Changes Summary 21
+2 -2
file changed
beaker-tests/Sanity/copr-cli-basic-operations/runtest.sh
+36 -4
file changed
cli/copr_cli/main.py
+72
file added
frontend/coprs_frontend/alembic/versions/63db6872060f_add_bootstrap_config_columns.py
+38 -9
file changed
frontend/coprs_frontend/coprs/forms.py
+2 -1
file changed
frontend/coprs_frontend/coprs/logic/complex_logic.py
+16 -5
file changed
frontend/coprs_frontend/coprs/logic/coprs_logic.py
+8 -2
file changed
frontend/coprs_frontend/coprs/models.py
+0
file added
frontend/coprs_frontend/coprs/templates/._helpers.html.swo
+43 -0
file changed
frontend/coprs_frontend/coprs/templates/_helpers.html
+25 -2
file changed
frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
+36 -1
file changed
frontend/coprs_frontend/coprs/templates/coprs/detail/edit_chroot.html
+9 -7
file changed
frontend/coprs_frontend/coprs/views/api_ns/api_general.py
+1 -1
file changed
frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_build_chroots.py
+2 -1
file changed
frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_project_chroots.py
+7 -2
file changed
frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_projects.py
+2 -1
file changed
frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
+6 -2
file changed
frontend/coprs_frontend/coprs/views/coprs_ns/coprs_chroots.py
+4 -2
file changed
frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+18 -8
file changed
python/copr/v3/proxies/project.py
+2 -0
file changed
rpmbuild/copr_rpmbuild/builders/mock.py
+2 -0
file changed
rpmbuild/mock.cfg.j2