@Override
  public Result execute(UIExecutionContext context) throws Exception {
    LOG.info("Creating the fabric8.yml file");

    String fileName = ProjectConfigs.FILE_NAME;
    Project project = getSelectedProject(context);
    File configFile = getProjectConfigFile(context.getUIContext(), getSelectedProject(context));
    if (configFile == null) {
      // lets not fail as we typically want to execute SaveDevOpsStep next...
      return Results.success();
    }
    ProjectConfig config = null;
    boolean hasFile = false;
    if (configFile.exists()) {
      config = ProjectConfigs.parseProjectConfig(configFile);
      hasFile = true;
    }
    if (config == null) {
      config = new ProjectConfig();
    }

    CommandHelpers.putComponentValuesInAttributeMap(context, inputComponents);
    updateConfiguration(context, config);
    LOG.info("Result: " + config);

    String message;
    if (config.isEmpty() && !hasFile) {
      message = "No " + fileName + " need be generated as there is no configuration";
      return Results.success(message);
    } else {
      String operation = "Updated";
      if (!configFile.exists()) {
        operation = "Created";
      }
      ProjectConfigs.saveConfig(config, configFile);
      message = operation + " " + fileName;
    }

    // now lets update the devops stuff
    UIContext uiContext = context.getUIContext();
    Map<Object, Object> attributeMap = uiContext.getAttributeMap();

    String gitUrl = getStringAttribute(attributeMap, "gitUrl");
    if (Strings.isNullOrBlank(gitUrl)) {
      gitUrl = getStringAttribute(attributeMap, "gitAddress");
    }

    Object object = attributeMap.get(Project.class);
    String user = getStringAttribute(attributeMap, "gitUser");
    String named = getStringAttribute(attributeMap, "projectName");
    ;
    File basedir = CommandHelpers.getBaseDir(project);
    if (basedir == null && configFile != null) {
      basedir = configFile.getParentFile();
    }

    if (object instanceof Project) {
      Project newProject = (Project) object;
      MetadataFacet facet = newProject.getFacet(MetadataFacet.class);
      if (facet != null) {
        if (Strings.isNullOrBlank(named)) {
          named = facet.getProjectName();
        }
        if (Strings.isNullOrBlank(gitUrl)) {
          String address = getStringAttribute(attributeMap, "gitAddress");
          gitUrl = address + user + "/" + named + ".git";
        }
      } else {
        LOG.error("No MetadataFacet for newly created project " + newProject);
      }
    } else {
      // updating an existing project - so lets try find the git url from the current source code
      if (Strings.isNullOrBlank(gitUrl)) {
        gitUrl = GitHelpers.extractGitUrl(basedir);
      }
      if (basedir != null) {
        if (Strings.isNullOrBlank(named)) {
          named = basedir.getName();
        }
      }
    }
    // lets default the environments from the pipeline
    PipelineDTO pipelineValue = pipeline.getValue();
    LOG.info("Using pipeline " + pipelineValue);
    String buildName = config.getBuildName();
    if (Strings.isNotBlank(buildName)) {
      if (pipelineValue != null) {
        List<String> environments = pipelineValue.getEnvironments();
        if (environments == null) {
          environments = new ArrayList<>();
        }
        LinkedHashMap<String, String> environmentMap = new LinkedHashMap<>();
        if (environments.isEmpty()) {
          environmentMap.put("Current", namespace);
        } else {
          for (String environment : environments) {
            String envNamespace = namespace + "-" + environment.toLowerCase();
            environmentMap.put(environment, envNamespace);
          }
        }
        config.setEnvironments(environmentMap);
      }
    }
    LOG.info("Configured project " + buildName + " environments: " + config.getEnvironments());
    ProjectConfigs.defaultEnvironments(config, namespace);

    String projectName = config.getBuildName();
    if (Strings.isNullOrBlank(projectName)) {
      projectName = named;
      config.setBuildName(projectName);
    }

    LOG.info("Project name is: " + projectName);
    if (Strings.isNotBlank(projectName) && project != null) {
      MavenFacet maven = project.getFacet(MavenFacet.class);
      Model pom = maven.getModel();
      if (pom != null
          && !isFunktionParentPom(project)
          && !isFabric8MavenPlugin3OrGreater(project)) {
        Properties properties = pom.getProperties();
        boolean updated = false;
        updated =
            MavenHelpers.updatePomProperty(
                properties, "fabric8.label.project", projectName, updated);
        updated =
            MavenHelpers.updatePomProperty(
                properties, "fabric8.label.version", "${project.version}", updated);
        if (updated) {
          LOG.info("Updating pom.xml properties!");
          maven.setModel(pom);
        } else {
          LOG.warn("Did not update pom.xml properties!");
        }
      } else {
        LOG.warn("No pom.xml found!");
      }
    }

    Boolean copyFlowToProjectValue = copyPipelineToProject.getValue();
    if (copyFlowToProjectValue != null && copyFlowToProjectValue.booleanValue()) {
      if (basedir == null || !basedir.isDirectory()) {
        LOG.warn("Cannot copy the pipeline to the project as no basedir!");
      } else {
        String flow = null;
        PipelineDTO pipelineDTO = pipelineValue;
        if (pipelineDTO != null) {
          flow = pipelineDTO.getValue();
        }
        if (Strings.isNullOrBlank(flow)) {
          LOG.warn("Cannot copy the pipeline to the project as no pipeline selected!");
        } else {
          String flowText = getFlowContent(flow, uiContext);
          if (Strings.isNullOrBlank(flowText)) {
            LOG.warn(
                "Cannot copy the pipeline to the project as no pipeline text could be loaded!");
          } else {
            flowText = Strings.replaceAllWithoutRegex(flowText, "GIT_URL", "'" + gitUrl + "'");
            File newFile = new File(basedir, ProjectConfigs.LOCAL_FLOW_FILE_NAME);
            Files.writeToFile(newFile, flowText.getBytes());
            LOG.info("Written pipeline to " + newFile);
            if (config != null) {
              config.setPipeline(null);
              config.setUseLocalFlow(true);
            }
          }
        }
      }
    }

    final DevOpsConnector connector = new DevOpsConnector();
    connector.setProjectConfig(config);
    connector.setTryLoadConfigFileFromRemoteGit(false);
    connector.setUsername(user);
    connector.setPassword(getStringAttribute(attributeMap, "gitPassword"));
    connector.setBranch(getStringAttribute(attributeMap, "gitBranch", "master"));
    connector.setBasedir(basedir);
    connector.setGitUrl(gitUrl);
    connector.setRepoName(named);

    connector.setRegisterWebHooks(true);

    // lets not trigger the jenkins webhook yet as the git push should trigger the build
    connector.setTriggerJenkinsJob(false);

    LOG.info("Using connector: " + connector);

    /*
            attributeMap.put("registerWebHooks", new Runnable() {
                @Override
                public void run() {
                    LOG.info("Now registering webhooks!");
                    connector.registerWebHooks();
                }
            });
    */
    try {
      connector.execute();
    } catch (Exception e) {
      LOG.error("Failed to update DevOps resources: " + e, e);
    }

    return Results.success(message);
  }