github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/services/upgrader/errors.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package upgrader
     5  
     6  import (
     7  	"fmt"
     8  )
     9  
    10  // InvalidArch indicates that the current operating system or cpu architecture doesn't support upgrades
    11  type InvalidArch struct{}
    12  
    13  func NewInvalidArch() *InvalidArch {
    14  	return &InvalidArch{}
    15  }
    16  
    17  func (e *InvalidArch) Error() string {
    18  	return "invalid operating system or processor architecture"
    19  }
    20  
    21  // InvalidSignature indicates that the downloaded file doesn't have a valid signature.
    22  type InvalidSignature struct{}
    23  
    24  func NewInvalidSignature() *InvalidSignature {
    25  	return &InvalidSignature{}
    26  }
    27  
    28  func (e *InvalidSignature) Error() string {
    29  	return "invalid file signature"
    30  }
    31  
    32  // InvalidPermissions indicates that the file permissions doesn't allow to upgrade
    33  type InvalidPermissions struct {
    34  	ErrType            string
    35  	Path               string
    36  	FileUsername       string
    37  	MattermostUsername string
    38  }
    39  
    40  func NewInvalidPermissions(errType string, path string, mattermostUsername string, fileUsername string) *InvalidPermissions {
    41  	return &InvalidPermissions{
    42  		ErrType:            errType,
    43  		Path:               path,
    44  		FileUsername:       fileUsername,
    45  		MattermostUsername: mattermostUsername,
    46  	}
    47  }
    48  
    49  func (e *InvalidPermissions) Error() string {
    50  	return fmt.Sprintf("the user %s is unable to update the %s file", e.MattermostUsername, e.Path)
    51  }