@@ -512,133 +512,6 @@ func WhoamiQuery(cl *graphql.Client) (*WhoamiResponse, error) {
512512 return & response , nil
513513}
514514
515- // OrbQuery validated and processes an orb.
516- func OrbQuery (cl * graphql.Client , configPath string , ownerId string ) (* ConfigResponse , error ) {
517- var response OrbConfigResponse
518-
519- config , err := loadYaml (configPath )
520- if err != nil {
521- return nil , err
522- }
523-
524- request , err := makeOrbRequest (cl , config , ownerId )
525- if err != nil {
526- return nil , err
527- }
528-
529- err = cl .Run (request , & response )
530- if err != nil {
531- return nil , errors .Wrap (err , "Unable to validate config" )
532- }
533-
534- if len (response .OrbConfig .ConfigResponse .Errors ) > 0 {
535- return nil , response .OrbConfig .ConfigResponse .Errors
536- }
537-
538- return & response .OrbConfig .ConfigResponse , nil
539- }
540-
541- func makeOrbRequest (cl * graphql.Client , configContent string , ownerId string ) (* graphql.Request , error ) {
542- handlesOwner := orbQueryHandleOwnerId (cl )
543-
544- if handlesOwner {
545- query := `
546- query ValidateOrb ($config: String!, $owner: UUID) {
547- orbConfig(orbYaml: $config, ownerId: $owner) {
548- valid,
549- errors { message },
550- sourceYaml,
551- outputYaml
552- }
553- }`
554-
555- request := graphql .NewRequest (query )
556- request .Var ("config" , configContent )
557-
558- if ownerId != "" {
559- request .Var ("owner" , ownerId )
560- }
561-
562- request .SetToken (cl .Token )
563- return request , nil
564- }
565-
566- if ownerId != "" {
567- return nil , errors .Errorf ("Your version of Server does not support validating orbs that refer to other private orbs. Please see the README for more information on server compatibility: https://github.com/CircleCI-Public/circleci-cli#server-compatibility" )
568- }
569- query := `
570- query ValidateOrb ($config: String!) {
571- orbConfig(orbYaml: $config) {
572- valid,
573- errors { message },
574- sourceYaml,
575- outputYaml
576- }
577- }`
578-
579- request := graphql .NewRequest (query )
580- request .Var ("config" , configContent )
581-
582- request .SetToken (cl .Token )
583- return request , nil
584- }
585-
586- type OrbIntrospectionResponse struct {
587- Schema struct {
588- Query struct {
589- Fields []struct {
590- Name string `json:"name"`
591- Args []struct {
592- Name string `json:"name"`
593- } `json:"args"`
594- } `json:"fields"`
595- } `json:"queryType"`
596- } `json:"__schema"`
597- }
598-
599- func orbQueryHandleOwnerId (cl * graphql.Client ) bool {
600- query := `
601- query ValidateOrb {
602- __schema {
603- queryType {
604- fields(includeDeprecated: true) {
605- name
606- args {
607- name
608- __typename
609- type {
610- name
611- }
612- }
613- }
614- }
615- }
616- }`
617- request := graphql .NewRequest (query )
618- response := OrbIntrospectionResponse {}
619- err := cl .Run (request , & response )
620- if err != nil {
621- return false
622- }
623-
624- request .SetToken (cl .Token )
625-
626- // Find the orbConfig query method, look at its arguments, if it has the "ownerId" argument, return true
627- for _ , field := range response .Schema .Query .Fields {
628- if field .Name == "orbConfig" {
629- for _ , arg := range field .Args {
630- if arg .Name == "ownerId" {
631- return true
632- }
633- }
634- }
635- }
636-
637- // else return false, ownerId is not supported
638-
639- return false
640- }
641-
642515// OrbImportVersion publishes a new version of an orb using the provided source and id.
643516func OrbImportVersion (cl * graphql.Client , orbSrc string , orbID string , orbVersion string ) (* Orb , error ) {
644517 var response OrbImportVersionResponse
0 commit comments