Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiple search repositories
Up until now, whalebrew restricts its searches to https://hub.docker.com/u/whalebrew This commit introduces the ability to customize search organization under docker hub. To customize it, place a file like ``` registries: - dockerHub: owner: whalebrew ``` You can add as many search repositories as desired, all of them will be searched. Currently, there is no authentication to the search repositories. Only public images will be retrieved. A step forward for whaleebrew tap discussed in #102
- Loading branch information
Showing
2 changed files
with
66 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package config | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/viper" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type DockerHubRegistry struct { | ||
Owner string `yaml:"owner"` | ||
} | ||
|
||
type Registry struct { | ||
DockerHub *DockerHubRegistry `yaml:"dockerHub"` | ||
} | ||
|
||
type Config struct { | ||
Registries []Registry `yaml:"registries"` | ||
} | ||
|
||
func GetConfig() Config { | ||
configPath := filepath.Join(viper.GetString("config_dir"), "config.yaml") | ||
fd, err := os.Open(configPath) | ||
c := Config{} | ||
if err == nil { | ||
defer fd.Close() | ||
yaml.NewDecoder(fd).Decode(&c) | ||
} | ||
if len(c.Registries) == 0 { | ||
c.Registries = []Registry{{DockerHub: &DockerHubRegistry{Owner: "whalebrew"}}} | ||
} | ||
return c | ||
} |