...

Source file src/golang.conradwood.net/go-easyops/http/creds.go

Documentation: golang.conradwood.net/go-easyops/http

     1  package http
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type creds struct {
     8  	username string
     9  	password string
    10  }
    11  
    12  type cred_producer struct {
    13  	host        string
    14  	known_creds []*creds
    15  	used        int
    16  }
    17  
    18  func (c *cred_producer) AddUsernamePassword(username, password string) {
    19  	cr := &creds{username: username, password: password}
    20  	c.known_creds = append([]*creds{cr}, c.known_creds...)
    21  }
    22  func (c *cred_producer) getNetRC() *creds {
    23  	if *debug {
    24  		fmt.Printf("Getting netrc for host \"%s\"\n", c.host)
    25  	}
    26  	cr := &creds{username: "foo", password: "bar"}
    27  	return cr
    28  }
    29  func (c *cred_producer) GetCredentials() *creds {
    30  	if c.used == len(c.known_creds) {
    31  		c.used++
    32  		//return c.getNetRC()
    33  		return nil
    34  	}
    35  	if c.used > len(c.known_creds) {
    36  		return nil
    37  	}
    38  	res := c.known_creds[c.used]
    39  	c.used++
    40  	return res
    41  }
    42  

View as plain text