Mainflux.mainflux/cli/config.go

244 lines
5.8 KiB
Go
Raw Normal View History

MF-1506 - Group-based Access Control (#1716) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update Add and Delete Policies (#1792) * Remove Policy Action Ranks Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Rebase Issues Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix CI Test Errors Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Adding Check on Subject For Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Check Client Exists Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check When Sharing Clients Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Only Add User to Group When Sharing Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove clientType Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Minor Fix on ShareClient and Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Clean Up Things Authorization Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests on RetrieveAll Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Test ShareThing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Merge Conflicts Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove Adding Policies. Only Use Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Check If Subject is same as Object Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Move Back To Union As Sometimes Policy is Empty and Fails to Evaluate on Ownership Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Entity Type For Failing Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix BUG in policy evaluation Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Comments Regarding checkAdmin Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Combine Authorize For Things and Users Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests On Rebase Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Error on Things SVC `unsupported protocol scheme` Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix Bug on Things Authorization Cache (#1810) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Use Password instead of username in MQTT handler Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Simplify MQTT authorization Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix MQTT tests Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add More Functions to SDK (#1811) * Add More Functions to SDK Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to GoDoc Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Update Unassign Interface Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Pass Subject as ID and Not Token on List Channels By Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Bootstrap Errors For Element Check Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add empty line Before Return Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Reorder URLS in things mux Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Listing Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Share Thing Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Examples to CLI Docs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Identity To Update Another User Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Identify an Update Policies on Things Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Update Things Policies Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix GoDocs on Disconnect Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Change Authorize To Use AccessRequest Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * For Evaluate Policy Use AccessRequest (#1814) Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add SDK Tests (#1812) * Add Things Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Channel Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Certs Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Consumer Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enrich Group Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Health Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Tests For Tokens Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename SDK for Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Policies Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Linter Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Fix Tests Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Make Variable Defination Inline Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Make Cache Key Duration Configurable (#1815) * Make Cache Key Duration Configurable Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Rename ENV Var Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Update GoDocs (#1816) * Add GoDocs Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add Missing GoDoc Files Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Enable godot Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Add License Information Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * NOISSUE - Add Call Home Client to Mainflux services (#1751) * Move Things and Users to Clients Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> * collect and send data package Signed-off-by: SammyOina <sammyoina@gmail.com> * create telemetry migrations Signed-off-by: SammyOina <sammyoina@gmail.com> * add telemetry endpoints Signed-off-by: SammyOina <sammyoina@gmail.com> * add transport Signed-off-by: SammyOina <sammyoina@gmail.com> * create service Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing server Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to adapters Signed-off-by: SammyOina <sammyoina@gmail.com> * add last seen Signed-off-by: SammyOina <sammyoina@gmail.com> * rename logger Signed-off-by: SammyOina <sammyoina@gmail.com> * remove homing client Signed-off-by: SammyOina <sammyoina@gmail.com> * use unmerged repo Signed-off-by: SammyOina <sammyoina@gmail.com> * use renamed module Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home version Signed-off-by: SammyOina <sammyoina@gmail.com> * edit documentation Signed-off-by: SammyOina <sammyoina@gmail.com> * align table Signed-off-by: SammyOina <sammyoina@gmail.com> * use alias for call home client Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home pkg Signed-off-by: SammyOina <sammyoina@gmail.com> * update call home Signed-off-by: SammyOina <sammyoina@gmail.com> * fix modules Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * use mf build version Signed-off-by: SammyOina <sammyoina@gmail.com> * restore default Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home for users and things Signed-off-by: SammyOina <sammyoina@gmail.com> * enable opting on call home Signed-off-by: SammyOina <sammyoina@gmail.com> * remove full stops Signed-off-by: SammyOina <sammyoina@gmail.com> * update callhome client Signed-off-by: SammyOina <sammyoina@gmail.com> * add call home to all services Signed-off-by: SammyOina <sammyoina@gmail.com> * fix build Signed-off-by: SammyOina <sammyoina@gmail.com> * restore sdk tests Signed-off-by: SammyOina <sammyoina@gmail.com> * remove unnecessary changes Signed-off-by: SammyOina <sammyoina@gmail.com> * restore health_test.go Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> --------- Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Sammy Kerata Oina <44265300+SammyOina@users.noreply.github.com>
2023-06-14 18:40:37 +08:00
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package cli
import (
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
"io"
"net/url"
"os"
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
"reflect"
"strconv"
"strings"
"github.com/mainflux/mainflux/pkg/errors"
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
mfxsdk "github.com/mainflux/mainflux/pkg/sdk/go"
"github.com/pelletier/go-toml"
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
"github.com/spf13/cobra"
)
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
type remotes struct {
ThingsURL string `toml:"things_url"`
UsersURL string `toml:"users_url"`
ReaderURL string `toml:"reader_url"`
HTTPAdapterURL string `toml:"http_adapter_url"`
BootstrapURL string `toml:"bootstrap_url"`
CertsURL string `toml:"certs_url"`
TLSVerification bool `toml:"tls_verification"`
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
type filter struct {
Offset string `toml:"offset"`
Limit string `toml:"limit"`
Topic string `toml:"topic"`
}
type config struct {
Remotes remotes `toml:"remotes"`
Filter filter `toml:"filter"`
UserToken string `toml:"user_token"`
RawOutput string `toml:"raw_output"`
}
// Readable by all user groups but writeable by the user only.
NOISSUE - Change import name aliases (#1868) * Change import name aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change import name aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change import aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> Fix aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx merge Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx merge Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx merge Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix import alias Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix linter Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix linter Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix import Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add linter to CI pipeline Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Changes Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix merge issues Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix gci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix gci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix gci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add gofumpt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove multiple gofupmt in CI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary changes Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix linter Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix CI pipeline Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-11 17:30:25 +08:00
const filePermission = 0o644
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
var (
errReadFail = errors.New("failed to read config file")
errNoKey = errors.New("no such key")
errUnsupportedKeyValue = errors.New("unsupported data type for key")
errWritingConfig = errors.New("error in writing the updated config to file")
errInvalidURL = errors.New("invalid url")
errURLParseFail = errors.New("failed to parse url")
defaultConfigPath = "./config.toml"
)
func read(file string) (config, error) {
c := config{}
data, err := os.Open(file)
if err != nil {
return c, errors.Wrap(errReadFail, err)
}
defer data.Close()
buf, err := io.ReadAll(data)
if err != nil {
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
return c, errors.Wrap(errReadFail, err)
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
if err := toml.Unmarshal(buf, &c); err != nil {
return config{}, err
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
return c, nil
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
// ParseConfig - parses the config file.
func ParseConfig(sdkConf mfxsdk.Config) (mfxsdk.Config, error) {
if ConfigPath == "" {
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
ConfigPath = defaultConfigPath
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
_, err := os.Stat(ConfigPath)
switch {
// If the file does not exist, create it with default values.
case os.IsNotExist(err):
defaultConfig := config{
Remotes: remotes{
ThingsURL: "http://localhost:9000",
UsersURL: "http://localhost:9002",
ReaderURL: "http://localhost",
HTTPAdapterURL: "http://localhost/http:9016",
BootstrapURL: "http://localhost",
CertsURL: "https://localhost:9019",
TLSVerification: false,
},
}
buf, err := toml.Marshal(defaultConfig)
if err != nil {
return sdkConf, err
}
if err = os.WriteFile(ConfigPath, buf, filePermission); err != nil {
return sdkConf, errors.Wrap(errWritingConfig, err)
}
case err != nil:
return sdkConf, err
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
config, err := read(ConfigPath)
if err != nil {
return sdkConf, err
}
if config.Filter.Offset != "" {
offset, err := strconv.ParseUint(config.Filter.Offset, 10, 64)
if err != nil {
return sdkConf, err
}
Offset = offset
}
if config.Filter.Limit != "" {
limit, err := strconv.ParseUint(config.Filter.Limit, 10, 64)
if err != nil {
return sdkConf, err
}
Limit = limit
}
if config.Filter.Topic != "" {
Topic = config.Filter.Topic
}
if config.RawOutput != "" {
rawOutput, err := strconv.ParseBool(config.RawOutput)
if err != nil {
return sdkConf, err
}
RawOutput = rawOutput
}
sdkConf.ThingsURL = config.Remotes.ThingsURL
sdkConf.UsersURL = config.Remotes.UsersURL
sdkConf.ReaderURL = config.Remotes.ReaderURL
sdkConf.HTTPAdapterURL = config.Remotes.HTTPAdapterURL
sdkConf.BootstrapURL = config.Remotes.BootstrapURL
sdkConf.CertsURL = config.Remotes.CertsURL
return sdkConf, nil
}
// New config command to store params to local TOML file.
func NewConfigCmd() *cobra.Command {
return &cobra.Command{
Use: "config <key> <value>",
Short: "CLI local config",
Long: "Local param storage to prevent repetitive passing of keys",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
logUsage(cmd.Use)
return
}
if err := setConfigValue(args[0], args[1]); err != nil {
logError(err)
return
}
logOK()
},
}
}
func setConfigValue(key string, value string) error {
MF 1413 - Use per-service URL in SDK (#1444) * Use per-service URL in SDK Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> * Fix CLI Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix CLI messaging Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix message tests Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Simplify Bootstrap Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Update API doc and responses Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * fix failing certs, bootstrap tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix failing certs, bootstrap tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * Fix tests and rename to auth service Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Clean the code Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Remove unnecessary Repository logs Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Always return error in case of repo failure Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Cleanup SDK and CLI Update tests, remove linter warnings, remove dead code. Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Clean the code Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Undo Bootstrap changes Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix tests Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix linter Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> Co-authored-by: mteodor <mirko.teodorovic@gmail.com> Co-authored-by: dusanb94 <dusan.borovcanin@mainflux.com>
2021-08-11 22:58:10 +08:00
config, err := read(ConfigPath)
if err != nil {
return err
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
if strings.Contains(key, "url") {
u, err := url.Parse(value)
if err != nil {
return errors.Wrap(errInvalidURL, err)
}
if u.Scheme == "" || u.Host == "" {
return errors.Wrap(errInvalidURL, err)
}
if u.Scheme != "http" && u.Scheme != "https" {
return errors.Wrap(errURLParseFail, err)
}
}
NOISSUE - Change import name aliases (#1868) * Change import name aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change import name aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change import aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> Fix aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx merge Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx merge Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> FIx merge Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix import alias Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix linter Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix linter Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix import Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add linter to CI pipeline Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Changes Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused aliases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix merge issues Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix gci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix gci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix gci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add gofumpt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove multiple gofupmt in CI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary changes Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix linter Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix CI pipeline Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-11 17:30:25 +08:00
configKeyToField := map[string]interface{}{
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
"things_url": &config.Remotes.ThingsURL,
"users_url": &config.Remotes.UsersURL,
"reader_url": &config.Remotes.ReaderURL,
"http_adapter_url": &config.Remotes.HTTPAdapterURL,
"bootstrap_url": &config.Remotes.BootstrapURL,
"certs_url": &config.Remotes.CertsURL,
"tls_verification": &config.Remotes.TLSVerification,
"offset": &config.Filter.Offset,
"limit": &config.Filter.Limit,
"topic": &config.Filter.Topic,
"raw_output": &config.RawOutput,
"user_token": &config.UserToken,
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
fieldPtr, ok := configKeyToField[key]
if !ok {
return errNoKey
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
fieldValue := reflect.ValueOf(fieldPtr).Elem()
switch fieldValue.Kind() {
case reflect.String:
fieldValue.SetString(value)
case reflect.Int:
intValue, err := strconv.Atoi(value)
if err != nil {
return err
}
fieldValue.SetUint(uint64(intValue))
case reflect.Bool:
boolValue, err := strconv.ParseBool(value)
if err != nil {
return err
}
fieldValue.SetBool(boolValue)
default:
return errors.Wrap(errUnsupportedKeyValue, err)
}
MF-1340 - Add CLI config TOML file (#1858) * Add config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change key names Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add config file path Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Configure TOML parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli config command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove debug log Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use snake case Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change from interactive command Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use map for keys Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add cli logger level Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Use mainflux logger Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary comments Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove fmt Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify CLI Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unused variables Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * TEsts Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Make config path configurable Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove empty toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Change url key identification Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove url parsing functions Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle parse error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle url error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add marshal Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Update config Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix cli Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Handle file error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Modify url parsing Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add usertoken Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix user token Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove string init Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove config.toml from root Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Add empty line to config.toml Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Inline error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove unnecessary type conversion Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Fix error handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * Remove dynamic filters Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
2023-08-08 18:01:59 +08:00
buf, err := toml.Marshal(config)
if err != nil {
return err
}
if err = os.WriteFile(ConfigPath, buf, filePermission); err != nil {
return errors.Wrap(errWritingConfig, err)
}
return nil
}