public function testBuild()
 {
     $inspect = new DockerInspectCommand();
     // Container.
     $this->assertFalse($inspect->build());
     $inspect->setContainer('123456');
     $command = $inspect->build();
     $this->assertTrue(!empty($command));
     // Format.
     $inspect->setFormat('{{ .Rock }}');
     $command = $inspect->build();
     $this->assertEquals('docker inspect --format "{{ .Rock }}" 123456', $command);
     // Command.
     $inspect->setCommand('| grep "wazzup"');
     $command = $inspect->build();
     $this->assertEquals('docker inspect --format "{{ .Rock }}" 123456 | grep "wazzup"', $command);
 }
Esempio n. 2
0
 /**
  * Adds a container service to the permutation.
  */
 public function addService($service)
 {
     // Convert the service name to uppercase for bash variables.
     $uppercase_service = str_replace("-", "_", strtoupper($service));
     $namespace = $this->getNamespace();
     // Build the service command.
     $run = new DockerRunCommand();
     $run->setDaemon(true);
     // $run->setRemove(true);
     $run->setImage($namespace . '/' . $service);
     // Privileged.
     $privileged = $this->getPrivileged();
     if ($privileged) {
         $run->setPrivileged(true);
     }
     $command = $run->build();
     $this->addStep($uppercase_service . '_ID=$(' . $command . ')');
     // Build the inspect command.
     $run = new DockerInspectCommand();
     $run->setFormat('{{ .Name }}');
     $run->setContainer('$' . $uppercase_service . '_ID');
     $run->setCommand('| cut -d "/" -f 2');
     $command = $run->build();
     $this->addStep($uppercase_service . '=$(' . $command . ')');
     // Add a link so we can access these services from the main container.
     $this->addLink('$' . $uppercase_service . ':' . $service);
 }