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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples how to use container.files parameter. #922

Open
bkielbasa opened this issue Apr 26, 2021 · 1 comment
Open

More examples how to use container.files parameter. #922

bkielbasa opened this issue Apr 26, 2021 · 1 comment

Comments

@bkielbasa
Copy link

馃摎 Documentation

The documentation for specific items in the spec is very poor it makes using opctl much harder. An example I can give is files parameter. An example of using it is here: https://opctl.io/docs/training/inputs-outputs

but... I couldn't find any example where I can copy a file to a container. The example above shows how we can put text into it but not copy a file inside. Here's what I tried but nothing succeeded

    files:
      /root/.netrc: $(/src/netrc)

    files:
      /root/.netrc: /src/netrc

etc

@gunnarg-remitly
Copy link
Contributor

The documentation definitely needs work, particularly around tutorials and recipes.

In this case, here's an example op that passes a file in:

name: example
description: an example op
inputs:
    example-input:
        file:
            default: ./optest
run:
    container:
        image: { ref: 'alpine' }
        cmd: ['echo', $(example-input)]

I suggest making a test directory, adding a .opspec directory to the test directory, adding and example directory, and adding the above op as op.yml in the example directory.

mkdir opctl-test
mkdir opctl-test/.opspec
mkdir opctl-test/.opspec/example
touch opctl-test/.opspec/example/op.yml
# paste the example op into ^ this file
echo hello world > optest
opctl run example

It'll load the file and the op will echo "hello world" to the command line.

If you want an op to have access to a file as a thing, then I suggest passing in the directory containing the file:

name: example
description: an example op
inputs:
    example-input:
        dir:
            default: ./
run:
    container:
        image: { ref: 'alpine' }
        cmd: ["ls", "/example-input"]
        dirs:
            /example-input: $(example-input)

if you use the directory created for the previous example, then create a new op (example-directory, for instance), running opctl run example-directory should produce the optest file that was created earlier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants