github.com/getgauge/gauge@v1.6.9/plugin/descriptor.go (about)

     1  /*----------------------------------------------------------------
     2   *  Copyright (c) ThoughtWorks, Inc.
     3   *  Licensed under the Apache License, Version 2.0
     4   *  See LICENSE in the project root for license information.
     5   *----------------------------------------------------------------*/
     6  
     7  package plugin
     8  
     9  import (
    10  	"strings"
    11  
    12  	"github.com/getgauge/gauge/version"
    13  )
    14  
    15  type pluginCapability string
    16  
    17  const (
    18  	gRPCSupportCapability pluginCapability = "grpc_support"
    19  )
    20  
    21  type PluginDescriptor struct {
    22  	ID          string
    23  	Version     string
    24  	Name        string
    25  	Description string
    26  	Command     struct {
    27  		Windows []string
    28  		Linux   []string
    29  		Darwin  []string
    30  	}
    31  	Scope               []string
    32  	GaugeVersionSupport version.VersionSupport
    33  	pluginPath          string
    34  	Capabilities        []string
    35  }
    36  
    37  func (pd *PluginDescriptor) hasScope(scope pluginScope) bool {
    38  	for _, s := range pd.Scope {
    39  		if strings.ToLower(s) == string(scope) {
    40  			return true
    41  		}
    42  	}
    43  	return false
    44  }
    45  
    46  func (pd *PluginDescriptor) hasAnyScope() bool {
    47  	return len(pd.Scope) > 0
    48  }
    49  
    50  func (pd *PluginDescriptor) hasCapability(capability pluginCapability) bool {
    51  	for _, c := range pd.Capabilities {
    52  		if strings.ToLower(c) == string(capability) {
    53  			return true
    54  		}
    55  	}
    56  	return false
    57  }