github.com/jenkins-x/jx/v2@v2.1.155/pkg/cloud/amazon/awscli/aws_cli.go (about)

     1  package awscli
     2  
     3  import (
     4  	"github.com/jenkins-x/jx/v2/pkg/util"
     5  	"github.com/pkg/errors"
     6  )
     7  
     8  // awsClient is an abstraction over the AWS CLI operations
     9  type awsClient struct{}
    10  
    11  // NewAWSCli returns an AWS CLI abstraction client
    12  func NewAWSCli() awsClient {
    13  	return awsClient{}
    14  }
    15  
    16  // ConnectToClusterWithAWSCLI will modify the kube-config file to add the provided cluster and change context to it
    17  func (awsClient) ConnectToClusterWithAWSCLI(clusterName string) error {
    18  	args := []string{"eks", "update-kubeconfig", "--name", clusterName}
    19  
    20  	cmd := util.Command{
    21  		Name: "aws",
    22  		Args: args,
    23  	}
    24  	_, err := cmd.RunWithoutRetry()
    25  	if err != nil {
    26  		return errors.Wrapf(err, "failed to connect to region cluster %s", clusterName)
    27  	}
    28  	return nil
    29  }