MCPcopy Create free account
hub / github.com/Scalingo/cli / keysContainsName

Function keysContainsName

scmintegrations/import_keys.go:80–108  ·  view source on GitHub ↗
(ctx context.Context, c *scalingo.Client, name string)

Source from the content-addressed store, hash-verified

78}
79
80func keysContainsName(ctx context.Context, c *scalingo.Client, name string) ([]scalingo.Key, error) {
81 keys, err := c.KeysList(ctx)
82 if err != nil {
83 return nil, errors.Wrapf(ctx, err, "fail to get keys")
84 }
85
86 var keysAlreadyImported []scalingo.Key
87
88 for _, k := range keys {
89 if !strings.Contains(k.Name, name+"-") {
90 continue
91 }
92
93 switch scalingo.SCMType(name) {
94 case scalingo.SCMGitlabType:
95 if !strings.Contains(k.Name, scalingo.SCMGitlabSelfHostedType.Str()) {
96 keysAlreadyImported = append(keysAlreadyImported, k)
97 }
98 case scalingo.SCMGithubType:
99 if !strings.Contains(k.Name, scalingo.SCMGithubEnterpriseType.Str()) {
100 keysAlreadyImported = append(keysAlreadyImported, k)
101 }
102 case scalingo.SCMGithubEnterpriseType, scalingo.SCMGitlabSelfHostedType:
103 keysAlreadyImported = append(keysAlreadyImported, k)
104 }
105 }
106
107 return keysAlreadyImported, nil
108}

Callers 1

ImportKeysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected