github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/config/flags_service_start.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package config
    19  
    20  import (
    21  	"strings"
    22  
    23  	"github.com/urfave/cli/v2"
    24  )
    25  
    26  var (
    27  	// FlagIdentity keystore's identity.
    28  	FlagIdentity = cli.StringFlag{
    29  		Name:  "identity",
    30  		Usage: "Keystore's identity used to provide service. If not given identity will be created automatically",
    31  		Value: "",
    32  	}
    33  	// FlagIdentityPassphrase passphrase to unlock the identity.
    34  	FlagIdentityPassphrase = cli.StringFlag{
    35  		Name:  "identity.passphrase",
    36  		Usage: "Used to unlock keystore's identity",
    37  		Value: "",
    38  	}
    39  
    40  	// FlagAgreedTermsConditions agree with terms & conditions.
    41  	FlagAgreedTermsConditions = cli.BoolFlag{
    42  		Name:  "agreed-terms-and-conditions",
    43  		Usage: "Agree with terms & conditions for consumer, provider or both depending on the command executed",
    44  	}
    45  
    46  	// FlagAccessPolicyList a comma-separated list of access policies that determines allowed identities to use the service.
    47  	FlagAccessPolicyList = cli.StringFlag{
    48  		Name:  "access-policy.list",
    49  		Usage: "Comma separated list that determines the access policies applied to provide service.",
    50  		Value: "",
    51  	}
    52  
    53  	// FlagPaymentPriceGiB sets the price/GiB to provided service.
    54  	FlagPaymentPriceGiB = cli.Float64Flag{
    55  		Name:  "payment.price-gib",
    56  		Usage: "Sets the price/GiB applied to provider service.",
    57  		Value: 0.1,
    58  	}
    59  	// FlagPaymentPriceHour sets the price/hour to provided service.
    60  	FlagPaymentPriceHour = cli.Float64Flag{
    61  		Name:  "payment.price-hour",
    62  		Usage: "Sets the price/hour applied to provider service.",
    63  		Value: 0.00006,
    64  	}
    65  
    66  	// FlagActiveServices a comma-separated list of active services.
    67  	FlagActiveServices = cli.StringFlag{
    68  		Name:  "active-services",
    69  		Usage: "Comma separated list of active services.",
    70  		Value: strings.Join([]string{"scraping", "data_transfer", "dvpn"}, ","),
    71  	}
    72  
    73  	// FlagStoppedServices a comma-separated list of stopped services.
    74  	FlagStoppedServices = cli.StringFlag{
    75  		Name:   "stopped-services",
    76  		Usage:  "Comma separated list of stopped services.",
    77  		Value:  strings.Join([]string{}, ","),
    78  		Hidden: true,
    79  	}
    80  )
    81  
    82  // RegisterFlagsServiceStart registers CLI flags used to start a service.
    83  func RegisterFlagsServiceStart(flags *[]cli.Flag) {
    84  	*flags = append(*flags,
    85  		&FlagIdentity,
    86  		&FlagIdentityPassphrase,
    87  		&FlagAgreedTermsConditions,
    88  		&FlagPaymentPriceGiB,
    89  		&FlagPaymentPriceHour,
    90  		&FlagAccessPolicyList,
    91  		&FlagActiveServices,
    92  		&FlagStoppedServices,
    93  	)
    94  }
    95  
    96  // ParseFlagsServiceStart parses service start CLI flags and registers values to the configuration
    97  func ParseFlagsServiceStart(ctx *cli.Context) {
    98  	Current.ParseStringFlag(ctx, FlagIdentity)
    99  	Current.ParseStringFlag(ctx, FlagIdentityPassphrase)
   100  	Current.ParseBoolFlag(ctx, FlagAgreedTermsConditions)
   101  	Current.ParseFloat64Flag(ctx, FlagPaymentPriceGiB)
   102  	Current.ParseFloat64Flag(ctx, FlagPaymentPriceHour)
   103  	Current.ParseStringFlag(ctx, FlagAccessPolicyList)
   104  	Current.ParseStringFlag(ctx, FlagActiveServices)
   105  	Current.ParseStringFlag(ctx, FlagStoppedServices)
   106  }