-
Notifications
You must be signed in to change notification settings - Fork 385
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
[RFC] remove .docker/config.json parsing #41
Conversation
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
How about, instead (per conversation in containers/skopeo#106 ): type SystemContext struct {
HomeDir string // "" = use the real home directory
DockerConfiguration *SomeDockerStruct // nil = read from the users’ or system configuration
OpenshiftConfiguration *SomeOpenshiftStruct
// the two existing params
InsecureDisableTLSVerification bool // except flipping the default to be secure
CAPath string // "" = use system defaults
// etc. for other transports
// Perhaps also
DisableReadingAnyOutsideState bool
// to allow writing reliably-standalone users?
} instead, and passing that to |
Been looking at this today, so, I agree we should have a type-safe way of passing around options - not sure anymore about the name |
Dunno. Vaguely I think that unless they get really unwieldy, function arguments should be function arguments and not members of a struct [OTOH I have done the exact opposite in https://github.com/containers/image/blob/master/signature/signature.go#L170 , to get readable parameter names; I kind of think that this is an exception, with too many similarly-typed parameters in a critical place].
That said, I don’t like the |
… on second thought, if the concept makes sense, and is well documented, I ultimately care very little about the actual name. |
Why not something like |
because we'd like to differentiate a context from the underlying system and a context in where there are only stuff related to images (at which point the latter can be just an argument, no need for a struct) |
@mtrmac the thing with all of this is in Golang (and the way I always implemented those concepts) - arguments are actually needed for a function, while an option struct is, as it seems, a box carrying arguments which may or may not be used by the function.
so |
@mtrmac what about playing with interface and trying to standardize most of the common stuff - I don't really like 83 type AuthConfig struct {
84 Username string
85 Password string
86 Auth string
87 ServerAddress string
88 // IdentityToken is used to authenticate the user and get
89 // an access token for the registry.
90 IdentityToken string
91 // RegistryToken is a bearer token to be sent to a registry
92 RegistryToken string
93 }
94
95 type TLSParams struct {
96 InsecureDisableTLSVerification bool
97 CAPath string
98 }
99
100 type ImageContext interface {
101 GetAuth() AuthConfig
102 GetTLSParams() TLSParams
103 DisableReadingSystemState() bool
104 } What if any specific reference is implementing his own context struct and that it's passed to |
Good point, Go has neither optionals nor named params…
The trouble with this is that the semantics are not common (how do I use an (Yes, this makes it difficult to implement Ultimately, the
Why make this an interface? Just filling a |
I think there is a semantic difference between “this is the identity of the image” ( That would suggest that OTOH, the way I guess I’d prefer trying to preserve the current “primarily rely on environment defaults” approach for most uses, it is nice and clean and simple to understand; and have the options/context only used for comparatively rare cases like unit tests or perhaps explicit overrides, and only to the extent we actually need any individual field. |
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is the API most applications should use to get the policy for the current host. Also adds a types.SystemContext per discussions in containers/image#41 and elsewhere, to make the functions testable and usable in special situations like chroots. (Though, signature.DefaultPolicy() with an override is not that different from signature.NewPolicyFromFile().) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This patch removes the parsing and credential retrieval from
~/.docker/config.json
.Eventually I'll move the actual json parsing in skopeo according to containers/skopeo#106.
containers/image
shouldn't depend nor rely on docker being installed on the system where we are actually running it. Higher level tooling should instead take care of this and the library should just accepts username/password to later attempt an authentication against a registry.This work is being done as part of kubernetes/kubernetes#25899 and https://github.com/mrunalp/ocid because we don't expect to have any docker daemon installed in the kubelet. /cc @mrunalp
@mtrmac I'm not sure username and password being passed as arguments is good. Eventually I'd expect to have an Auth struct containing useful information about authenticating against a given registry (see https://github.com/kubernetes/kubernetes/pull/25899/files#diff-b99b84f6471ccf2077dedc93530a51a2R401).
@mtrmac That said, if you have any better suggestion on how to achieve this w/o requiring a long list of arguments, I'll rework this patch. Right now, it's just taking username and password because those were what
getAuth
was actually providing.@mtrmac I've also thought about having a generic connection option struct to be passed to
NewImage...
methods so that we don't break any function definition in the future when adding other options.The ocid part will then receive an AuthConfig struct from the Kubelet Runtime API and we'll pass those info down to containers/image to do pull and push. See https://github.com/mrunalp/ocid/blob/master/vendor/github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime/api.pb.go#L2130 for instance.
Lastly as said, the config.json parsing will be moved to skopeo (which is where, IMO, it belongs as a mean to integrate better with the host running skopeo; skopeo also has --username and --password flag which are used to override the whole parsing or to ignore the fact that the underlying host has docker installed)
Note: tests against skopeo are rightly failing - containers/image tests pass instead
Signed-off-by: Antonio Murdaca runcom@redhat.com