Commit Graph

11 Commits

Author SHA1 Message Date
Taylor Blau
552b955b3f all: expand config.Environment interface to support multiple values per key 2017-04-12 17:29:11 -04:00
risk danger olson
2e213cf9c4 config: remove env mutation funcs, no longer needed! 2017-01-10 13:25:03 -07:00
risk danger olson
1715e97f41 add export comments 2016-11-10 11:24:45 -07:00
risk danger olson
b694d64f12 make set() and del() private 2016-11-10 11:16:46 -07:00
risk danger olson
0e679c7d98 add Set(), remove .gitConfig 2016-11-09 17:46:52 -07:00
risk danger olson
e2ca1e5533 add Environment Del(key string) 2016-11-09 17:37:14 -07:00
risk danger olson
9c46443baf remove AllGitConfig() 2016-11-09 17:33:43 -07:00
Taylor Blau
6c60d2b2db config: demote *Environment to interface
In order to support lazily loading the values stored in a user's `.gitconfig`,
we must wait until calling `*config.Configuration.loadGitConfig()` until it is
_absolutely necessary_.

To accomplish this, it was proposed that we introduce a wrapped variant of the
`*Environment` type, only for interacting with the `GitFetcher` that was
capable of supporting such beahvior.

As such, a new implementation of the `Environment` type must be defined. Since
previously there only existed the concrete type `*Environment`, this commit
demotes that down to `*enviornment`, and introduces the interface
`Environment`, which it implements.
2016-08-15 13:17:11 -06:00
risk danger olson
7bcc69bf58 change c.GitConfigInt() and c.GitConfigBool() to use c.Git 2016-08-05 16:31:39 -06:00
risk danger olson
9c727d210c change (Environment) Get()'s signature to include ok bool 2016-08-05 15:59:57 -06:00
Taylor Blau
18cb9257f9 config: demote Fetcher, introduce Environment
Previously, to fetch data out of the `*config.Configuration` type, a reference
to a `Fetcher` was used, a-la:

```
cfg.Env.Get(...)
```

This is quite convenient, however, it forces the LFS client to implement
several methods more than once. Consider the interface:

```
type Fetcher interface {
        Get(key string) (val string)

        Bool(key string, def bool) (val bool)
        // et. al.
}
```

In order to return typed information from a configuration instance, _each_
`Fetcher` must implement its own `N` methods for `Int`, `Bool`, etc.

To remedy this, the `Environment` type was introduced. It instead _has_ a
`Fetcher`, and defines its own type conversions, like so:

```
type Environment struct {
        f Fetcher
}

func (e *Environment) Bool(key string, def bool) (val bool) { }
func (e *Environment) Int(key string, def int)   (val int) { }

// et. al.
```

Now, the `config.Configuration` type holds a reference to an `Environment`, and
all type conversion methods are defined only once, saving time, and enforcing
consistency across multiple sources.
2016-08-04 14:28:19 -06:00