Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/confluentinc/cli/v4

go 1.24.9
go 1.24.10

toolchain go1.24.11

require (
github.com/antihax/optional v1.0.0
Expand Down Expand Up @@ -286,3 +288,6 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/confluentinc/ccloud-sdk-go-v2/networking-gateway v0.2.0 => github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-gateway v0.11.0
replace github.com/confluentinc/ccloud-sdk-go-v2/networking-access-point v0.5.0 => github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-access-point v0.10.0
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ github.com/compose-spec/compose-go/v2 v2.1.3 h1:bD67uqLuL/XgkAK6ir3xZvNLFPxPScEi
github.com/compose-spec/compose-go/v2 v2.1.3/go.mod h1:lFN0DrMxIncJGYAXTfWuajfwj5haBJqrBkarHcnjJKc=
github.com/confluentinc/ccloud-sdk-go-v1-public v0.0.0-20250521223017-0e8f6f971b52 h1:19qEGhkbZa5fopKCe0VPIV+Sasby4Pv10z9ZaktwWso=
github.com/confluentinc/ccloud-sdk-go-v1-public v0.0.0-20250521223017-0e8f6f971b52/go.mod h1:62EMf+5uFEt1BJ2q8WMrUoI9VUSxAbDnmZCGRt/MbA0=
github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-access-point v0.9.0 h1:BULMAA6/NxDdd/MPgkXJHRkIh4ZEHNOEU+0SkOiiNqI=
github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-access-point v0.9.0/go.mod h1:3qRZBOqO0+rqWPWpfB1C56IvO6BvcjgYguIlXS8747s=
github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-access-point v0.10.0 h1:64ofcEeL8cuN3Ar7ClgQK769jBTbjYYInT+P+1Q+ub0=
github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-access-point v0.10.0/go.mod h1:VhCGBq6fQ8cJCEkp1OfPV4/8Pw4VbVKQCA9an2tLcQw=
github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-gateway v0.11.0 h1:z5ud8cyXRQw1QWlTH8mlDjPK9vQkqwALjAZ1RZYV05I=
github.com/confluentinc/ccloud-sdk-go-v2-internal/networking-gateway v0.11.0/go.mod h1:ECFZ7rp1MZKQQ8b2FHOlrngR4x26QcQAnBYGKxMxQ5c=
github.com/confluentinc/ccloud-sdk-go-v2/ai v0.1.0 h1:zSF4OQUJXWH2JeAo9rsq13ibk+JFdzITGR8S7cFMpzw=
github.com/confluentinc/ccloud-sdk-go-v2/ai v0.1.0/go.mod h1:DoxqzzF3JzvJr3fWkvCiOHFlE0GoYpozWxFZ1Ud9ntA=
github.com/confluentinc/ccloud-sdk-go-v2/apikeys v0.4.0 h1:8fWyLwMuy8ec0MVF5Avd54UvbIxhDFhZzanHBVwgxdw=
Expand Down
1 change: 1 addition & 0 deletions internal/network/command_access_point_private_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func (c *accessPointCommand) newPrivateLinkCommand() *cobra.Command {
}

cmd.AddCommand(c.newEgressEndpointCommand())
cmd.AddCommand(c.newIngressEndpointCommand())

return cmd
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package network

import (
"fmt"
"slices"

"github.com/spf13/cobra"

networkingaccesspointv1 "github.com/confluentinc/ccloud-sdk-go-v2/networking-access-point/v1"

"github.com/confluentinc/cli/v4/pkg/errors"
"github.com/confluentinc/cli/v4/pkg/output"
)

type ingressEndpointOut struct {
Id string `human:"ID" serialized:"id"`
Name string `human:"Name,omitempty" serialized:"name,omitempty"`
Environment string `human:"Environment" serialized:"environment"`
Gateway string `human:"Gateway" serialized:"gateway"`
Phase string `human:"Phase" serialized:"phase"`
AwsVpcEndpointId string `human:"AWS VPC Endpoint ID,omitempty" serialized:"aws_vpc_endpoint_id,omitempty"`
AwsVpcEndpointServiceName string `human:"AWS VPC Endpoint Service Name,omitempty" serialized:"aws_vpc_endpoint_service_name,omitempty"`
DnsDomain string `human:"DNS Domain,omitempty" serialized:"dns_domain,omitempty"`
}

func (c *accessPointCommand) newIngressEndpointCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "ingress-endpoint",
Short: "Manage private link ingress endpoints.",
}

