@Test( expectedExceptions = EnvironmentException.class, expectedExceptionsMessageRegExp = "ws-machine is not found on agents applying" ) public void shouldThrowEnvExceptionIfNoMachinesFoundInEnvironment() throws Exception { environment.setMachines(Collections.emptyMap()); provisioner.provision(environment, internalEnv); }
@Override public void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv) throws EnvironmentException { String devMachineName = getDevMachineName(envConfig); if (devMachineName == null) { throw new EnvironmentException("ws-machine is not found on agents applying"); } CheServiceImpl devMachine = internalEnv.getServices().get(devMachineName); HashMap<String, String> environmentVars = new HashMap<>(devMachine.getEnvironment()); environmentVars.put(SYNC_KEY_ENV_VAR_NAME, pubSyncKey); environmentVars.put( CheBootstrap.CHE_LOCAL_CONF_DIR, DockerExtConfBindingProvider.EXT_CHE_LOCAL_CONF_DIR); devMachine.setEnvironment(environmentVars); ExtendedMachineImpl extendedMachine = envConfig.getMachines().get(devMachineName); List<String> agents = new ArrayList<>(extendedMachine.getAgents()); agents.add(agents.indexOf("org.eclipse.che.ws-agent"), "com.codenvy.rsync_in_machine"); extendedMachine.setAgents(agents); List<String> volumes = new ArrayList<>(devMachine.getVolumes()); volumes.add(projectFolder); devMachine.setVolumes(volumes); for (CheServiceImpl service : internalEnv.getServices().values()) { volumes = new ArrayList<>(service.getVolumes()); volumes.addAll( SNAPSHOT_EXCLUDED_DIRECTORIES); service.setVolumes(volumes); } super.provision(envConfig, internalEnv); }
CodenvyInContainerInfrastructureProvisioner extends DefaultInfrastructureProvisioner { @Override public void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv) throws EnvironmentException { String devMachineName = getDevMachineName(envConfig); if (devMachineName == null) { throw new EnvironmentException("ws-machine is not found on agents applying"); } CheServiceImpl devMachine = internalEnv.getServices().get(devMachineName); HashMap<String, String> environmentVars = new HashMap<>(devMachine.getEnvironment()); environmentVars.put(SYNC_KEY_ENV_VAR_NAME, pubSyncKey); environmentVars.put( CheBootstrap.CHE_LOCAL_CONF_DIR, DockerExtConfBindingProvider.EXT_CHE_LOCAL_CONF_DIR); devMachine.setEnvironment(environmentVars); ExtendedMachineImpl extendedMachine = envConfig.getMachines().get(devMachineName); List<String> agents = new ArrayList<>(extendedMachine.getAgents()); agents.add(agents.indexOf("org.eclipse.che.ws-agent"), "com.codenvy.rsync_in_machine"); extendedMachine.setAgents(agents); List<String> volumes = new ArrayList<>(devMachine.getVolumes()); volumes.add(projectFolder); devMachine.setVolumes(volumes); for (CheServiceImpl service : internalEnv.getServices().values()) { volumes = new ArrayList<>(service.getVolumes()); volumes.addAll( SNAPSHOT_EXCLUDED_DIRECTORIES); service.setVolumes(volumes); } super.provision(envConfig, internalEnv); } }
CodenvyInContainerInfrastructureProvisioner extends DefaultInfrastructureProvisioner { @Override public void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv) throws EnvironmentException { String devMachineName = getDevMachineName(envConfig); if (devMachineName == null) { throw new EnvironmentException("ws-machine is not found on agents applying"); } CheServiceImpl devMachine = internalEnv.getServices().get(devMachineName); HashMap<String, String> environmentVars = new HashMap<>(devMachine.getEnvironment()); environmentVars.put(SYNC_KEY_ENV_VAR_NAME, pubSyncKey); environmentVars.put( CheBootstrap.CHE_LOCAL_CONF_DIR, DockerExtConfBindingProvider.EXT_CHE_LOCAL_CONF_DIR); devMachine.setEnvironment(environmentVars); ExtendedMachineImpl extendedMachine = envConfig.getMachines().get(devMachineName); List<String> agents = new ArrayList<>(extendedMachine.getAgents()); agents.add(agents.indexOf("org.eclipse.che.ws-agent"), "com.codenvy.rsync_in_machine"); extendedMachine.setAgents(agents); List<String> volumes = new ArrayList<>(devMachine.getVolumes()); volumes.add(projectFolder); devMachine.setVolumes(volumes); for (CheServiceImpl service : internalEnv.getServices().values()) { volumes = new ArrayList<>(service.getVolumes()); volumes.addAll( SNAPSHOT_EXCLUDED_DIRECTORIES); service.setVolumes(volumes); } super.provision(envConfig, internalEnv); } @Inject  CodenvyInContainerInfrastructureProvisioner(
      AgentConfigApplier agentConfigApplier,
      @Named("workspace.backup.public_key") String pubSyncKey,
      @Named("che.workspace.projects.storage") String projectFolder); }
CodenvyInContainerInfrastructureProvisioner extends DefaultInfrastructureProvisioner { @Override public void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv) throws EnvironmentException { String devMachineName = getDevMachineName(envConfig); if (devMachineName == null) { throw new EnvironmentException("ws-machine is not found on agents applying"); } CheServiceImpl devMachine = internalEnv.getServices().get(devMachineName); HashMap<String, String> environmentVars = new HashMap<>(devMachine.getEnvironment()); environmentVars.put(SYNC_KEY_ENV_VAR_NAME, pubSyncKey); environmentVars.put( CheBootstrap.CHE_LOCAL_CONF_DIR, DockerExtConfBindingProvider.EXT_CHE_LOCAL_CONF_DIR); devMachine.setEnvironment(environmentVars); ExtendedMachineImpl extendedMachine = envConfig.getMachines().get(devMachineName); List<String> agents = new ArrayList<>(extendedMachine.getAgents()); agents.add(agents.indexOf("org.eclipse.che.ws-agent"), "com.codenvy.rsync_in_machine"); extendedMachine.setAgents(agents); List<String> volumes = new ArrayList<>(devMachine.getVolumes()); volumes.add(projectFolder); devMachine.setVolumes(volumes); for (CheServiceImpl service : internalEnv.getServices().values()) { volumes = new ArrayList<>(service.getVolumes()); volumes.addAll( SNAPSHOT_EXCLUDED_DIRECTORIES); service.setVolumes(volumes); } super.provision(envConfig, internalEnv); } @Inject  CodenvyInContainerInfrastructureProvisioner(
      AgentConfigApplier agentConfigApplier,
      @Named("workspace.backup.public_key") String pubSyncKey,
      @Named("che.workspace.projects.storage") String projectFolder); @Override void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv); @Override void provision(ExtendedMachineImpl machineConfig, CheServiceImpl internalMachine); }
CodenvyInContainerInfrastructureProvisioner extends DefaultInfrastructureProvisioner { @Override public void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv) throws EnvironmentException { String devMachineName = getDevMachineName(envConfig); if (devMachineName == null) { throw new EnvironmentException("ws-machine is not found on agents applying"); } CheServiceImpl devMachine = internalEnv.getServices().get(devMachineName); HashMap<String, String> environmentVars = new HashMap<>(devMachine.getEnvironment()); environmentVars.put(SYNC_KEY_ENV_VAR_NAME, pubSyncKey); environmentVars.put( CheBootstrap.CHE_LOCAL_CONF_DIR, DockerExtConfBindingProvider.EXT_CHE_LOCAL_CONF_DIR); devMachine.setEnvironment(environmentVars); ExtendedMachineImpl extendedMachine = envConfig.getMachines().get(devMachineName); List<String> agents = new ArrayList<>(extendedMachine.getAgents()); agents.add(agents.indexOf("org.eclipse.che.ws-agent"), "com.codenvy.rsync_in_machine"); extendedMachine.setAgents(agents); List<String> volumes = new ArrayList<>(devMachine.getVolumes()); volumes.add(projectFolder); devMachine.setVolumes(volumes); for (CheServiceImpl service : internalEnv.getServices().values()) { volumes = new ArrayList<>(service.getVolumes()); volumes.addAll( SNAPSHOT_EXCLUDED_DIRECTORIES); service.setVolumes(volumes); } super.provision(envConfig, internalEnv); } @Inject  CodenvyInContainerInfrastructureProvisioner(
      AgentConfigApplier agentConfigApplier,
      @Named("workspace.backup.public_key") String pubSyncKey,
      @Named("che.workspace.projects.storage") String projectFolder); @Override void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv); @Override void provision(ExtendedMachineImpl machineConfig, CheServiceImpl internalMachine); static final String SYNC_KEY_ENV_VAR_NAME; static final List<String> SNAPSHOT_EXCLUDED_DIRECTORIES; }