import os

import drone
import subprocess


def main():
    """The main entrypoint for the plugin."""
    payload = drone.plugin.get_input()
    vargs = payload["vargs"]

    # Required fields should raise an error
    url, key, secret = vargs['url'], vargs['access_key'], vargs['secret_key']

    # Optional fields
    compose_file = vargs.get('compose_file', 'docker-compose.yml')
    stack = vargs.get('stack', payload['repo']['name'])
    services = vargs.get('services', '')

    # Change directory
    deploy_path = payload["workspace"]["path"]
    os.chdir(deploy_path)

    rc_args = [
        "rancher-compose", "-f", compose_file, "-p", stack, "up", services,
    ]
    subprocess.call(rc_args)


if __name__ == "__main__":
    main()

import os

import drone
import subprocess


def main():
    """The main entrypoint for the plugin."""
    payload = drone.plugin.get_input()
    vargs = payload["vargs"]

    # Required fields should raise an error
    os.environ["RANCHER_URL"] = vargs['url']
    os.environ["RANCHER_ACCESS_KEY"] = vargs['access_key']
    os.environ["RANCHER_SECRET_KEY"] = vargs['secret_key']

    # Optional fields
    compose_file = vargs.get('compose_file', 'docker-compose.yml')
    stack = vargs.get('stack', payload['repo']['name'])
    services = vargs.get('services', '')

    # Change directory
    deploy_path = payload["workspace"]["path"]
    os.chdir(deploy_path)

    rc_args = [
        "rancher-compose", "-f", compose_file, "-p", stack, "up", services,
    ]
    subprocess.call(rc_args)


if __name__ == "__main__":
    main()

Set environmental vars for rancher-compose to work
Set environmental vars for rancher-compose to work

  import os
  
  import drone
  import subprocess
  
  
  def main():
      """The main entrypoint for the plugin."""
      payload = drone.plugin.get_input()
      vargs = payload["vargs"]
  
      # Required fields should raise an error
-     url, key, secret = vargs['url'], vargs['access_key'], vargs['secret_key']
+     os.environ["RANCHER_URL"] = vargs['url']
+     os.environ["RANCHER_ACCESS_KEY"] = vargs['access_key']
+     os.environ["RANCHER_SECRET_KEY"] = vargs['secret_key']
  
      # Optional fields
      compose_file = vargs.get('compose_file', 'docker-compose.yml')
      stack = vargs.get('stack', payload['repo']['name'])
      services = vargs.get('services', '')
  
      # Change directory
      deploy_path = payload["workspace"]["path"]
      os.chdir(deploy_path)
  
      rc_args = [
          "rancher-compose", "-f", compose_file, "-p", stack, "up", services,
      ]
      subprocess.call(rc_args)
  
  
  if __name__ == "__main__":
      main()
  
Set environmental vars for rancher-compose to work
## Code Before:
import os

import drone
import subprocess


def main():
    """The main entrypoint for the plugin."""
    payload = drone.plugin.get_input()
    vargs = payload["vargs"]

    # Required fields should raise an error
    url, key, secret = vargs['url'], vargs['access_key'], vargs['secret_key']

    # Optional fields
    compose_file = vargs.get('compose_file', 'docker-compose.yml')
    stack = vargs.get('stack', payload['repo']['name'])
    services = vargs.get('services', '')

    # Change directory
    deploy_path = payload["workspace"]["path"]
    os.chdir(deploy_path)

    rc_args = [
        "rancher-compose", "-f", compose_file, "-p", stack, "up", services,
    ]
    subprocess.call(rc_args)


if __name__ == "__main__":
    main()

## Instruction:
Set environmental vars for rancher-compose to work
## Code After:
import os

import drone
import subprocess


def main():
    """The main entrypoint for the plugin."""
    payload = drone.plugin.get_input()
    vargs = payload["vargs"]

    # Required fields should raise an error
    os.environ["RANCHER_URL"] = vargs['url']
    os.environ["RANCHER_ACCESS_KEY"] = vargs['access_key']
    os.environ["RANCHER_SECRET_KEY"] = vargs['secret_key']

    # Optional fields
    compose_file = vargs.get('compose_file', 'docker-compose.yml')
    stack = vargs.get('stack', payload['repo']['name'])
    services = vargs.get('services', '')

    # Change directory
    deploy_path = payload["workspace"]["path"]
    os.chdir(deploy_path)

    rc_args = [
        "rancher-compose", "-f", compose_file, "-p", stack, "up", services,
    ]
    subprocess.call(rc_args)


if __name__ == "__main__":
    main()