cmd.AddCommand(c.newIngressEndpointCreateCommand())
cmd.AddCommand(c.newIngressEndpointDeleteCommand())
cmd.AddCommand(c.newIngressEndpointDescribeCommand())
cmd.AddCommand(c.newIngressEndpointListCommand())
cmd.AddCommand(c.newIngressEndpointUpdateCommand())

return cmd
}

func (c *accessPointCommand) validIngressEndpointArgs(cmd *cobra.Command, args []string) []string {
if len(args) > 0 {
return nil
}

return c.validIngressEndpointArgsMultiple(cmd, args)
}

func (c *accessPointCommand) validIngressEndpointArgsMultiple(cmd *cobra.Command, args []string) []string {
if err := c.PersistentPreRunE(cmd, args); err != nil {
return nil
}

return c.autocompleteIngressEndpoints()
}

func (c *accessPointCommand) autocompleteIngressEndpoints() []string {
environmentId, err := c.Context.EnvironmentId()
if err != nil {
return nil
}

accessPoints, err := c.V2Client.ListAccessPoints(environmentId, nil)
if err != nil {
return nil
}
ingressEndpoints := slices.DeleteFunc(accessPoints, func(accessPoint networkingaccesspointv1.NetworkingV1AccessPoint) bool {
return accessPoint.Spec.GetConfig().NetworkingV1AwsIngressPrivateLinkEndpoint == nil
})

suggestions := make([]string, len(ingressEndpoints))
for i, ingressEndpoint := range ingressEndpoints {
suggestions[i] = fmt.Sprintf("%s\t%s", ingressEndpoint.GetId(), ingressEndpoint.Spec.GetDisplayName())
}
return suggestions
}

func printPrivateLinkIngressEndpointTable(cmd *cobra.Command, ingressEndpoint networkingaccesspointv1.NetworkingV1AccessPoint) error {
if ingressEndpoint.Spec == nil {
return fmt.Errorf(errors.CorruptedNetworkResponseErrorMsg, "spec")
}
if ingressEndpoint.Status == nil {
return fmt.Errorf(errors.CorruptedNetworkResponseErrorMsg, "status")
}

out := &ingressEndpointOut{
Id: ingressEndpoint.GetId(),
Name: ingressEndpoint.Spec.GetDisplayName(),
Gateway: ingressEndpoint.Spec.Gateway.GetId(),
Environment: ingressEndpoint.Spec.Environment.GetId(),
Phase: ingressEndpoint.Status.GetPhase(),
}

if ingressEndpoint.Status.Config != nil && ingressEndpoint.Status.Config.NetworkingV1AwsIngressPrivateLinkEndpointStatus != nil {
out.AwsVpcEndpointId = ingressEndpoint.Status.Config.NetworkingV1AwsIngressPrivateLinkEndpointStatus.GetVpcEndpointId()
out.AwsVpcEndpointServiceName = ingressEndpoint.Status.Config.NetworkingV1AwsIngressPrivateLinkEndpointStatus.GetVpcEndpointServiceName()
if ingressEndpoint.Status.Config.NetworkingV1AwsIngressPrivateLinkEndpointStatus.HasDnsDomain() {
out.DnsDomain = ingressEndpoint.Status.Config.NetworkingV1AwsIngressPrivateLinkEndpointStatus.GetDnsDomain()
}
}

table := output.NewTable(cmd)
table.Add(out)
return table.PrintWithAutoWrap(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package network

import (
"fmt"
"strings"

"github.com/spf13/cobra"

networkingaccesspointv1 "github.com/confluentinc/ccloud-sdk-go-v2/networking-access-point/v1"

pcloud "github.com/confluentinc/cli/v4/pkg/cloud"
pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/examples"
)

func (c *accessPointCommand) newIngressEndpointCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "create [name]",
Short: "Create an ingress endpoint.",
Args: cobra.MaximumNArgs(1),
RunE: c.createIngressEndpoint,
Example: examples.BuildExampleString(
examples.Example{
Text: "Create an AWS PrivateLink ingress endpoint.",
Code: "confluent network access-point private-link ingress-endpoint create --cloud aws --gateway gw-123456 --vpc-endpoint-id com.amazonaws.vpce.us-west-2.vpce-svc-00000000000000000",
},
),
}

pcmd.AddCloudFlag(cmd)
cmd.Flags().String("vpc-endpoint-id", "", "ID of an AWS VPC endpoint.")
addGatewayFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddOutputFlag(cmd)

cobra.CheckErr(cmd.MarkFlagRequired("cloud"))
cobra.CheckErr(cmd.MarkFlagRequired("gateway"))
cobra.CheckErr(cmd.MarkFlagRequired("vpc-endpoint-id"))

return cmd
}

