(ref flake.Ref)
| 32 | var githubNameRegexp = regexp.MustCompile("[^a-zA-Z0-9-_.]+") |
| 33 | |
| 34 | func newGithubPlugin(ref flake.Ref) (*githubPlugin, error) { |
| 35 | plugin := &githubPlugin{ref: ref} |
| 36 | // For backward compatibility, we don't strictly require name to be present |
| 37 | // in github plugins. If it's missing, we just use the directory as the name. |
| 38 | name, err := getPluginNameFromContent(plugin) |
| 39 | if err != nil && !errors.Is(err, errNameMissing) { |
| 40 | return nil, err |
| 41 | } |
| 42 | if name == "" { |
| 43 | name = strings.ReplaceAll(ref.Dir, "/", "-") |
| 44 | } |
| 45 | plugin.name = githubNameRegexp.ReplaceAllString( |
| 46 | strings.Join(lo.Compact([]string{ref.Owner, ref.Repo, name}), "."), |
| 47 | " ", |
| 48 | ) |
| 49 | return plugin, nil |
| 50 | } |
| 51 | |
| 52 | func (p *githubPlugin) Fetch() ([]byte, error) { |
| 53 | content, err := p.FileContent(pluginConfigName) |
no test coverage detected