|  | @@ -4,6 +4,8 @@ import (
 | 
	
		
			
				|  |  |  	"context"
 | 
	
		
			
				|  |  |  	"fmt"
 | 
	
		
			
				|  |  |  	"io"
 | 
	
		
			
				|  |  | +	"strconv"
 | 
	
		
			
				|  |  | +	"strings"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
 | 
	
		
			
				|  |  |  	"github.com/Azure/go-autorest/autorest/azure/auth"
 | 
	
	
		
			
				|  | @@ -139,11 +141,24 @@ func (cs *containerService) Exec(ctx context.Context, name string, command strin
 | 
	
		
			
				|  |  |  	)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -func (cs *containerService) Logs(ctx context.Context, name string, writer io.Writer, follow bool) error {
 | 
	
		
			
				|  |  | -	logs, err := getACIContainerLogs(ctx, cs.ctx, name, name)
 | 
	
		
			
				|  |  | +func (cs *containerService) Logs(ctx context.Context, containerName string, req containers.LogsRequest) error {
 | 
	
		
			
				|  |  | +	logs, err := getACIContainerLogs(ctx, cs.ctx, containerName, containerName)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	_, err = fmt.Fprint(writer, logs)
 | 
	
		
			
				|  |  | +	if req.Tail != "all" {
 | 
	
		
			
				|  |  | +		tail, err := strconv.Atoi(req.Tail)
 | 
	
		
			
				|  |  | +		if err != nil {
 | 
	
		
			
				|  |  | +			return err
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		lines := strings.Split(logs, "\n")
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		// If asked for less lines than exist, take only those lines
 | 
	
		
			
				|  |  | +		if tail <= len(lines) {
 | 
	
		
			
				|  |  | +			logs = strings.Join(lines[len(lines)-tail:], "\n")
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	_, err = fmt.Fprint(req.Writer, logs)
 | 
	
		
			
				|  |  |  	return err
 | 
	
		
			
				|  |  |  }
 |