1
0
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:
Sebastiaan van Stijn
2023-05-28 12:33:58 +02:00
parent 94483d2d23
commit 19557f8fff
2 changed files with 14 additions and 14 deletions
+11 -11
View File
@@ -92,16 +92,16 @@ func mockProgramFn(args ...string) Program {
}
func ExampleStore() {
p := NewShellProgramFunc("docker-credential-secretservice")
p := NewShellProgramFunc("docker-credential-pass")
c := &credentials.Credentials{
ServerURL: "https://example.com",
Username: "calavera",
ServerURL: "https://registry.example.com",
Username: "exampleuser",
Secret: "my super secret token",
}
if err := Store(p, c); err != nil {
fmt.Println(err)
_, _ = fmt.Println(err)
}
}
@@ -129,14 +129,14 @@ func TestStore(t *testing.T) {
}
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 {
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) {
@@ -190,10 +190,10 @@ func TestGet(t *testing.T) {
}
func ExampleErase() {
p := NewShellProgramFunc("docker-credential-secretservice")
p := NewShellProgramFunc("docker-credential-pass")
if err := Erase(p, "https://example.com"); err != nil {
fmt.Println(err)
if err := Erase(p, "https://registry.example.com"); err != nil {
_, _ = fmt.Println(err)
}
}
+3 -3
View File
@@ -59,7 +59,7 @@ func Serve(helper Helper) {
}
if err != nil {
fmt.Fprintf(os.Stdout, "%v\n", err)
_, _ = fmt.Fprintln(os.Stdout, err)
os.Exit(1)
}
}
@@ -143,7 +143,7 @@ func Get(helper Helper, reader io.Reader, writer io.Writer) error {
return err
}
fmt.Fprint(writer, buffer.String())
_, _ = fmt.Fprint(writer, buffer.String())
return nil
}
@@ -181,6 +181,6 @@ func List(helper Helper, writer io.Writer) error {
// PrintVersion outputs the current version.
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
}