-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat add cli option to add credentials files #5900
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
afdd91b
to
cae4b78
Compare
@tonistiigi @AkihiroSuda |
if err != nil { | ||
return nil, errors.Wrap(err, "parsing file descriptor") | ||
} | ||
f := os.NewFile(uintptr(fd), "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does go throw an error here if the file descriptor is above the OS limit (e.g. /proc/sys/fs/file-max
or ulimit
on Linux)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the open call will fail if it is more than the limit. The newfile itself doesnt throw error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no open if it is a fd. read(2)
would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fd is from a open file that is getting inherrited as a child process. if the fd is not inherited it would fail from what i tested which makes sense to me for the use case i am trying.
Do you suggest i check if the fd is valid and open already? @tonistiigi
if err := configFile.LoadFromReader(f); err != nil { | ||
return nil, errors.Wrap(err, fmt.Sprintf("loading config file %s", path)) | ||
} | ||
case strings.HasPrefix(path, "pipe://"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this work with Windows pipes? I think they start with \\.\pipe\
typically, but I'm not sure if they're opened like a regular file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not very familiar with using windows pipe, if there is a specific requirement we can implement but at the moment i dont know if we do require it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db09cc6
to
7626804
Compare
if err := configFile.LoadFromReader(f); err != nil { | ||
return nil, errors.Wrapf(err, "loading config file %s", path) | ||
} | ||
case strings.HasPrefix(path, "pipe://"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux, pipe:// is probably unneeded and can be just treated in the same way as a regular file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was more of a logical entry to differentiate, can remove it.
if path == "" { | ||
return nil, fmt.Errorf("credential file path empty") | ||
} | ||
configFile := configfile.New("config-file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit scary. There are functions like configFile.Save()
that would now write out actual file to this path.
Maybe it would make sense for DockerAuthProviderConfig
to take a limited interface that just implements GetAuthConfig(registry)
instead? @AkihiroSuda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does buildkit write back credentials to this file? or its more of a concern with it is possible to write back to the path and as such is a risk itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more of a concern that we pass full configfile to another component, so we can't really control what methods it is allowed to call. We are passing configfile, but it isn't actually a valid file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case when the further component call it to write it would fail i suppose which is not ideal but is it a risk though as the config file if its a fd then it needs to be called as a child process or else it wont be valid. For pipes it is more tricky i suppose as they can be passed independently.
@tonistiigi @AkihiroSuda
if err != nil { | ||
return nil, errors.Wrap(err, "parsing file descriptor") | ||
} | ||
f := os.NewFile(uintptr(fd), "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no open if it is a fd. read(2)
would fail.
if err := configFile.LoadFromReader(f); err != nil { | ||
return nil, errors.Wrap(err, fmt.Sprintf("loading config file %s", path)) | ||
} | ||
case strings.HasPrefix(path, "pipe://"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonistiigi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter is failing, and I would still prefer to not pass the whole (fake) configfile.
When we say pass the whole configfile are we stating the whole configfile struct into DockerAuthProvider and any component that uses DockerAuthProviderConfig has access to this configfile and we cannot control the use of it? |
7626804
to
955346e
Compare
955346e
to
1227ab0
Compare
@tonistiigi @AkihiroSuda |
@@ -32,6 +31,11 @@ import ( | |||
"google.golang.org/grpc/status" | |||
) | |||
|
|||
// ConfigFile Interface exposes GetAuthConfig method. | |||
type ConfigFile interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AuthConfigProvider
cmd/buildctl/build.go
Outdated
return err | ||
} | ||
|
||
func processCredentialConfigFile(path string) (*configfile.ConfigFile, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return the interface type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks changed it.
1227ab0
to
af008c4
Compare
Signed-off-by: Shubharanshu Mahapatra <shubhum@amazon.com>
af008c4
to
81c1d5b
Compare
Description
Add a cli option to pass in credential config file path. This will override DOCKER_CONFIG path used to fetch credential. You can pass a file path or a file descriptor("fd://") or a pipe("pipe://")
Use case:
This will allow clients to configure the cred config location of the buildctl and pass in credentials via file descriptors and pipes as well if they dont want to write it to disk.
Related to issue: #5860