Commit 09adbbb2 authored by Kamil Trzciński's avatar Kamil Trzciński 🔴

Merge branch 'allow-file-variables-from-network' into 'master'

Allow network-sourced variables to specify that they should be files

## What does this MR do?

Adds an optional boolean attribute - `file` - to the `GetBuildResponse` variables. This causes the value of the variable to be written to a temporary file, and path to the file to be set as the value of the variable.

## Why was this MR needed? wishes to introduce a `KUBE_CA_PEM` variable that should be a file on disc, rather than a newline-packed environment variable. `ca.pem` files from elsewhere are also written to disc in the same manner, but these variables are sourced from within the runner itself.

## Are there points in the code the reviewer needs to double check?

## Does this MR meet the acceptance criteria?

- [ ] Documentation created/updated (should be added to gitlab-ce instead)
- Tests
  - [X] Added for this feature/bug
  - [x] All builds are passing
- [X] Branch has no merge conflicts with `master` (if you do - rebase it please)

## What are the relevant issue numbers?

See merge request !413
parents 57a0a9ce a3466134
......@@ -12,7 +12,7 @@ type BuildVariable struct {
Value string `json:"value"`
Public bool `json:"public"`
Internal bool `json:"-"`
File bool `json:"-"`
File bool `json:"file"`
type BuildVariables []BuildVariable
package common
import (
func TestVariablesJSON(t *testing.T) {
var x BuildVariable
data := []byte(`{"key": "FOO", "value": "bar", "public": true, "internal": true, "file": true}`)
err := json.Unmarshal(data, &x)
assert.NoError(t, err)
assert.Equal(t, x.Key, "FOO")
assert.Equal(t, x.Value, "bar")
assert.Equal(t, x.Public, true)
assert.Equal(t, x.Internal, false) // cannot be set from the network
assert.Equal(t, x.File, true)
func TestVariableString(t *testing.T) {
v := BuildVariable{"key", "value", false, false, false}
assert.Equal(t, "key=value", v.String())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment