Changeset 2092 in ProjectBuilder


Ignore:
Timestamp:
Jun 1, 2016, 6:29:33 PM (5 years ago)
Author:
Bruno Cornec
Message:

Adds function pv_ve_docker_repo

Reuse code from VE.pm in pb to check whether we use a Registry or just a
repository
Adds a new conf param dockerrepository and document it (mandatory if no
registry used)

Location:
devel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf.pod

    r2079 r2092  
    127127 Example: dockerregistry mondorescue = localhost:5900/mondorescue
    128128
     129=item B<dockerrepository>
     130
     131 Nature: Optional
     132 Key: project (as defined in the -p option or PBPROJ environment variable)
     133 Value: name of the docker repository to interact with if any. It is mandatory if no dockerregistry is defined.
     134 Conffile: project
     135 Example: dockerrepository mondorescue = localhost:5000/mondorescue
     136
    129137=item B<extpkgdir>
    130138
  • devel/pb-modules/lib/ProjectBuilder/VE.pm

    r2032 r2092  
    3232 
    3333our @ISA = qw(Exporter);
    34 our @EXPORT = qw(pb_ve_launch pb_ve_snap pb_ve_get_type pb_ve_docker_repo pb_ve_docker_get_image);
     34our @EXPORT = qw(pb_ve_launch pb_ve_snap pb_ve_get_type pb_ve_docker_repo pb_ve_docker_get_image pv_ve_docker_repo);
    3535
    3636($VERSION,$REVISION) = pb_version_init();
     
    7373my $pbimage = shift;
    7474
    75 my $dockerregistry = undef;
    7675my $docrepo = "";           # By default no repository for docker available
    7776
     
    8483
    8584if ($vetype eq "docker") {
    86     # Check acces to registry
    87     ($dockerregistry) = pb_conf_get("dockerregistry");
    88     if ((defined $dockerregistry) && (defined $dockerregistry->{$ENV{'PBPROJ'}})) {
    89         pb_ve_docker_registry($dockerregistry->{$ENV{'PBPROJ'}});
    90         $docrepo = pb_ve_docker_repo($dockerregistry->{$ENV{'PBPROJ'}}).":";
    91     }
     85    $docrepo = pv_ve_docker_repo();
    9286}
    9387
     
    432426}
    433427
     428sub pv_ve_docker_repo {
     429
     430my $docrepo = "";
     431# Check acces to registry
     432my ($dockerregistry) = pb_conf_get_if("dockerregistry");
     433if ((defined $dockerregistry) && (defined $dockerregistry->{$ENV{'PBPROJ'}})) {
     434    pb_ve_docker_registry($dockerregistry->{$ENV{'PBPROJ'}});
     435    $docrepo = pb_ve_docker_repo($dockerregistry->{$ENV{'PBPROJ'}}).":";
     436} else {
     437    my ($dockerrepository) = pb_conf_get("dockerrepository");
     438    $docrepo = $dockerrepository->{$ENV{'PBPROJ'}}.":";
     439}
     440pb_log(1,"Using Docker Repository $docrepo\n");
     441return($docrepo);
     442}
     443
    434444
    435445=head1 WEB SITES
  • devel/pb/bin/pb

    r2085 r2092  
    24272427    my $tpdir;
    24282428    my $tp;
    2429     my $docrepo;
    24302429    my $context = "$ENV{'PBTMP'}";
    24312430    my %tag;
     
    24502449            # docker manages the storage so rely on it
    24512450            $shcmdroot = "";
    2452             my ($dockerregistry) = pb_conf_get("dockerregistry");
    2453             $docrepo = pb_ve_docker_repo($dockerregistry->{$ENV{'PBPROJ'}});
     2451            my $docrepo = pv_ve_docker_repo();
    24542452            $cmd1 = pb_check_req("docker",0);
    24552453            #my ($dockeropt) =  pb_conf_get_if("dockeropt");
     
    24632461            if ((not defined $pbimage) || ($pbimage eq "")) {
    24642462                # If no image name given, create a naming convention
    2465                 $tag{1} = "$docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
     2463                $tag{1} = "$docrepo$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
    24662464                $tag{2} = "$tag{1}-pb";
    24672465                $tag{3} = "$tag{2}-$ENV{'PBPROJ'}";
Note: See TracChangeset for help on using the changeset viewer.