func (c *accessPointCommand) createIngressEndpoint(cmd *cobra.Command, args []string) error {
name := ""
if len(args) == 1 {
name = args[0]
}

cloud, err := cmd.Flags().GetString("cloud")
if err != nil {
return err
}
cloud = strings.ToUpper(cloud)

gateway, err := cmd.Flags().GetString("gateway")
if err != nil {
return err
}

vpcEndpointId, err := cmd.Flags().GetString("vpc-endpoint-id")
if err != nil {
return err
}

environmentId, err := c.Context.EnvironmentId()
if err != nil {
return err
}

createIngressEndpoint := networkingaccesspointv1.NetworkingV1AccessPoint{
Spec: &networkingaccesspointv1.NetworkingV1AccessPointSpec{
Environment: &networkingaccesspointv1.ObjectReference{Id: environmentId},
Gateway: &networkingaccesspointv1.ObjectReference{Id: gateway},
},
}

if name != "" {
createIngressEndpoint.Spec.SetDisplayName(name)
}

switch cloud {
case pcloud.Aws:
createIngressEndpoint.Spec.Config = &networkingaccesspointv1.NetworkingV1AccessPointSpecConfigOneOf{
NetworkingV1AwsIngressPrivateLinkEndpoint: &networkingaccesspointv1.NetworkingV1AwsIngressPrivateLinkEndpoint{
Kind: "AwsIngressPrivateLinkEndpoint",
VpcEndpointId: vpcEndpointId,
},
}
default:
return fmt.Errorf("ingress endpoints are only supported for AWS")
}

ingressEndpoint, err := c.V2Client.CreateAccessPoint(createIngressEndpoint)
if err != nil {
return err
}

return printPrivateLinkIngressEndpointTable(cmd, ingressEndpoint)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package network

import (
"fmt"

"github.com/spf13/cobra"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/deletion"
"github.com/confluentinc/cli/v4/pkg/output"
"github.com/confluentinc/cli/v4/pkg/plural"
"github.com/confluentinc/cli/v4/pkg/resource"
"github.com/confluentinc/cli/v4/pkg/utils"
)

func (c *accessPointCommand) newIngressEndpointDeleteCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "delete <id-1> [id-2] ... [id-n]",
Short: "Delete one or more ingress endpoints.",
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: pcmd.NewValidArgsFunction(c.validIngressEndpointArgsMultiple),
RunE: c.deleteIngressEndpoint,
}

pcmd.AddForceFlag(cmd)
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)

return cmd
}

func (c *accessPointCommand) deleteIngressEndpoint(cmd *cobra.Command, args []string) error {
environmentId, err := c.Context.EnvironmentId()
if err != nil {
return err
}

existenceFunc := func(id string) bool {
_, err := c.V2Client.GetAccessPoint(environmentId, id)
return err == nil
}

if err := deletion.ValidateAndConfirm(cmd, args, existenceFunc, resource.AccessPoint); err != nil {
return err
}

deleteFunc := func(id string) error {
return c.V2Client.DeleteAccessPoint(environmentId, id)
}

deletedIds, err := deletion.DeleteWithoutMessage(cmd, args, deleteFunc)
deleteMsg := "Requested to delete %s %s.\n"
if len(deletedIds) == 1 {
output.Printf(c.Config.EnableColor, deleteMsg, resource.AccessPoint, fmt.Sprintf(`"%s"`, deletedIds[0]))
} else if len(deletedIds) > 1 {
output.Printf(c.Config.EnableColor, deleteMsg, plural.Plural(resource.AccessPoint), utils.ArrayToCommaDelimitedString(deletedIds, "and"))
}

return err
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package network

import (
"github.com/spf13/cobra"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/examples"
)

func (c *accessPointCommand) newIngressEndpointDescribeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "describe <id>",
Short: "Describe an ingress endpoint.",
Args: cobra.ExactArgs(1),
ValidArgsFunction: pcmd.NewValidArgsFunction(c.validIngressEndpointArgs),
RunE: c.describeIngressEndpoint,
Example: examples.BuildExampleString(
examples.Example{
Text: `Describe ingress endpoint "ap-123456".`,
Code: "confluent network access-point private-link ingress-endpoint describe ap-123456",
},
),
}

pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand)
pcmd.AddOutputFlag(cmd)

return cmd
}

func (c *accessPointCommand) describeIngressEndpoint(cmd *cobra.Command, args []string) error {
environmentId, err := c.Context.EnvironmentId()
if err != nil {
return err
}

ingressEndpoint, err := c.V2Client.GetAccessPoint(environmentId, args[0])
if err != nil {
return err
}

return printPrivateLinkIngressEndpointTable(cmd, ingressEndpoint)
}
Loading