aboutsummaryrefslogtreecommitdiffstats
path: root/docker/scripts/set_dockerfile_and_pom.pl
blob: 8411f30d0625cef89248bf0cb31e3b664236c05d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl

use strict;
use warnings;


my @lines;

#
### POM file
#

my $file = 'pom.xml';
### Read the pom.xml file.
open (POM, $file) or die "[ERROR] Cannot read the file '$file' : $!\n\n";
chomp (@lines = <POM>);
close (POM);

open (NEW, ">${file}") or die "[ERROR] Cannot write to the file '$file' : $!\n\n";
foreach my $line (@lines) {

	# Replace groupID
	if ($line =~ m|<groupId>org.onap.sdc</groupId>|) {
		$line =~ s|org.onap.sdc|com.att.sdc|;
	}

	# Remove the tags.
	if ($line =~ m|<tag>(.*)</tag>|) {

		if ($1 eq '${docker.tag}') {
			$line =~ s|\$\{docker.tag\}|\$\{project.version\}|;
		}
		else {
			next;
		}
	}

	print NEW "$line\n";
}
close (NEW);


#
### Dockerfie
#

my $dockerFile = 'Dockerfile';

open (FILE, $dockerFile) or die "[ERROR] Cannot read the file '$dockerFile' : $!\n\n";
chomp (@lines = <FILE>);
close (FILE);

open (NEW, ">${dockerFile}") or die "[ERROR] Cannot write to the file '$dockerFile' : $!\n\n";

foreach my $line (@lines) {
	# Replace the docker registry
	if ($line =~ m|FROM|) {
		$line =~ s|onap|dockercentral.it.att.com:5100/com.att.sdc|;
	}
	print NEW "$line\n";
}
close (NEW);