MCPcopy Create free account
hub / github.com/github/gh-aw / validateOwner

Function validateOwner

pkg/cli/project_command.go:229–250  ·  view source on GitHub ↗

validateOwner validates that the owner exists

(ctx context.Context, ownerType, owner string, verbose bool)

Source from the content-addressed store, hash-verified

227
228// validateOwner validates that the owner exists
229func validateOwner(ctx context.Context, ownerType, owner string, verbose bool) error {
230 projectLog.Printf("Validating %s: %s", ownerType, owner)
231 console.LogVerbose(verbose, fmt.Sprintf("Validating %s exists: %s", ownerType, owner))
232
233 var query string
234 if ownerType == "org" {
235 query = fmt.Sprintf(`query { organization(login: "%s") { id login } }`, escapeGraphQLString(owner))
236 } else {
237 query = fmt.Sprintf(`query { user(login: "%s") { id login } }`, escapeGraphQLString(owner))
238 }
239
240 _, err := workflow.RunGH("Validating owner...", "api", "graphql", "-f", "query="+query)
241 if err != nil {
242 if ownerType == "org" {
243 return fmt.Errorf("organization '%s' not found or not accessible", owner)
244 }
245 return fmt.Errorf("user '%s' not found or not accessible", owner)
246 }
247
248 console.LogVerbose(verbose, fmt.Sprintf("✓ %s '%s' validated", capitalizeFirst(ownerType), owner))
249 return nil
250}
251
252// capitalizeFirst capitalizes the first letter of a string
253func capitalizeFirst(s string) string {

Callers 1

RunProjectNewFunction · 0.85

Calls 6

LogVerboseFunction · 0.92
RunGHFunction · 0.92
escapeGraphQLStringFunction · 0.85
capitalizeFirstFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected