func NewNsmClient(ctx context.Context, rootConf *config.Config) networkservice.NetworkServiceClient {
	// ********************************************************************************
	// Get a x509Source
	// ********************************************************************************
	source, err := workloadapi.NewX509Source(ctx)
	if err != nil {
		logrus.Fatalf("error getting x509 source: %+v", err)
	}
	var svid *x509svid.SVID
	svid, err = source.GetX509SVID()
	if err != nil {
		logrus.Fatalf("error getting x509 svid: %+v", err)
	}
	logrus.Infof("sVID: %q", svid.ID)

	// ********************************************************************************
	// Connect to NSManager
	// ********************************************************************************
	var cancel context.CancelFunc
	ctx, cancel = context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	logrus.Infof("NSC: Connecting to Network Service Manager %v", rootConf.ConnectTo.String())
	var clientCC *grpc.ClientConn
	clientCC, err = grpc.DialContext(ctx,
		grpcutils.URLToTarget(rootConf.ConnectTo),
		grpc.WithTransportCredentials(
			credentials.NewTLS(
				tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()))),
		grpc.WithDefaultCallOptions(
			grpc.WaitForReady(true)))
	if err != nil {
		logrus.Fatalf("failed to dial NSM: %v", err)
	}

	// ********************************************************************************
	// Create Network Service Manager nsmClient
	// ********************************************************************************
	return client.NewClient(ctx, rootConf.Name, nil, spiffejwt.TokenGeneratorFunc(source, rootConf.MaxTokenLifetime), clientCC)
}
// NewNsmClient - creates a client connection to NSMGr
creates a client connection to NSMGr
// NewNsmClient - creates a client connection to NSMGr
func NewNsmClient(ctx context.Context, rootConf *config.Config) networkservice.NetworkServiceClient {
	source, err := workloadapi.NewX509Source(ctx)
	if err != nil {
		logrus.Fatalf("error getting x509 source: %+v", err)
	}
	var svid *x509svid.SVID
	svid, err = source.GetX509SVID()
	if err != nil {
		logrus.Fatalf("error getting x509 svid: %+v", err)
	}
	logrus.Infof("sVID: %q", svid.ID)
	var cancel context.CancelFunc
	ctx, cancel = context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	logrus.Infof("NSC: Connecting to Network Service Manager %v", rootConf.ConnectTo.String())
	var clientCC *grpc.ClientConn
	clientCC, err = grpc.DialContext(ctx,
		grpcutils.URLToTarget(rootConf.ConnectTo),
		grpc.WithTransportCredentials(
			credentials.NewTLS(
				tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()))),
		grpc.WithDefaultCallOptions(
			grpc.WaitForReady(true)))
	if err != nil {
		logrus.Fatalf("failed to dial NSM: %v", err)
	}
	return client.NewClient(ctx, rootConf.Name, nil, spiffejwt.TokenGeneratorFunc(source, rootConf.MaxTokenLifetime), clientCC)
}
func NewNsmClient ( ctx context . Context , rootConf * config . Config ) networkservice . NetworkServiceClient { source , err := workloadapi . NewX509Source ( ctx ) if err != nil { logrus . Fatalf ( " " , err ) } var svid * x509svid . SVID svid , err = source . GetX509SVID ( ) if err != nil { logrus . Fatalf ( " " , err ) } logrus . Infof ( " " , svid . ID ) var cancel context . CancelFunc ctx , cancel = context . WithTimeout ( ctx , 5 * time . Second ) defer cancel ( ) logrus . Infof ( " " , rootConf . ConnectTo . String ( ) ) var clientCC * grpc . ClientConn clientCC , err = grpc . DialContext ( ctx , grpcutils . URLToTarget ( rootConf . ConnectTo ) , grpc . WithTransportCredentials ( credentials . NewTLS ( tlsconfig . MTLSClientConfig ( source , source , tlsconfig . AuthorizeAny ( ) ) ) ) , grpc . WithDefaultCallOptions ( grpc . WaitForReady ( true ) ) ) if err != nil { logrus . Fatalf ( " " , err ) } return client . NewClient ( ctx , rootConf . Name , nil , spiffejwt . TokenGeneratorFunc ( source , rootConf . MaxTokenLifetime ) , clientCC ) }
creates a client connection to NSMGr
creates a client connection to NSMGr
// ******************************************************************************** // Get a x509Source // ******************************************************************************** // ******************************************************************************** // Connect to NSManager // ******************************************************************************** // ******************************************************************************** // Create Network Service Manager nsmClient // ********************************************************************************