Skip to content

Repository files navigation

Toolsconfig

Documentation is work in progress!

Single config file containing credentials and favourites for cli tools using cobra and viper.

Default configuration file: ~/.toolsconfig/config.yaml. On Linux systems the directory should have 700 permissions, and the file 600, otherwise an error will be thrown.

The following kinds of credentials are now available.

  • Server credentials per URL/Identifier (Similar to ~/.m2/settings.xml or ~/.gradle/gradle.properties) e.g. Docker registry, Artifactory, ...
  • Azure Subscription Credentials
  • Generic credentials (Simple Key/Value pair)

If a credential is required, and it does not exist in the config file a new entry with empty values will be added to the configuration.

Additional features:

  • Favourite handling

    Requires adding toolconfig commands and functions to the cobra root command!

    • Every successfully executed call can be saved as a favourite using
      mytool [param1] [param2] --flag1 test --save myFirstFavourite
    • List existing favourites.
      mytool fav list
    • Run save commands
      mytool --run myFirstFavourite => runs mytool [param1] [param2] --flag1 test

Configuration

# ~/.toolsconfig/config.yamlservers:
- # The server base url. This url is used from the apps to find the credentials for the serverurl: repository.url# The username to access the serverusername: [ USERNAME ]# The password to access the serverpassword: [ PASSWORD ]# Another example for a maven repository
- url: maven.repository.urlusername: [ MAVEN_USERNAME ]password: [ MAVENPASSWORD ]azureSubscriptions:
- # The subscription name. Either the name or the subscriptionID can be used from the tools to get teh credentials name: azureSubsciption01# The subscription IDsubscriptionID: [ SUBSCRIPTION_ID ]# The tenant IDtenantID: [ TENANT_ID ]# The client IDclientID: [ CLIENT_ID ]# The client secretclientSecret: [ CLIENT_SECRET ]generics:
- # The key of a generic value key: system-with-token# The value for the generic key (e.g. auth token)value: [ SECRET TOKEN ]favourites:
toolname1:
favName:
name: favNameargs: [ arg01, arg02, arg03]

Environement Variables

You can use environment variables to use instead of the values from config files. Environment variables overrule values from config files, but only if all values for a entry are available.

Environment values for the example from above:

REPOSITORY.URL_USERNAME=[USERNAME]
REPOSITORY.URL_IO_PASSWORD=[PASSWORD]
MAVEN.REPOSITORY.URL_PASSWORD=[USERNAME] MAVEN.REPOSITORY.URL_USERNAME=[PASSWORD]
AZURESUBSCRIPTION01_SUBSCRIPTIONID=[SUBSCRIPTION_ID]
AZURESUBSCRIPTION01_TENANTID=[TENANT_ID]
AZURESUBSCRIPTION01_CLIENTID=[CLIENT_ID]
AZURESUBSCRIPTION01_CLIENTSECRET=[CLIENT_SECRET]
SYSTEM_WITH_TOKEN_VALUE=CLIENT_SECRET

Example

see Command example

run with:

go run example/main.go --help

About

Single config file containing credentials and favorites for cli tools using cobra and viper.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages