generated from octomation/go-service
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
539 additions
and
292 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,128 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"regexp" | ||
|
||
"github.com/BurntSushi/toml" | ||
"go.octolab.org/safe" | ||
"go.octolab.org/unsafe" | ||
) | ||
|
||
func Load(name string) (Config, error) { | ||
cnf := defaults() | ||
|
||
f, err := os.Open(name) | ||
if err != nil { | ||
return cnf, err | ||
} | ||
defer safe.Close(f, unsafe.Ignore) | ||
|
||
if _, err := toml.NewDecoder(f).Decode(&cnf); err != nil { | ||
return cnf, err | ||
} | ||
return cnf, cnf.Index() | ||
} | ||
|
||
type Config struct { | ||
GitHub struct { | ||
Affiliation []string `toml:"affiliation"` | ||
Tags []string `toml:"tags"` | ||
Readme string `toml:"readme"` | ||
Limit int `toml:"limit"` | ||
|
||
Canonical []struct { | ||
Name string `toml:"name"` | ||
Real string `toml:"real"` | ||
} `toml:"canonical"` | ||
canonicals map[string]string | ||
|
||
Aliases []struct { | ||
SSH string `toml:"ssh"` | ||
Aliases []string `toml:"aliases"` | ||
} `toml:"aliases"` | ||
aliases map[string][]string | ||
|
||
Include struct { | ||
List []string `toml:"list"` | ||
list map[string]struct{} | ||
} `toml:"include"` | ||
|
||
Exclude struct { | ||
List []string `toml:"list"` | ||
list map[string]struct{} | ||
|
||
Patterns []string `toml:"patterns"` | ||
patterns []*regexp.Regexp | ||
} `toml:"exclude"` | ||
} `toml:"github"` | ||
} | ||
|
||
func (cnf *Config) Index() error { | ||
cnf.GitHub.canonicals = make(map[string]string) | ||
for _, canonical := range cnf.GitHub.Canonical { | ||
cnf.GitHub.canonicals[canonical.Real] = canonical.Name | ||
} | ||
|
||
cnf.GitHub.aliases = make(map[string][]string) | ||
for _, alias := range cnf.GitHub.Aliases { | ||
cnf.GitHub.aliases[alias.SSH] = alias.Aliases | ||
} | ||
|
||
cnf.GitHub.Include.list = make(map[string]struct{}) | ||
for _, include := range cnf.GitHub.Include.List { | ||
cnf.GitHub.Include.list[include] = struct{}{} | ||
} | ||
|
||
cnf.GitHub.Exclude.list = make(map[string]struct{}) | ||
for _, exclude := range cnf.GitHub.Exclude.List { | ||
cnf.GitHub.Exclude.list[exclude] = struct{}{} | ||
} | ||
|
||
size := len(cnf.GitHub.Exclude.Patterns) | ||
cnf.GitHub.Exclude.patterns = make([]*regexp.Regexp, 0, size) | ||
for _, pattern := range cnf.GitHub.Exclude.Patterns { | ||
r, err := regexp.Compile(pattern) | ||
if err != nil { | ||
return err | ||
} | ||
cnf.GitHub.Exclude.patterns = append(cnf.GitHub.Exclude.patterns, r) | ||
} | ||
return nil | ||
} | ||
|
||
func defaults() Config { | ||
var cnf Config | ||
cnf.GitHub.Affiliation = []string{"owner"} | ||
cnf.GitHub.Tags = []string{"github", "repository"} | ||
cnf.GitHub.Readme = "README.md" | ||
cnf.GitHub.Limit = 100 | ||
|
||
// TODO:feature future implementation | ||
// some names from differed orgs are matched | ||
collision := "{{ .GetFullName | title }}" | ||
// sometimes readme are missed | ||
readme := struct { | ||
name string | ||
alt struct { | ||
tags []string | ||
content string | ||
} | ||
}{ | ||
name: "README.md", | ||
alt: struct { | ||
tags []string | ||
content string | ||
}{ | ||
tags: []string{"debt", "todo"}, | ||
content: ` | ||
# {{ .GetName | emoji }} | ||
{{ .GetDescription }} | ||
`, | ||
}, | ||
} | ||
_, _ = collision, readme | ||
|
||
return cnf | ||
} |
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 |
---|---|---|
@@ -1,136 +1,174 @@ | ||
[repository] | ||
[github] | ||
affiliation = ['owner', 'organization_member'] | ||
tags = ['github', 'repository'] | ||
|
||
[[repository.aliases]] | ||
readme = "README.md" | ||
limit = 100 | ||
|
||
collision = "{{ .GetName }} at {{ .GetLogin .GetOwner }}" | ||
[github.alt] | ||
tags = ['debt', 'todo'] | ||
draft = """ | ||
# {{ .GetName | emoji }} | ||
{{ .GetDescription }} | ||
""" | ||
|
||
[github.include] | ||
list = [ | ||
'kamilsk/godownloader', | ||
'kamilsk/go-tools', | ||
'kamilsk/golangci-lint', | ||
'under-the-hood/persona', | ||
] | ||
|
||
[github.exclude] | ||
list = [ | ||
'kamilsk/algobox', | ||
'kamilsk/CilexServiceProviders', | ||
'kamilsk/Common', | ||
'kamilsk/ideas', | ||
'kamilsk/kamilsk', | ||
'kamilsk/Kilex', | ||
'kamilsk/notes', | ||
'kamilsk/pmc', | ||
'kamilsk/SilexServiceProviders', | ||
'kamilsk/workshops', | ||
] | ||
patterns = [ | ||
'\w*\.\w+', | ||
'^under-the-hood/', | ||
'/site$', | ||
] | ||
|
||
[[github.canonical]] | ||
name = 'tact' | ||
real = 'tact-app' | ||
|
||
[[github.canonical]] | ||
name = 'research' | ||
real = 'under-the-hood' | ||
|
||
[[github.canonical]] | ||
name = 'sparkle' | ||
real = 'withsparkle' | ||
|
||
[[github.aliases]] | ||
ssh = 'git@github.com:kamilsk/go-tools.git' | ||
aliases = ['goimports'] | ||
|
||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/breakit.git' | ||
aliases = ['go.octolab.org/toolset/breakit'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/cli.git' | ||
aliases = ['go.octolab.org/toolkit/cli'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/config.git' | ||
aliases = ['go.octolab.org/toolkit/config'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/maintainer.git' | ||
aliases = ['go.octolab.org/toolset/maintainer'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/parallel.git' | ||
aliases = ['go.octolab.org/toolset/parallel'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/pkg.git' | ||
aliases = ['go.octolab.org'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/propaganda.git' | ||
aliases = ['go.octolab.org/propaganda'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/protocol.git' | ||
aliases = ['go.octolab.org/toolkit/protocol'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/testit.git' | ||
aliases = ['go.octolab.org/toolset/testit'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octolab/try.git' | ||
aliases = ['go.octolab.org/toolset/try'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octomation/go-module.git' | ||
aliases = ['go.octolab.org/template/module'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octomation/go-service.git' | ||
aliases = ['go.octolab.org/template/service'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octomation/go-tool.git' | ||
aliases = ['go.octolab.org/template/tool'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octomation/tablo.git' | ||
aliases = ['go.octolab.org/ecosystem/tablo'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octopot/forma.git' | ||
aliases = ['go.octolab.org/ecosystem/forma'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octopot/guard.git' | ||
aliases = ['go.octolab.org/ecosystem/guard'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:octopot/passport.git' | ||
aliases = ['go.octolab.org/ecosystem/passport'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/airseat.git' | ||
aliases = ['go.octolab.org/toolset/airseat'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/beads.git' | ||
aliases = ['go.octolab.org/ecosystem/beads'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/click.git' | ||
aliases = ['go.octolab.org/ecosystem/click'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/github.git' | ||
aliases = ['go.octolab.org/tact/inbox/github'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/inbox.git' | ||
aliases = ['go.octolab.org/template/inbox'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/loop.git' | ||
aliases = ['go.octolab.org/toolset/loop'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/optflow.git' | ||
aliases = ['go.octolab.org/toolset/optflow'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/secret.git' | ||
aliases = ['go.octolab.org/toolset/secret'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/service.git' | ||
aliases = ['go.octolab.org/ecosystem/tact'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:tact-app/trello.git' | ||
aliases = ['go.octolab.org/tact/inbox/trello'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:withsparkle/fiddle.git' | ||
aliases = ['go.octolab.org/toolset/fiddle'] | ||
|
||
[[repository.aliases]] | ||
[[github.aliases]] | ||
ssh = 'git@github.com:withsparkle/service.git' | ||
aliases = ['go.octolab.org/ecosystem/sparkle'] | ||
|
||
[repository.exclude] | ||
list = [ | ||
'kamilsk/algobox', | ||
'kamilsk/CilexServiceProviders', | ||
'kamilsk/Common', | ||
'kamilsk/ideas', | ||
'kamilsk/kamilsk', | ||
'kamilsk/Kilex', | ||
'kamilsk/notes', | ||
'kamilsk/pmc', | ||
'kamilsk/SilexServiceProviders', | ||
'kamilsk/workshops', | ||
] | ||
patterns = [ | ||
'\w*\.\w+', | ||
'^under-the-hood/', | ||
'/site$', | ||
] |
Oops, something went wrong.