Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref/cli queries update #337

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Ref/cli queries update #337

merged 2 commits into from
Dec 9, 2024

Conversation

nxtCoder19
Copy link
Contributor

@nxtCoder19 nxtCoder19 commented Dec 9, 2024

Summary by Sourcery

New Features:

  • Introduce CLI queries for listing, creating, and deleting service intercepts.

Copy link

sourcery-ai bot commented Dec 9, 2024

Reviewer's Guide by Sourcery

This PR adds new GraphQL queries and mutations for managing service bindings and intercepts in the CLI. The changes introduce functionality to list services, create service intercepts, and delete service intercepts.

Sequence diagram for CLI service management

sequenceDiagram
    actor User
    participant CLI
    participant GraphQLServer
    User->>CLI: Execute listServices
    CLI->>GraphQLServer: Core_listServiceBindings
    GraphQLServer-->>CLI: Return service bindings
    CLI-->>User: Display service list

    User->>CLI: Execute createServiceIntercept
    CLI->>GraphQLServer: Core_createServiceIntercept
    GraphQLServer-->>CLI: Confirm intercept creation
    CLI-->>User: Confirm intercept created

    User->>CLI: Execute deleteServiceIntercept
    CLI->>GraphQLServer: Core_deleteServiceIntercept
    GraphQLServer-->>CLI: Confirm intercept deletion
    CLI-->>User: Confirm intercept deleted
Loading

Class diagram for GraphQL service operations

classDiagram
    class ServiceBinding {
        String accountName
        String apiVersion
        String clusterName
        String creationTime
        String environmentName
        String id
        InterceptStatus interceptStatus
        String kind
        Boolean markedForDeletion
        Metadata metadata
        String recordVersion
        Spec spec
        Status status
        String updateTime
    }
    class InterceptStatus {
        Boolean intercepted
        PortMapping[] portMappings
        String toAddr
    }
    class Metadata {
        Map annotations
        String creationTimestamp
        String deletionTimestamp
        Integer generation
        Map labels
        String name
        String namespace
    }
    class Spec {
        String globalIP
        String hostname
        Port[] ports
        String serviceIP
        ServiceRef serviceRef
    }
    class Status {
        CheckList[] checkList
        Boolean checks
        Boolean isReady
        Integer lastReadyGeneration
        String lastReconcileTime
        Message message
        Resource[] resources
    }
    class PortMapping {
        Integer containerPort
        Integer servicePort
    }
    class Port {
        String appProtocol
        String name
        Integer nodePort
        Integer port
        String protocol
        TargetPort targetPort
    }
    class TargetPort {
        Integer IntVal
        String StrVal
        String Type
    }
    class ServiceRef {
        String name
        String namespace
    }
    class CheckList {
        Boolean debug
        String description
        Boolean hide
        String name
        String title
    }
    class Message {
        String RawMessage
    }
    class Resource {
        String apiVersion
        String kind
        String name
        String namespace
    }
Loading

File-Level Changes

Change Details Files
Added new GraphQL queries and mutations for service management
  • Added cli_listServices query to fetch service bindings with pagination support
  • Added cli_createServiceIntercept mutation to create service intercepts
  • Added cli_deleteServiceIntercept mutation to remove service intercepts
  • Implemented corresponding auth CLI queries in the GraphQL schema
src/apps/auth/server/gql/cli-queries.ts
gql-queries-generator/doc/queries.graphql
src/generated/gql/server.ts
Enhanced service binding data structure
  • Added comprehensive service binding fields including metadata, spec, and status
  • Included intercept status information with port mappings
  • Added support for pagination metadata in service listing
src/apps/auth/server/gql/cli-queries.ts
gql-queries-generator/doc/queries.graphql

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @nxtCoder19 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -487,6 +487,144 @@ export const cliQueries = (executor: IExecutor) => ({
}
),

cli_listServices: executor(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider extracting common GraphQL fields into reusable fragments to improve code organization

The GraphQL queries could be simplified by extracting common Kubernetes patterns into reusable fragments. This would reduce duplication while maintaining all functionality. For example:

fragment K8sMetadata on Metadata {
  annotations
  creationTimestamp
  deletionTimestamp
  generation
  labels
  name
  namespace
}

fragment PortMapping on PortMapping {
  containerPort
  servicePort
}

fragment ServiceStatus on Status {
  isReady
  lastReadyGeneration
  lastReconcileTime
  message {
    RawMessage
  }
}

query Core_listServiceBindings(
  $envName: String!
  $pagination: CursorPaginationIn
) {
  core_listServiceBindings(envName: $envName, pagination: $pagination) {
    edges {
      cursor
      node {
        metadata { ...K8sMetadata }
        interceptStatus {
          intercepted
          portMappings { ...PortMapping }
          toAddr
        }
        status { ...ServiceStatus }
        # ... other fields
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}

This approach:

  • Reduces duplicate field definitions
  • Makes schema changes easier to maintain
  • Keeps queries more readable
  • Allows reuse across multiple queries

@nxtCoder19 nxtCoder19 merged commit c3b3d9b into release-v1.1.1 Dec 9, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants