Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users should only be able to push from the current folder #523

Closed
lucasfcosta opened this issue Jun 7, 2022 · 3 comments
Closed

Users should only be able to push from the current folder #523

lucasfcosta opened this issue Jun 7, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@lucasfcosta
Copy link
Contributor

lucasfcosta commented Jun 7, 2022

Summary

When using push, the agent will use the cwd as the path from which it will read a configuration file.

That behaviour is problematic because if the user is using the agent to push journeys from a different target folder, they'll read the incorrect configuration file (or none), not the configuration in the target folder.

Therefore, we have decided that we will only allow pushing from the current working directory. That eliminates the confusion people could have if they were pushing multiple different folders (wondering which config would be used for each).

How to reproduce

  1. Create a Synthetics project using the init command
  2. Update config file in the new folder created by init, changing its schedule
     import type { SyntheticsConfig } from '@elastic/synthetics';
    
     export default env => {
       const config: SyntheticsConfig = {
         params: {
           url: 'https://elastic.github.io/synthetics-demo/',
         },
         playwrightOptions: {
           ignoreHTTPSErrors: false,
         },
         /**
          * Configure global monitor settings
          */
         monitor: {
           schedule: 25,
           locations: ["brazil"],
         },
       };
       if (env !== 'development') {
         /**
          * Override configuration specific to environment
          * Ex: config.params.url = ""
          */
       }
       return config;
     };
  3. Copy this config file to /tmp and change the schedule's value to something else, like 50, for example.
  4. Navigate (cd) into /tmp and run the push command from there, specifying the other directory (the one you created with init)
  5. You'll see the monitors get created with the schedule from /tmp, not the one within the target folder's config file.

The desired behaviour is to always use cwd and not allow a path to be passed, as we discussed on Slack.

@lucasfcosta lucasfcosta added the bug Something isn't working label Jun 7, 2022
@lucasfcosta lucasfcosta self-assigned this Jun 7, 2022
@lucasfcosta lucasfcosta changed the title Push command fetches configurations from CWD, not the target folder Users should only be able to push from the current folder Jun 9, 2022
@lucasfcosta
Copy link
Contributor Author

I have repurposed this issue to reflect our discussions on Slack.

@shahzad31
Copy link
Contributor

Push command works without following error now

errors: [
    {
      detail: [Error],
      id: '',
      location: null,
      notes: [Array],
      pluginName: 'esbuild-multiasset-plugin',
      text: "ENOENT: no such file or directory, open '/Users/shahzad-16/elastic/synthetics/examples/todos/file:/Users/shahzad-16/elastic/synthetics/examples/todos/basic.journey.ts'"
    }
  ],

@lucasfcosta
Copy link
Contributor Author

@shahzad31 that's a different error. It's fixed by the PR #521. Can you please make sure both the target package you're pushing and this PR are tested with the latest versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants