From 9b365965c150e94f366702a4523aecc82d719e05 Mon Sep 17 00:00:00 2001
From: Gabriel Martinez <gabrielmartinez@sisti.pt>
Date: Wed, 21 Apr 2021 18:37:54 +0100
Subject: [PATCH] Add config input

Signed-off-by: Gabriel Martinez <gabrielmartinez@sisti.pt>
---
 README.md      | 1 +
 action.yml     | 3 +++
 dist/index.js  | 6 +++++-
 src/context.ts | 4 +++-
 src/main.ts    | 3 +++
 5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 1e41939..85f8500 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,7 @@ Following inputs can be used as `step.with` keys
 | `install`          | Bool    | Sets up `docker build` command as an alias to `docker buildx` (default `false`) |
 | `use`              | Bool    | Switch to this builder instance (default `true`) |
 | `endpoint`         | String  | [Optional address for docker socket](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#description) or context from `docker context ls` |
+| `config`           | String  | [Optional config file path](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#config) |
 
 > `CSV` type must be a newline-delimited string
 > ```yaml
diff --git a/action.yml b/action.yml
index f53d07a..e218e16 100644
--- a/action.yml
+++ b/action.yml
@@ -32,6 +32,9 @@ inputs:
   endpoint:
     description: 'Optional address for docker socket or context from `docker context ls`'
     required: false
+  config:
+    description: 'Optional config file path'
+    required: false
 
 outputs:
   name:
diff --git a/dist/index.js b/dist/index.js
index 4915a6f..987b31e 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -554,6 +554,9 @@ function run() {
                 if (inputs.endpoint) {
                     createArgs.push(inputs.endpoint);
                 }
+                if (inputs.config) {
+                    createArgs.push('--config', inputs.config);
+                }
                 yield exec.exec('docker', createArgs);
                 core.endGroup();
                 core.startGroup(`Booting builder`);
@@ -8023,7 +8026,8 @@ function getInputs() {
                 '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
             install: /true/i.test(core.getInput('install')),
             use: /true/i.test(core.getInput('use')),
-            endpoint: core.getInput('endpoint')
+            endpoint: core.getInput('endpoint'),
+            config: core.getInput('config')
         };
     });
 }
diff --git a/src/context.ts b/src/context.ts
index f56e1ad..daa8fe1 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -12,6 +12,7 @@ export interface Inputs {
   install: boolean;
   use: boolean;
   endpoint: string;
+  config: string;
 }
 
 export async function getInputs(): Promise<Inputs> {
@@ -24,7 +25,8 @@ export async function getInputs(): Promise<Inputs> {
       '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
     install: /true/i.test(core.getInput('install')),
     use: /true/i.test(core.getInput('use')),
-    endpoint: core.getInput('endpoint')
+    endpoint: core.getInput('endpoint'),
+    config: core.getInput('config')
   };
 }
 
diff --git a/src/main.ts b/src/main.ts
index 560524c..6427c1c 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -48,6 +48,9 @@ async function run(): Promise<void> {
       if (inputs.endpoint) {
         createArgs.push(inputs.endpoint);
       }
+      if (inputs.config) {
+        createArgs.push('--config', inputs.config);
+      }
       await exec.exec('docker', createArgs);
       core.endGroup();