message: 92 - also need to get data about the environment from the API
diff: @@ -49,6 +49,13 @@ class ProjectNotFound extends Error {
  }
  }
  +class EnvironmentNotFound extends Error {
  + constructor(message: string) {
  + super(message);
  + this.name = 'EnvironmentNotFound';
  + }
  +}
  +
  class NoActiveSystemsDefined extends Error {
  constructor(message: string) {
  super(message);
  @@ -162,6 +169,34 @@ async function getActiveSystemForProject(
  return result.project;
  }
  +async function getEnvironmentByName(
  + name: string,
  + projectId: number
  +): Promise<Project[]> {
  + const result = await graphqlapi.query(`
  + {
  + environmentByName(name: "${name}",project:${projectId}) {
  + id,
  + name,
  + lagoon_route,
  + lagoon_routes,
  + deploy_type,
  + environment_type,
  + openshift_projectname,
  + updated,
  + created,
  + deleted,
  + }
  + }
  + `);
  +
  + if (!result || !result.environmentByName) {
  + throw new EnvironmentNotFound(`Cannot find environment for projectId ${projectId}, name ${name}\n${result.environmentByName}`);
  + }
  +
  + return result;
  +}
  +
  const addOrUpdateEnvironment = (
  name: string,
  projectId: number,
  