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

intercept app cli query updated #304

Merged
merged 1 commit into from
Sep 28, 2024
Merged

Conversation

nxtcoder36
Copy link
Contributor

@nxtcoder36 nxtcoder36 commented Sep 28, 2024

Summary by Sourcery

Introduce a new GraphQL query to fetch DNS host suffix and enhance the existing app interception mutation by renaming it and modifying its parameters to support local cluster interception.

New Features:

  • Add a new GraphQL query cli_getDNSHostSuffix to retrieve the DNS host suffix.

Enhancements:

  • Update the cli_interceptApp mutation to cli_interceptAppOnLocalCluster, changing parameters from deviceName to clusterName and adding ipAddr.

Copy link

sourcery-ai bot commented Sep 28, 2024

Reviewer's Guide by Sourcery

This pull request updates the CLI query for intercepting an app, introduces a new query for getting the DNS host suffix, and modifies the related GraphQL schema. The changes focus on adapting the app interception process for local clusters and adding functionality to retrieve DNS host information.

Sequence Diagram

sequenceDiagram
    participant CLI
    participant Server
    participant LocalCluster
    CLI->>Server: core_interceptAppOnLocalCluster(clusterName, ipAddr, ...)
    Server->>LocalCluster: Intercept app
    LocalCluster-->>Server: Interception result
    Server-->>CLI: Return result
Loading

File-Level Changes

Change Details Files
Updated app interception mutation
  • Renamed mutation from 'Core_interceptApp' to 'Core_interceptAppOnLocalCluster'
  • Replaced 'deviceName' parameter with 'clusterName' and 'ipAddr'
  • Updated the corresponding GraphQL query in the schema
src/apps/auth/server/gql/cli-queries.ts
gql-queries-generator/doc/queries.graphql
Added new query for retrieving DNS host suffix
  • Implemented 'cli_getDNSHostSuffix' query
  • Added corresponding GraphQL query 'authCli_getDNSHostSuffix' in the schema
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.

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

@nxtcoder36 nxtcoder36 merged commit f76531c into release-v1.0.8 Sep 28, 2024
4 checks passed
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 @nxtcoder36 - 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.

@@ -293,24 +307,26 @@ export const cliQueries = (executor: IExecutor) => ({
),
cli_interceptApp: executor(
gql`
mutation Core_interceptApp(
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 maintaining both device-based and cluster-based interception functions or creating a more generic function to handle both cases.

The changes to cli_interceptApp (now cli_interceptAppOnLocalCluster) introduce additional complexity by shifting from a device-based to a cluster-based approach. While this may be necessary for the evolving architecture, consider the following suggestions to minimize complexity and maintain API clarity:

  1. Keep both functions to ensure backwards compatibility:
cli_interceptApp: executor(
  gql`
    mutation Core_interceptApp(
      $portMappings: [Github__com___kloudlite___operator___apis___crds___v1__AppInterceptPortMappingsIn!]
      $intercept: Boolean!
      $deviceName: String!
      $appName: String!
      $envName: String!
    ) {
      core_interceptApp(
        portMappings: $portMappings
        intercept: $intercept
        deviceName: $deviceName
        appname: $appName
        envName: $envName
      )
    }
  `,
  {
    transformer: (data: any) => data.core_interceptApp,
    vars: (_: any) => {},
  }
),

cli_interceptAppOnLocalCluster: executor(
  gql`
    mutation Core_interceptAppOnLocalCluster(
      $portMappings: [Github__com___kloudlite___operator___apis___crds___v1__AppInterceptPortMappingsIn!]
      $intercept: Boolean!
      $clusterName: String!
      $ipAddr: String!
      $appName: String!
      $envName: String!
    ) {
      core_interceptAppOnLocalCluster(
        portMappings: $portMappings
        intercept: $intercept
        clusterName: $clusterName
        ipAddr: $ipAddr
        appname: $appName
        envName: $envName
      )
    }
  `,
  {
    transformer: (data: any) => data.core_interceptAppOnLocalCluster,
    vars: (_: any) => {},
  }
),
  1. If possible, consider creating a more generic function that can handle both device and cluster-based interception:
cli_interceptApp: executor(
  gql`
    mutation Core_interceptApp(
      $portMappings: [Github__com___kloudlite___operator___apis___crds___v1__AppInterceptPortMappingsIn!]
      $intercept: Boolean!
      $target: InterceptTargetInput!
      $appName: String!
      $envName: String!
    ) {
      core_interceptApp(
        portMappings: $portMappings
        intercept: $intercept
        target: $target
        appname: $appName
        envName: $envName
      )
    }
  `,
  {
    transformer: (data: any) => data.core_interceptApp,
    vars: (_: any) => {},
  }
),

Where InterceptTargetInput is a new input type that can represent either a device or a cluster:

input InterceptTargetInput {
  deviceName: String
  clusterName: String
  ipAddr: String
}

This approach would provide flexibility while maintaining a single, more generic API.

Please provide more context on why this change was necessary and how it fits into the broader architecture. This information would help in understanding the rationale behind the current implementation and potentially lead to more tailored suggestions for reducing complexity.

@nxtcoder36 nxtcoder36 deleted the impl/kl-cli-intercept branch September 28, 2024 13:38
abdheshnayak pushed a commit that referenced this pull request Oct 28, 2024
tulsiojha pushed a commit that referenced this pull request Nov 1, 2024
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
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