mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
fix some errCheck warnings, and update examples
- Explicitly suppress some unhandled errors - Use "pass" credentials helper in examples, which is available on more platforms than "secretservice" (only supporte on Linux) - Update domain and username in examples. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
+11
-11
@@ -92,16 +92,16 @@ func mockProgramFn(args ...string) Program {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExampleStore() {
|
func ExampleStore() {
|
||||||
p := NewShellProgramFunc("docker-credential-secretservice")
|
p := NewShellProgramFunc("docker-credential-pass")
|
||||||
|
|
||||||
c := &credentials.Credentials{
|
c := &credentials.Credentials{
|
||||||
ServerURL: "https://example.com",
|
ServerURL: "https://registry.example.com",
|
||||||
Username: "calavera",
|
Username: "exampleuser",
|
||||||
Secret: "my super secret token",
|
Secret: "my super secret token",
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := Store(p, c); err != nil {
|
if err := Store(p, c); err != nil {
|
||||||
fmt.Println(err)
|
_, _ = fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,14 +129,14 @@ func TestStore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExampleGet() {
|
func ExampleGet() {
|
||||||
p := NewShellProgramFunc("docker-credential-secretservice")
|
p := NewShellProgramFunc("docker-credential-pass")
|
||||||
|
|
||||||
creds, err := Get(p, "https://example.com")
|
creds, err := Get(p, "https://registry.example.com")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
_, _ = fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Got credentials for user `%s` in `%s`\n", creds.Username, creds.ServerURL)
|
_, _ = fmt.Printf("Got credentials for user `%s` in `%s`\n", creds.Username, creds.ServerURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
@@ -190,10 +190,10 @@ func TestGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExampleErase() {
|
func ExampleErase() {
|
||||||
p := NewShellProgramFunc("docker-credential-secretservice")
|
p := NewShellProgramFunc("docker-credential-pass")
|
||||||
|
|
||||||
if err := Erase(p, "https://example.com"); err != nil {
|
if err := Erase(p, "https://registry.example.com"); err != nil {
|
||||||
fmt.Println(err)
|
_, _ = fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func Serve(helper Helper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stdout, "%v\n", err)
|
_, _ = fmt.Fprintln(os.Stdout, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ func Get(helper Helper, reader io.Reader, writer io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprint(writer, buffer.String())
|
_, _ = fmt.Fprint(writer, buffer.String())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +181,6 @@ func List(helper Helper, writer io.Writer) error {
|
|||||||
|
|
||||||
// PrintVersion outputs the current version.
|
// PrintVersion outputs the current version.
|
||||||
func PrintVersion(writer io.Writer) error {
|
func PrintVersion(writer io.Writer) error {
|
||||||
fmt.Fprintf(writer, "%s (%s) %s\n", Name, Package, Version)
|
_, _ = fmt.Fprintf(writer, "%s (%s) %s\n", Name, Package, Version)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user