-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver: add support for credentials helper and static file auth config
This PR adds support for specifying an external credentials helper and/ or an external "auth.json" credentials file. The plugin configuration now has an "auth" block with fields "helper" and "config" (similar to the docker driver). We also now have an "auth_soft_fail" option in Task config for cases where someone has configured the auth block in plugin config, but has a task that is using a public image with no credentials. In that case setting auth_soft_fail is used to ignore the fact that no credentials will be found for the given public image. (This is also how the docker driver works, I didn't come up with this). Unlike the docker driver, the podman driver still does not support specifying a credentials helper _in_ the external "auth.json" credentials file. If there is demand for that use case we can add it, but in the short term it seems like just the plugin's support for specifying a credentials helper could be sufficient. And it's a lot of code to do the other thing.
- Loading branch information
Showing
15 changed files
with
721 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package registry | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/shoenig/test/must" | ||
) | ||
|
||
func TestPullConfig_NoAuth(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
pc *PullConfig | ||
exp bool | ||
}{ | ||
{ | ||
name: "task config", | ||
pc: &PullConfig{ | ||
RegistryConfig: &RegistryAuthConfig{ | ||
Username: "user", | ||
Password: "pass", | ||
}, | ||
}, | ||
exp: true, | ||
}, | ||
{ | ||
name: "creds helper", | ||
pc: &PullConfig{ | ||
CredentialsHelper: "helper.sh", | ||
}, | ||
exp: true, | ||
}, | ||
{ | ||
name: "creds file", | ||
pc: &PullConfig{ | ||
CredentialsFile: "auth.json", | ||
}, | ||
exp: true, | ||
}, | ||
{ | ||
name: "none", | ||
pc: &PullConfig{}, | ||
exp: false, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result := tc.pc.AuthAvailable() | ||
must.Eq(t, tc.exp, result) | ||
}) | ||
} | ||
} |
Oops, something went wrong.