getOwnerNodeId gets the node ID for the owner
(ctx context.Context, ownerType, owner string, verbose bool)
| 259 | |
| 260 | // getOwnerNodeId gets the node ID for the owner |
| 261 | func getOwnerNodeId(ctx context.Context, ownerType, owner string, verbose bool) (string, error) { |
| 262 | projectLog.Printf("Getting node ID for %s: %s", ownerType, owner) |
| 263 | console.LogVerbose(verbose, fmt.Sprintf("Getting node ID for %s: %s", ownerType, owner)) |
| 264 | |
| 265 | var query string |
| 266 | var jqPath string |
| 267 | if ownerType == "org" { |
| 268 | query = fmt.Sprintf(`query { organization(login: "%s") { id } }`, escapeGraphQLString(owner)) |
| 269 | jqPath = ".data.organization.id" |
| 270 | } else { |
| 271 | query = fmt.Sprintf(`query { user(login: "%s") { id } }`, escapeGraphQLString(owner)) |
| 272 | jqPath = ".data.user.id" |
| 273 | } |
| 274 | |
| 275 | output, err := workflow.RunGH("Getting owner ID...", "api", "graphql", "-f", "query="+query, "--jq", jqPath) |
| 276 | if err != nil { |
| 277 | return "", fmt.Errorf("failed to get owner node ID: %w", err) |
| 278 | } |
| 279 | |
| 280 | nodeId := strings.TrimSpace(string(output)) |
| 281 | if nodeId == "" { |
| 282 | return "", errors.New("failed to get owner node ID from response") |
| 283 | } |
| 284 | |
| 285 | console.LogVerbose(verbose, "✓ Got node ID: "+nodeId) |
| 286 | return nodeId, nil |
| 287 | } |
| 288 | |
| 289 | // createProject creates a GitHub Project V2 |
| 290 | func createProject(ctx context.Context, ownerId, title string, verbose bool) (map[string]any, error) { |
no test coverage detected