pax_global_header00006660000000000000000000000064141563644560014530gustar00rootroot0000000000000052 comment=f646c50b184a0bec644dd1147d6b0e57be17c7aa viper-1.10.1/000077500000000000000000000000001415636445600127355ustar00rootroot00000000000000viper-1.10.1/.editorconfig000066400000000000000000000003251415636445600154120ustar00rootroot00000000000000root = true [*] charset = utf-8 end_of_line = lf indent_size = 4 indent_style = space insert_final_newline = true trim_trailing_whitespace = true [*.go] indent_style = tab [{Makefile, *.mk}] indent_style = tab viper-1.10.1/.github/000077500000000000000000000000001415636445600142755ustar00rootroot00000000000000viper-1.10.1/.github/.editorconfig000066400000000000000000000000411415636445600167450ustar00rootroot00000000000000[{*.yml,*.yaml}] indent_size = 2 viper-1.10.1/.github/ISSUE_TEMPLATE/000077500000000000000000000000001415636445600164605ustar00rootroot00000000000000viper-1.10.1/.github/ISSUE_TEMPLATE/bug_report.yaml000066400000000000000000000063411415636445600215200ustar00rootroot00000000000000name: 🐛 Bug report description: Report a bug to help us improve Viper labels: [kind/bug] body: - type: markdown attributes: value: | Thank you for submitting a bug report! Please fill out the template below to make it easier to debug your problem. If you are not sure if it is a bug or not, you can contact us via the available [support channels](https://github.com/spf13/viper/issues/new/choose). - type: checkboxes attributes: label: Preflight Checklist description: Please ensure you've completed all of the following. options: - label: I have searched the [issue tracker](https://www.github.com/spf13/viper/issues) for an issue that matches the one I want to file, without success. required: true - label: I am not looking for support or already pursued the available [support channels](https://github.com/spf13/viper/issues/new/choose) without success. required: true - type: input attributes: label: Viper Version description: What version of Viper are you using? placeholder: 1.8.1 validations: required: true - type: input attributes: label: Go Version description: What version of Go are you using? placeholder: "1.16" validations: required: true - type: dropdown attributes: label: Config Source description: What sources do you load configuration from? options: - Manual set - Flags - Environment variables - Files - Remove K/V stores - Defaults multiple: true validations: required: true - type: dropdown attributes: label: Format description: Which file formats do you use? options: - JSON - YAML - TOML - Dotenv - HCL - Java properties - INI - Other (specify below) multiple: true - type: input attributes: label: Repl.it link description: Complete example on Repl.it reproducing the issue. [Here](https://repl.it/@sagikazarmark/Viper-example) is an example you can use. placeholder: https://repl.it/@sagikazarmark/Viper-example - type: textarea attributes: label: Code reproducing the issue description: Please provide a Repl.it link if possible. render: go placeholder: | package main import ( "github.com/spf13/viper" ) func main() { v := viper.New() // ... var config Config err = v.Unmarshal(&config) if err != nil { panic(err) } } - type: textarea attributes: label: Expected Behavior description: A clear and concise description of what you expected to happen. validations: required: true - type: textarea attributes: label: Actual Behavior description: A clear description of what actually happens. validations: required: true - type: textarea attributes: label: Steps To Reproduce description: Steps to reproduce the behavior if it is not self-explanatory. placeholder: | 1. In this environment... 2. With this config... 3. Run '...' 4. See error... - type: textarea attributes: label: Additional Information description: Links? References? Anything that will give us more context about the issue that you are encountering! viper-1.10.1/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000007161415636445600204540ustar00rootroot00000000000000blank_issues_enabled: false contact_links: - name: ❓ Ask a question url: https://github.com/spf13/viper/discussions/new?category=q-a about: Ask and discuss questions with other Viper community members - name: 📓 Reference url: https://pkg.go.dev/mod/github.com/spf13/viper about: Check the Go code reference - name: 💬 Slack channel url: https://gophers.slack.com/messages/viper about: Please ask and answer questions here viper-1.10.1/.github/ISSUE_TEMPLATE/feature_request.yaml000066400000000000000000000027251415636445600225550ustar00rootroot00000000000000name: 🚀 Feature request description: Suggest an idea for Viper labels: [kind/enhancement] body: - type: markdown attributes: value: | Thank you for submitting a feature request! Please describe what you would like to change/add and why in detail by filling out the template below. If you are not sure if your request fits into Viper, you can contact us via the available [support channels](https://github.com/spf13/viper/issues/new/choose). - type: checkboxes attributes: label: Preflight Checklist description: Please ensure you've completed all of the following. options: - label: I have searched the [issue tracker](https://www.github.com/spf13/viper/issues) for an issue that matches the one I want to file, without success. required: true - type: textarea attributes: label: Problem Description description: A clear and concise description of the problem you are seeking to solve with this feature request. validations: required: true - type: textarea attributes: label: Proposed Solution description: A clear and concise description of what would you like to happen. validations: required: true - type: textarea attributes: label: Alternatives Considered description: A clear and concise description of any alternative solutions or features you've considered. - type: textarea attributes: label: Additional Information description: Add any other context about the problem here. viper-1.10.1/.github/PULL_REQUEST_TEMPLATES.md000066400000000000000000000013071415636445600202220ustar00rootroot00000000000000 **Overview**: **What problem does it solve?**: **Special notes for a reviewer**: viper-1.10.1/.github/dependabot.yml000066400000000000000000000004171415636445600171270ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: gomod directory: / labels: - area/dependencies schedule: interval: daily - package-ecosystem: github-actions directory: / labels: - area/dependencies schedule: interval: daily viper-1.10.1/.github/logo.png000066400000000000000000000526421415636445600157540ustar00rootroot00000000000000PNG  IHDRpbUiIDATxه@l0W t_X5( `amemeea'4 AAH")X؝&؈FPDAdwӸ7I!a&Kv: L{ 췟)Bɠkow훆L(;_'foc>ᄏ@NSq]=ܾ(Vv۫o[1Xk?V__?=(!Y8_]tS#)T6(B ~I:;E5FR}+q D/Ƴ'i%wۣ`>xoOKiivBh~.]xFRh^,t @s)F|=ӖCPl5]$;*qX,_\elvgDQ+G<*ree\ow`lywZ`gDϱ(^Z,N{_x [Jd[Ѓ«{- RdZe^5Ů v;^a P`P[Da?E6-Z? AhK[H *BAĢIiL![dbfƅH(hCp;px6mFNoN!|0^. nY2٥"N) Q_}-4 ?tqPSiND*ݳ=긞aiut, |@% Իq`ƫ[n`|qDT6ju@2Ro&@[Are/1ڴ E3& T{q` @@Jwƒ*Xo^̻F6Mq` Z@q*T%H2_P% ?7Qbm  qvx-J&mfm*{=WjzBv'@j b=a([\!`!x3|=*ʓr-N@MC[~ k/cXȓbeH 3 PjQ\_~pm }fPg )og{XxhyԤX-WVQMMw wr WFJJ{\Xtuٸ4\]C LoйRw/rJt=Ck#JÓ C\o|ل] &+8 mۯ͛# &s&h$x) 7îVL kmm) <{E 5۲ y*>C p\W/|m0rsSMOqx/\VPhvUt00)8P__} @ xGtUWm}l>}^9?+qRh&@n}W 8[#qE mh]8ח6vIx}R?FI_#Q Հ@AWoc rw=oagIX-0Ibh:"bH|iIU#:H"x& €$Ic1ܧ_rͽ庞녍X'q+ɭ eXWU']+N^Mjwd;|U@R, `y~}%%0F IuU.ȖK-LxTb[jj~2$xP,/^K(qıGKZ?;Ķ.X'uIr)R9W):,"+3{vvbD/'9׹@,!ٻNXȒ׺ ;u ʼn;Ó.zw$y=p: 0:۫Uޞ˿Vf4n6s5ѹ7GR4jK ' @BQ[ /10Џ̄'V$v > bQH$# >"Wz] 7E"Ţ hG^|׾Z]5$][w*f h+IV^xv7dyCbH ӲJZ3y`( ,ɥ,BP 6FD,ld .A LsρLu{_QkzӲC<7Y#k 8Xh{v`nO?h;*?2Xoޏ?[Sp$`њ5,[XI$D舞a28MDRy+阇Xu؂03A&J" D"dG2Dw4T J"H$0Nb,k@WqlJbSbX=%؇G@I$K,ҐbVJ"[lH$*B+Ģ3 x/tGVH%q"uq:+F? ` d}D7:.SĴq:(BfJb9/} y]>}8$%@VHTKY`a:-A:fc5vgvH=%*p`(&b!Q ]CEbq )؁P0w(Im" ;PбU🂣.hIS+,*Xj,[̉rN4+1pFp,1 Kpנ]~ Q"IɰORv[m۱xm`~%hǹ_$j=sg,[fu )\I=tA"fcUcZ kp#Na(I.+:Vn$ud@ƌ;6J1jl 1ߛ_M~x6O}9bvT!)`# }UXZvhwel!7hK\b(IUi7 * :Ė+qY_9)00fclY{XTۇy)/" VPJ0 [qc2,r rYMIBf-Ur#ABx8\7ᆗ Qw4vb7X*üfm  R4u Ӱې\ ڎ%q3-(9'A*"`S\fQ BעYb /&`*)0|"y:!p:%@;섶:4U,Sr.̷nAl- ]T?f~ERxhL|R<w**m?88|3b" Z+(K0+D._ppYVNGTvރdT 6)(a.OJV$=@'-v ^N Vr&x_ץa^Ud#$=th6zNS1ٜZZGNĤafPl{ %^)&˷_aSGNK)*Mc+9v p$㬒c&~Ex%#tyRTlC%R|]&'()8fH6ohNk(?Xa %7JsR$*nhJޯ`Ex@InXxqE9`t$f?5';ko\vC{@`0`H0hX뚱{fs /RH %n=p\{Ub<$H/{uqrY 2QB"!JYL o,>R3f^0K#/KVjBr4S[*.SJdM{3u= Džs V$ΧHEٰe? dW?OngHN743P[s??]`?)+!)N}pZ:]K=&(?0&%%M6N%Zw@Z.K3@|;|(d±5 s!^@w0˱ 8/Q{w⤒5jK6J|?D%!%%[8l%Mʏn 9Vzv3kqsב,ǻ#wc>!J.b6Xt eT")b2CG@$%@LKuJ֥.`۰@YN2g[JkJA6KP,}ihePG#9+)Bۙ+ k r?E=jۓRvHJJ$(gqH7C_ncA[RXQmJLs^^ZeUZz1(IY }#Ȓjl@$%@LK{qQɚ(rACIned`\~*-ӷ?)^-W\%e@gܤgW-Љ] B'cnK s莰b7.I ܊XQdhf8 msse„ R4K-&)Il3rT 0P)4qً-v%b?o^Yׂ%:RЎɃKyǟXX,%@Fs{ KT2i&\KAVcN#aQq $*i絾޹oz $5 h SpFcRU p  ajp)ІXS/bT쀶T% m L\° p] |VCR9R=-qDKrm`ct0.|1,c"܍8U`/==ǜB6l), }1VO e=#T$0nhv@FE O ]_.s3 d5TZ2/ϟsķoٔ?i2/4zF5☳XG,q[ 6HDգLo@;`R![ i![i/Z=tak??eMN5%{Z Ii $ކ͵CcOA^DP1L#j cIA^u!{"ڠFcuraSvzdEҟD2#N[! r%mV= pa{`LC! 9\TA"=aj3 ~D%&e 5/PGbbSiT$nO#Íw6(@BBwHÄ:3Hu}KyچOyF?m}>`Gտƽ `L$;6@Gܯ\ `LA,v5 8lJz,kjw p R*GGp0 E[X_5O%9^~͎hEu+ 8L}+uH[,q#b0i-},.5Oaiᔃj #/kѭ?#w9@8b> `8UWGfQG6M lՎ^TFz[Cx/fp(@˅8s}3p[UJ!{&Wz3)Tt?hiZ#۔s#@Lqe& 2Qq@GȄK`LuSn7%ރX)慮?`G?d!e+zcC1Nkz#@h8_ֻk:4#ޛp"701n(f5/4HEYx cS44ip:|kGe֌(9GQSȂk-XQ#C-`saz!1E]`D|ӊ=MAUG1)R9 '`Lt'$3?7: c բ?>l()!l֪ښm"4MR,Z?MzPPVT aQ# *f˭Q۷^7ݽ|q.=笁9n%\&Xk^G >Mӈ^ 6R'VV1\ ۮ4Dއ0O@}ŰH׼,Cܕ,U`UϪ5tt93VhpY恏Sz+jL#@-]` w QEy)eCAS5ҿ"b ¾ڽG#Qs0 FF*B?3(t` q]q#Qgq'a ]4(5@#q0 }+k[W#FXzVH{>隧@)G 2z~iS'4:GP?]4(u&#@W> E#qyN!xv+@-TF2rM4LԬ@)9xP߻6iJrG<`kp?5QVY?tA]HD ]ݢH H925ɕ00bŴ1l*lB-D+j;]؟ʺQ9ǽ@;ߕb7y~{oǐ078&SSᙱ'-%G{G Ui׺7<=^E{@8')]uXֵR;{@D_һͪg"@ !xnS#r#@~LMً`ͭ^?JA5\"ĿIHn%Ub" c$xKFd"07D"xLXha YsWP<@.{Nw$HlҘtD+xԈ(p0yD6[gMdw;c;hN_U݇?o*>l_=qh]itq@L^r):șGl)=?i_}T-" s;`f'ͫD"2M~IE#?`A7{e҇[5tYW3 P05p`D"pK`#vm^GP5"@,2gL 큭m^/B Wp8"0* (4g2{:)n($񜩁{ڼ*U@HZS#qä0 <"  ZF>Zs ;&󜩁{_ Dʜrg.Śzg {M5A0|#@˻D@75pY#@?^MR 580B SyE;s" l55pϘ T@ O,𫩁Y#@L&\9 fPA@y8~`GD"@E15K:lj`~{ E֡uD"$𔩁UGD"]heǯJ *CÊ(+,Ld%!$Ȑ,Fh[8(k,J,įQ%\ wsz~0uǝܿ6K&ˇzkb7x'dЉDyvDp"PUǥˀ5=3JG,w7{.`,\7D^,J+yD< ;[&HޱwMnB _fX=C1遽(o+(>"P?K}GtĀ5H2mJVJ[5t ksŧD=DHnoވ$D. Wx΀5;3qo r@'ܷ5$cFD&=,?>[ X<=mR72 ]Q6"}҃{cPzP; Xç&Kc;00lsgDRyIz`w`'"8;3%f߀5a"t5`KDtu y`zg|74/%O``@h]҃ ء#'/lеuEm7˷<+vJ5U=C,fnS @&LED"5Gz,?~Vb<"sc7_v( b6zS?3=G\'v D"wJ\`#@~oO`a"@1@si] ׿_+}I?KC^ۄQr@Ɯ#EA6`#@ ױwMɯ "Bݯ6`.MxנD"9$=[sP sv/{-8RD<_g_W_sE ʈ\Q]D"uf{}Ѐ@6 ,}6MtY"$,ٛ0v'"~G>7 c|B*8FT̘`ZYA7AYhUfl "КA56Th( D !,,dIUԢ~߅w̹?"Az6AUC  Y#=#mD'/I謼gр@(i#_ Բ0PHC9:D"qANzPǭ3""~U.u[pdrsFpwMT1pE".)l= m`$=+Du9Iyl[n~}7<=;FMOUHY*ʵWAI^0)=gIZ"cW,lFE*GD *ū҃z^zN2D"2~!,Huo@wXOz%^8tj";`*DX0rNz:fnF_-D*+Qj- A(J(*L` T4M::ZԬ)F dRRX=tL yqG(H)Vc99s?q\W0 rns`4 lS,&˜` '?k!uEz, PvUEIKi!dZa$@YX!mTld1m$a+@"$gy$?PX2vhͻ˒U=E,Tl}$@82Nd]4 ` 80w$I܊#-eH" 온d7 Q3-4CA^fedz3 i#b%Yb)a$@*Rq8 n'a 8m|c 5z*v2,~\q{р_t$43`Y 3$I`gJI" k Vl$KZYX1W0 b*WQr 88@Nb{`x4 g O AO͙H KH =(]7 `I.sj^MH)c߀6 GSe|^ iw3Dy+"2PMXcIH2pE4bF0 RVVF7L7,&$ H wi/р$XȳvϽQd :?-dI3+fI)2 XOQspɢ)+$v@:I!^.!&X L$BO 0B\$YO +:&RH#`e Q3pEC6VL-]`H #* 5 BEV$@nx:S 1}i &-ϽGXgJF?dI;[+z&<3 Ť#_x7\FYDgy+^HAy{:;&RkrA=:m^*Ɋs.-SX\80%l&Lxf9`et#GY)#lǃිCX1un\@(ln{[.. 5ғcePt%@t ur[_B ߥ^?axv&,$80'Ky bƙ0 `eT| 8"N:0pP >܋yb)őV! -2Cc`+`Οvm}>7 0k2$Wg@+X/h>\!\#ﻶ3W^37 d3ASY׀d+F&Q|&9PfГpϭT4VLC`x Dk{e;(Pcݽz LW`'*6U&HlZ&7HlKH2(EYKs5NR4^hBʇuͦ~R`HfV+ե0e)_~~FKA+ |)XoV xm $7vXk M&XZh 0]0U$?B={ -̂J8 F(کr f|o %`o3ܛr ~ n?NrZ}^--.ͯ S. uHT鵑Z8Tia~N1F i<|ka*@GJ_nAjp`QcޕvfwUUxjs^)8PLڕKH\v UDLX @-@(>y.: `-,0k8~ ȵA/l)x"(?7Vx/lS P~z^KM2 Xp=i2:`j %@ yN JXLO-`Ʊta/,8MyyO*Cwp}ty?>ˡ%@1iKH+E@-HvZSr#4qO͸7ȡk-TL,$s7"9pZKrMR%,sV J28oHf^:i {4&gҟ((,gc`8s0`k=ĉDl-N`Vt&>ܕlsi G0 Gc`J 04ҫ#8"3|:?1g<^ hkUn (mq ;&r7uY8?b^"#K҄]l?J_@g$jU>L;(IC+UXwcm% ﳟ}UїGV:WB`Dl Ѕ4p;Ь8FLB $ JTLٜlBKkllي,b`eId 1,J | =y;\_> &J9PM$:4[Y!8 T JeF2|s@UVY=!i#ƙzSm'QJv [9(K @ńE`x*+$|^>4 RgZI TTɦ)t?Prt.t3E{ $+=-9hLgS0 @e1 Cc}p 1Oi F GWN)LOPxTFl-s`4}.V|`7䄀Ζ<"t"ov,K׀*1 RJ>:l0&^bzQ'#`#X. Hj.@Y%h%ic]nuwL8 o>l\-5D7UB~)Y+F' jh "kOas<3`hS$LЍi@v5yVy|' M{E9e 7B64H Z7L  hˤ۔ 0/v_怾:~&>{5%^@ˀPTU E&M*,o &pϣ Q@٠C60{Z@^Fo[yO[q2j0't|l* "4BpBxßG %ת`__W{Z@=а15/;EefMԼ$tFف}0'MU~԰Jij "4ŷBR ExxG 0f@* t=daU. /pevnRCl9Qx˜:¬PTL~D4hcMl_xO=`*<Y@uPqT "4an*-<brLGhP*uWv;uz{Nu-ib@sF5^ `w)T,C*:0Z(> @3^4k$XJnFs#4c}ծ>:S@kc}O.!@_C>1/y:c!Q]mFoߚ S;(( j-AТMPԪVBAR.c#Ă̴ Sb@ڤC`Dm,  D (M)gtj4x8B=wTUzfPBv˸ p[dR^NvR9yHv{[sUżk~u*?8n-̒3wdv,wyPp@~1Y,;̗u2%?iC"8ț#WsB+]Hpefa& e < +"~W8$M.aEg2%r( `mI+\NZ?A@K~1kvM7/vbLs(BԾI>2%;AY#W0SɄleL+ʧ|)]yC^];( ʡ?Z4Xuְ `16ʘ>N!!@RY$WbY.c2..G6:.cL+e\&YrPbXg=^} /X_dD !0&6!9 7`ą'`땜 T` @KB(P.;  ,|+.TAɇ:{Vx  M `ɸm`  :=-=_]gvڎXlڑˍm~ܶgvh; ~Y]ULo67Ns@@ mkgqfPv Jx ?7@À][S ;^.{ݣMxm#ީjWץw9,޽4 DQ(] Ț(:n-5U 9ғWxU0xg}ocm/CBgd}o ,zoզs5k] a} Q_Ҽ' $t$X3w m‰z=( ؿLӈ׺NAOu!r]̜5! !B@B!_o# w!LLjCL"x.>G6 B'熈] ht eGx,X(;5e`xlO]{ Pl<^OKi p P2k>J^j`7;vlPPiMبE"͇q,һ@j.6V!SZ!9p@t`,(Leu p@i`<P6C1k @x `(LuM ͖uԤl>5fW<{~i#8c6`F($&0BTP[@HtF4̠0F":-x97Ľ@ ,=;52 0-1=[i&WBM*?}Ni-p*>5_e;p @NNp8 'Np8 i >k#*!aMVIENDB`viper-1.10.1/.github/workflows/000077500000000000000000000000001415636445600163325ustar00rootroot00000000000000viper-1.10.1/.github/workflows/ci.yml000066400000000000000000000020561415636445600174530ustar00rootroot00000000000000name: CI on: push: branches: - master pull_request: jobs: test: name: Test runs-on: ${{ matrix.os }} strategy: # Fail fast is disabled because there are Go version specific features and tests # that should be able to fail independently. fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] go: ['1.14', '1.15', '1.16', '1.17'] env: GOFLAGS: -mod=readonly steps: - name: Set up Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} - name: Checkout code uses: actions/checkout@v2 - name: Test run: go test -race -v ./... lint: name: Lint runs-on: ubuntu-latest env: GOFLAGS: -mod=readonly steps: - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.17 - name: Checkout code uses: actions/checkout@v2 - name: Lint uses: golangci/golangci-lint-action@v2 with: version: v1.43.0 viper-1.10.1/.github/workflows/codeql-analysis.yaml000066400000000000000000000046151415636445600223140ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ master ] pull_request: # The branches below must be a subset of the branches above branches: [ master ] schedule: - cron: '22 16 * * 3' jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'go' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - name: Checkout repository uses: actions/checkout@v2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v1 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 viper-1.10.1/.github/workflows/feedback_issue.yml000066400000000000000000000022011415636445600220040ustar00rootroot00000000000000on: issues: types: [opened] jobs: comment: runs-on: ubuntu-latest steps: - uses: actions/github-script@v5 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `👋 Thanks for reporting! A maintainer will take a look at your issue shortly. 👀 In the meantime: We are working on **Viper v2** and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues. ⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9 📣 If you've already given us your feedback, you can still help by spreading the news, either by sharing the above link or telling people about this on Twitter: https://twitter.com/sagikazarmark/status/1306904078967074816 **Thank you!** ❤️ `, }) viper-1.10.1/.github/workflows/feedback_pull_request.yml000066400000000000000000000022671415636445600234140ustar00rootroot00000000000000on: pull_request_target: types: [opened] jobs: comment: runs-on: ubuntu-latest steps: - uses: actions/github-script@v5 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `👋 Thanks for contributing to Viper! You are awesome! 🎉 A maintainer will take a look at your pull request shortly. 👀 In the meantime: We are working on **Viper v2** and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues. ⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9 📣 If you've already given us your feedback, you can still help by spreading the news, either by sharing the above link or telling people about this on Twitter: https://twitter.com/sagikazarmark/status/1306904078967074816 **Thank you!** ❤️ `, }) viper-1.10.1/.github/workflows/wasm.yml000066400000000000000000000006601415636445600200260ustar00rootroot00000000000000name: WASM on: push: branches: - master pull_request: jobs: build: name: Build runs-on: ubuntu-latest env: GOFLAGS: -mod=readonly steps: - name: Set up Go uses: actions/setup-go@v2 with: go-version: '1.17' - name: Checkout code uses: actions/checkout@v2 - name: Ensure Viper compiles for WASM run: GOOS=js GOARCH=wasm go build . viper-1.10.1/.gitignore000066400000000000000000000000451415636445600147240ustar00rootroot00000000000000/.idea/ /bin/ /build/ /var/ /vendor/ viper-1.10.1/.golangci.yml000066400000000000000000000034171415636445600153260ustar00rootroot00000000000000run: timeout: 5m linters-settings: gci: local-prefixes: github.com/spf13/viper golint: min-confidence: 0 goimports: local-prefixes: github.com/spf13/viper linters: disable-all: true enable: - bodyclose - deadcode - dogsled - dupl - durationcheck - exhaustive - exportloopref - gci - gofmt - gofumpt - goimports - gomoddirectives - goprintffuncname - govet - importas - ineffassign - makezero - misspell - nakedret - nilerr - noctx - nolintlint - prealloc - predeclared - revive - rowserrcheck - sqlclosecheck - staticcheck - structcheck - stylecheck - tparallel - typecheck - unconvert - unparam - unused - varcheck - wastedassign - whitespace # fixme # - cyclop # - errcheck # - errorlint # - exhaustivestruct # - forbidigo # - forcetypeassert # - gochecknoglobals # - gochecknoinits # - gocognit # - goconst # - gocritic # - gocyclo # - godot # - gosec # - gosimple # - ifshort # - lll # - nlreturn # - paralleltest # - scopelint # - thelper # - wrapcheck # unused # - depguard # - goheader # - gomodguard # don't enable: # - asciicheck # - funlen # - godox # - goerr113 # - gomnd # - interfacer # - maligned # - nestif # - testpackage # - wsl viper-1.10.1/LICENSE000066400000000000000000000020671415636445600137470ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Steve Francia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.viper-1.10.1/Makefile000066400000000000000000000047151415636445600144040ustar00rootroot00000000000000# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html OS = $(shell uname | tr A-Z a-z) export PATH := $(abspath bin/):${PATH} # Build variables BUILD_DIR ?= build export CGO_ENABLED ?= 0 export GOOS = $(shell go env GOOS) ifeq (${VERBOSE}, 1) ifeq ($(filter -v,${GOARGS}),) GOARGS += -v endif TEST_FORMAT = short-verbose endif # Dependency versions GOTESTSUM_VERSION = 1.7.0 GOLANGCI_VERSION = 1.43.0 # Add the ability to override some variables # Use with care -include override.mk .PHONY: clear clear: ## Clear the working area and the project rm -rf bin/ .PHONY: check check: test lint ## Run tests and linters bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION} @ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum bin/gotestsum-${GOTESTSUM_VERSION}: @mkdir -p bin curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION} TEST_PKGS ?= ./... .PHONY: test test: TEST_FORMAT ?= short test: SHELL = /bin/bash test: export CGO_ENABLED=1 test: bin/gotestsum ## Run tests @mkdir -p ${BUILD_DIR} bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...) bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION} @ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint bin/golangci-lint-${GOLANGCI_VERSION}: @mkdir -p bin curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION} @mv bin/golangci-lint "$@" .PHONY: lint lint: bin/golangci-lint ## Run linter bin/golangci-lint run .PHONY: fix fix: bin/golangci-lint ## Fix lint violations bin/golangci-lint run --fix # Add custom targets here -include custom.mk .PHONY: list list: ## List all make targets @${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort .PHONY: help .DEFAULT_GOAL := help help: @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' # Variable outputting/exporting rules var-%: ; @echo $($*) varexport-%: ; @echo $*=$($*) viper-1.10.1/README.md000066400000000000000000000665411415636445600142300ustar00rootroot00000000000000> ## Viper v2 feedback > Viper is heading towards v2 and we would love to hear what _**you**_ would like to see in it. Share your thoughts here: https://forms.gle/R6faU74qPRPAzchZ9 > > **Thank you!** ![Viper](.github/logo.png?raw=true) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go#configuration) [![run on repl.it](https://repl.it/badge/github/sagikazarmark/Viper-example)](https://repl.it/@sagikazarmark/Viper-example#main.go) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/spf13/viper/CI?style=flat-square)](https://github.com/spf13/viper/actions?query=workflow%3ACI) [![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Go Report Card](https://goreportcard.com/badge/github.com/spf13/viper?style=flat-square)](https://goreportcard.com/report/github.com/spf13/viper) ![Go Version](https://img.shields.io/badge/go%20version-%3E=1.14-61CFDD.svg?style=flat-square) [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/spf13/viper)](https://pkg.go.dev/mod/github.com/spf13/viper) **Go configuration with fangs!** Many Go projects are built using Viper including: * [Hugo](http://gohugo.io) * [EMC RexRay](http://rexray.readthedocs.org/en/stable/) * [Imgur’s Incus](https://github.com/Imgur/incus) * [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack) * [Docker Notary](https://github.com/docker/Notary) * [BloomApi](https://www.bloomapi.com/) * [doctl](https://github.com/digitalocean/doctl) * [Clairctl](https://github.com/jgsqware/clairctl) * [Mercure](https://mercure.rocks) ## Install ```shell go get github.com/spf13/viper ``` **Note:** Viper uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies. ## What is Viper? Viper is a complete configuration solution for Go applications including 12-Factor apps. It is designed to work within an application, and can handle all types of configuration needs and formats. It supports: * setting defaults * reading from JSON, TOML, YAML, HCL, envfile and Java properties config files * live watching and re-reading of config files (optional) * reading from environment variables * reading from remote config systems (etcd or Consul), and watching changes * reading from command line flags * reading from buffer * setting explicit values Viper can be thought of as a registry for all of your applications configuration needs. ## Why Viper? When building a modern application, you don’t want to worry about configuration file formats; you want to focus on building awesome software. Viper is here to help with that. Viper does the following for you: 1. Find, load, and unmarshal a configuration file in JSON, TOML, YAML, HCL, INI, envfile or Java properties formats. 2. Provide a mechanism to set default values for your different configuration options. 3. Provide a mechanism to set override values for options specified through command line flags. 4. Provide an alias system to easily rename parameters without breaking existing code. 5. Make it easy to tell the difference between when a user has provided a command line or config file which is the same as the default. Viper uses the following precedence order. Each item takes precedence over the item below it: * explicit call to `Set` * flag * env * config * key/value store * default **Important:** Viper configuration keys are case insensitive. There are ongoing discussions about making that optional. ## Putting Values into Viper ### Establishing Defaults A good configuration system will support default values. A default value is not required for a key, but it’s useful in the event that a key hasn't been set via config file, environment variable, remote configuration or flag. Examples: ```go viper.SetDefault("ContentDir", "content") viper.SetDefault("LayoutDir", "layouts") viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"}) ``` ### Reading Config Files Viper requires minimal configuration so it knows where to look for config files. Viper supports JSON, TOML, YAML, HCL, INI, envfile and Java Properties files. Viper can search multiple paths, but currently a single Viper instance only supports a single configuration file. Viper does not default to any configuration search paths leaving defaults decision to an application. Here is an example of how to use Viper to search for and read a configuration file. None of the specific paths are required, but at least one path should be provided where a configuration file is expected. ```go viper.SetConfigName("config") // name of config file (without extension) viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name viper.AddConfigPath("/etc/appname/") // path to look for the config file in viper.AddConfigPath("$HOME/.appname") // call multiple times to add many search paths viper.AddConfigPath(".") // optionally look for config in the working directory err := viper.ReadInConfig() // Find and read the config file if err != nil { // Handle errors reading the config file panic(fmt.Errorf("Fatal error config file: %w \n", err)) } ``` You can handle the specific case where no config file is found like this: ```go if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok { // Config file not found; ignore error if desired } else { // Config file was found but another error was produced } } // Config file found and successfully parsed ``` *NOTE [since 1.6]:* You can also have a file without an extension and specify the format programmaticaly. For those configuration files that lie in the home of the user without any extension like `.bashrc` ### Writing Config Files Reading from config files is useful, but at times you want to store all modifications made at run time. For that, a bunch of commands are available, each with its own purpose: * WriteConfig - writes the current viper configuration to the predefined path, if exists. Errors if no predefined path. Will overwrite the current config file, if it exists. * SafeWriteConfig - writes the current viper configuration to the predefined path. Errors if no predefined path. Will not overwrite the current config file, if it exists. * WriteConfigAs - writes the current viper configuration to the given filepath. Will overwrite the given file, if it exists. * SafeWriteConfigAs - writes the current viper configuration to the given filepath. Will not overwrite the given file, if it exists. As a rule of the thumb, everything marked with safe won't overwrite any file, but just create if not existent, whilst the default behavior is to create or truncate. A small examples section: ```go viper.WriteConfig() // writes current config to predefined path set by 'viper.AddConfigPath()' and 'viper.SetConfigName' viper.SafeWriteConfig() viper.WriteConfigAs("/path/to/my/.config") viper.SafeWriteConfigAs("/path/to/my/.config") // will error since it has already been written viper.SafeWriteConfigAs("/path/to/my/.other_config") ``` ### Watching and re-reading config files Viper supports the ability to have your application live read a config file while running. Gone are the days of needing to restart a server to have a config take effect, viper powered applications can read an update to a config file while running and not miss a beat. Simply tell the viper instance to watchConfig. Optionally you can provide a function for Viper to run each time a change occurs. **Make sure you add all of the configPaths prior to calling `WatchConfig()`** ```go viper.OnConfigChange(func(e fsnotify.Event) { fmt.Println("Config file changed:", e.Name) }) viper.WatchConfig() ``` ### Reading Config from io.Reader Viper predefines many configuration sources such as files, environment variables, flags, and remote K/V store, but you are not bound to them. You can also implement your own required configuration source and feed it to viper. ```go viper.SetConfigType("yaml") // or viper.SetConfigType("YAML") // any approach to require this configuration into your program. var yamlExample = []byte(` Hacker: true name: steve hobbies: - skateboarding - snowboarding - go clothing: jacket: leather trousers: denim age: 35 eyes : brown beard: true `) viper.ReadConfig(bytes.NewBuffer(yamlExample)) viper.Get("name") // this would be "steve" ``` ### Setting Overrides These could be from a command line flag, or from your own application logic. ```go viper.Set("Verbose", true) viper.Set("LogFile", LogFile) ``` ### Registering and Using Aliases Aliases permit a single value to be referenced by multiple keys ```go viper.RegisterAlias("loud", "Verbose") viper.Set("verbose", true) // same result as next line viper.Set("loud", true) // same result as prior line viper.GetBool("loud") // true viper.GetBool("verbose") // true ``` ### Working with Environment Variables Viper has full support for environment variables. This enables 12 factor applications out of the box. There are five methods that exist to aid working with ENV: * `AutomaticEnv()` * `BindEnv(string...) : error` * `SetEnvPrefix(string)` * `SetEnvKeyReplacer(string...) *strings.Replacer` * `AllowEmptyEnv(bool)` _When working with ENV variables, it’s important to recognize that Viper treats ENV variables as case sensitive._ Viper provides a mechanism to try to ensure that ENV variables are unique. By using `SetEnvPrefix`, you can tell Viper to use a prefix while reading from the environment variables. Both `BindEnv` and `AutomaticEnv` will use this prefix. `BindEnv` takes one or more parameters. The first parameter is the key name, the rest are the name of the environment variables to bind to this key. If more than one are provided, they will take precedence in the specified order. The name of the environment variable is case sensitive. If the ENV variable name is not provided, then Viper will automatically assume that the ENV variable matches the following format: prefix + "_" + the key name in ALL CAPS. When you explicitly provide the ENV variable name (the second parameter), it **does not** automatically add the prefix. For example if the second parameter is "id", Viper will look for the ENV variable "ID". One important thing to recognize when working with ENV variables is that the value will be read each time it is accessed. Viper does not fix the value when the `BindEnv` is called. `AutomaticEnv` is a powerful helper especially when combined with `SetEnvPrefix`. When called, Viper will check for an environment variable any time a `viper.Get` request is made. It will apply the following rules. It will check for an environment variable with a name matching the key uppercased and prefixed with the `EnvPrefix` if set. `SetEnvKeyReplacer` allows you to use a `strings.Replacer` object to rewrite Env keys to an extent. This is useful if you want to use `-` or something in your `Get()` calls, but want your environmental variables to use `_` delimiters. An example of using it can be found in `viper_test.go`. Alternatively, you can use `EnvKeyReplacer` with `NewWithOptions` factory function. Unlike `SetEnvKeyReplacer`, it accepts a `StringReplacer` interface allowing you to write custom string replacing logic. By default empty environment variables are considered unset and will fall back to the next configuration source. To treat empty environment variables as set, use the `AllowEmptyEnv` method. #### Env example ```go SetEnvPrefix("spf") // will be uppercased automatically BindEnv("id") os.Setenv("SPF_ID", "13") // typically done outside of the app id := Get("id") // 13 ``` ### Working with Flags Viper has the ability to bind to flags. Specifically, Viper supports `Pflags` as used in the [Cobra](https://github.com/spf13/cobra) library. Like `BindEnv`, the value is not set when the binding method is called, but when it is accessed. This means you can bind as early as you want, even in an `init()` function. For individual flags, the `BindPFlag()` method provides this functionality. Example: ```go serverCmd.Flags().Int("port", 1138, "Port to run Application server on") viper.BindPFlag("port", serverCmd.Flags().Lookup("port")) ``` You can also bind an existing set of pflags (pflag.FlagSet): Example: ```go pflag.Int("flagname", 1234, "help message for flagname") pflag.Parse() viper.BindPFlags(pflag.CommandLine) i := viper.GetInt("flagname") // retrieve values from viper instead of pflag ``` The use of [pflag](https://github.com/spf13/pflag/) in Viper does not preclude the use of other packages that use the [flag](https://golang.org/pkg/flag/) package from the standard library. The pflag package can handle the flags defined for the flag package by importing these flags. This is accomplished by a calling a convenience function provided by the pflag package called AddGoFlagSet(). Example: ```go package main import ( "flag" "github.com/spf13/pflag" ) func main() { // using standard library "flag" package flag.Int("flagname", 1234, "help message for flagname") pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() viper.BindPFlags(pflag.CommandLine) i := viper.GetInt("flagname") // retrieve value from viper // ... } ``` #### Flag interfaces Viper provides two Go interfaces to bind other flag systems if you don’t use `Pflags`. `FlagValue` represents a single flag. This is a very simple example on how to implement this interface: ```go type myFlag struct {} func (f myFlag) HasChanged() bool { return false } func (f myFlag) Name() string { return "my-flag-name" } func (f myFlag) ValueString() string { return "my-flag-value" } func (f myFlag) ValueType() string { return "string" } ``` Once your flag implements this interface, you can simply tell Viper to bind it: ```go viper.BindFlagValue("my-flag-name", myFlag{}) ``` `FlagValueSet` represents a group of flags. This is a very simple example on how to implement this interface: ```go type myFlagSet struct { flags []myFlag } func (f myFlagSet) VisitAll(fn func(FlagValue)) { for _, flag := range flags { fn(flag) } } ``` Once your flag set implements this interface, you can simply tell Viper to bind it: ```go fSet := myFlagSet{ flags: []myFlag{myFlag{}, myFlag{}}, } viper.BindFlagValues("my-flags", fSet) ``` ### Remote Key/Value Store Support To enable remote support in Viper, do a blank import of the `viper/remote` package: `import _ "github.com/spf13/viper/remote"` Viper will read a config string (as JSON, TOML, YAML, HCL or envfile) retrieved from a path in a Key/Value store such as etcd or Consul. These values take precedence over default values, but are overridden by configuration values retrieved from disk, flags, or environment variables. Viper uses [crypt](https://github.com/bketelsen/crypt) to retrieve configuration from the K/V store, which means that you can store your configuration values encrypted and have them automatically decrypted if you have the correct gpg keyring. Encryption is optional. You can use remote configuration in conjunction with local configuration, or independently of it. `crypt` has a command-line helper that you can use to put configurations in your K/V store. `crypt` defaults to etcd on http://127.0.0.1:4001. ```bash $ go get github.com/bketelsen/crypt/bin/crypt $ crypt set -plaintext /config/hugo.json /Users/hugo/settings/config.json ``` Confirm that your value was set: ```bash $ crypt get -plaintext /config/hugo.json ``` See the `crypt` documentation for examples of how to set encrypted values, or how to use Consul. ### Remote Key/Value Store Example - Unencrypted #### etcd ```go viper.AddRemoteProvider("etcd", "http://127.0.0.1:4001","/config/hugo.json") viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv" err := viper.ReadRemoteConfig() ``` #### Consul You need to set a key to Consul key/value storage with JSON value containing your desired config. For example, create a Consul key/value store key `MY_CONSUL_KEY` with value: ```json { "port": 8080, "hostname": "myhostname.com" } ``` ```go viper.AddRemoteProvider("consul", "localhost:8500", "MY_CONSUL_KEY") viper.SetConfigType("json") // Need to explicitly set this to json err := viper.ReadRemoteConfig() fmt.Println(viper.Get("port")) // 8080 fmt.Println(viper.Get("hostname")) // myhostname.com ``` #### Firestore ```go viper.AddRemoteProvider("firestore", "google-cloud-project-id", "collection/document") viper.SetConfigType("json") // Config's format: "json", "toml", "yaml", "yml" err := viper.ReadRemoteConfig() ``` Of course, you're allowed to use `SecureRemoteProvider` also ### Remote Key/Value Store Example - Encrypted ```go viper.AddSecureRemoteProvider("etcd","http://127.0.0.1:4001","/config/hugo.json","/etc/secrets/mykeyring.gpg") viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv" err := viper.ReadRemoteConfig() ``` ### Watching Changes in etcd - Unencrypted ```go // alternatively, you can create a new viper instance. var runtime_viper = viper.New() runtime_viper.AddRemoteProvider("etcd", "http://127.0.0.1:4001", "/config/hugo.yml") runtime_viper.SetConfigType("yaml") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv" // read from remote config the first time. err := runtime_viper.ReadRemoteConfig() // unmarshal config runtime_viper.Unmarshal(&runtime_conf) // open a goroutine to watch remote changes forever go func(){ for { time.Sleep(time.Second * 5) // delay after each request // currently, only tested with etcd support err := runtime_viper.WatchRemoteConfig() if err != nil { log.Errorf("unable to read remote config: %v", err) continue } // unmarshal new config into our runtime config struct. you can also use channel // to implement a signal to notify the system of the changes runtime_viper.Unmarshal(&runtime_conf) } }() ``` ## Getting Values From Viper In Viper, there are a few ways to get a value depending on the value’s type. The following functions and methods exist: * `Get(key string) : interface{}` * `GetBool(key string) : bool` * `GetFloat64(key string) : float64` * `GetInt(key string) : int` * `GetIntSlice(key string) : []int` * `GetString(key string) : string` * `GetStringMap(key string) : map[string]interface{}` * `GetStringMapString(key string) : map[string]string` * `GetStringSlice(key string) : []string` * `GetTime(key string) : time.Time` * `GetDuration(key string) : time.Duration` * `IsSet(key string) : bool` * `AllSettings() : map[string]interface{}` One important thing to recognize is that each Get function will return a zero value if it’s not found. To check if a given key exists, the `IsSet()` method has been provided. Example: ```go viper.GetString("logfile") // case-insensitive Setting & Getting if viper.GetBool("verbose") { fmt.Println("verbose enabled") } ``` ### Accessing nested keys The accessor methods also accept formatted paths to deeply nested keys. For example, if the following JSON file is loaded: ```json { "host": { "address": "localhost", "port": 5799 }, "datastore": { "metric": { "host": "127.0.0.1", "port": 3099 }, "warehouse": { "host": "198.0.0.1", "port": 2112 } } } ``` Viper can access a nested field by passing a `.` delimited path of keys: ```go GetString("datastore.metric.host") // (returns "127.0.0.1") ``` This obeys the precedence rules established above; the search for the path will cascade through the remaining configuration registries until found. For example, given this configuration file, both `datastore.metric.host` and `datastore.metric.port` are already defined (and may be overridden). If in addition `datastore.metric.protocol` was defined in the defaults, Viper would also find it. However, if `datastore.metric` was overridden (by a flag, an environment variable, the `Set()` method, …) with an immediate value, then all sub-keys of `datastore.metric` become undefined, they are “shadowed” by the higher-priority configuration level. Viper can access array indices by using numbers in the path. For example: ```json { "host": { "address": "localhost", "ports": [ 5799, 6029 ] }, "datastore": { "metric": { "host": "127.0.0.1", "port": 3099 }, "warehouse": { "host": "198.0.0.1", "port": 2112 } } } GetInt("host.ports.1") // returns 6029 ``` Lastly, if there exists a key that matches the delimited key path, its value will be returned instead. E.g. ```json { "datastore.metric.host": "0.0.0.0", "host": { "address": "localhost", "port": 5799 }, "datastore": { "metric": { "host": "127.0.0.1", "port": 3099 }, "warehouse": { "host": "198.0.0.1", "port": 2112 } } } GetString("datastore.metric.host") // returns "0.0.0.0" ``` ### Extracting a sub-tree When developing reusable modules, it's often useful to extract a subset of the configuration and pass it to a module. This way the module can be instantiated more than once, with different configurations. For example, an application might use multiple different cache stores for different purposes: ```yaml cache: cache1: max-items: 100 item-size: 64 cache2: max-items: 200 item-size: 80 ``` We could pass the cache name to a module (eg. `NewCache("cache1")`), but it would require weird concatenation for accessing config keys and would be less separated from the global config. So instead of doing that let's pass a Viper instance to the constructor that represents a subset of the configuration: ```go cache1Config := viper.Sub("cache.cache1") if cache1Config == nil { // Sub returns nil if the key cannot be found panic("cache configuration not found") } cache1 := NewCache(cache1Config) ``` **Note:** Always check the return value of `Sub`. It returns `nil` if a key cannot be found. Internally, the `NewCache` function can address `max-items` and `item-size` keys directly: ```go func NewCache(v *Viper) *Cache { return &Cache{ MaxItems: v.GetInt("max-items"), ItemSize: v.GetInt("item-size"), } } ``` The resulting code is easy to test, since it's decoupled from the main config structure, and easier to reuse (for the same reason). ### Unmarshaling You also have the option of Unmarshaling all or a specific value to a struct, map, etc. There are two methods to do this: * `Unmarshal(rawVal interface{}) : error` * `UnmarshalKey(key string, rawVal interface{}) : error` Example: ```go type config struct { Port int Name string PathMap string `mapstructure:"path_map"` } var C config err := viper.Unmarshal(&C) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } ``` If you want to unmarshal configuration where the keys themselves contain dot (the default key delimiter), you have to change the delimiter: ```go v := viper.NewWithOptions(viper.KeyDelimiter("::")) v.SetDefault("chart::values", map[string]interface{}{ "ingress": map[string]interface{}{ "annotations": map[string]interface{}{ "traefik.frontend.rule.type": "PathPrefix", "traefik.ingress.kubernetes.io/ssl-redirect": "true", }, }, }) type config struct { Chart struct{ Values map[string]interface{} } } var C config v.Unmarshal(&C) ``` Viper also supports unmarshaling into embedded structs: ```go /* Example config: module: enabled: true token: 89h3f98hbwf987h3f98wenf89ehf */ type config struct { Module struct { Enabled bool moduleConfig `mapstructure:",squash"` } } // moduleConfig could be in a module specific package type moduleConfig struct { Token string } var C config err := viper.Unmarshal(&C) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } ``` Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshaling values which uses `mapstructure` tags by default. ### Decoding custom formats A frequently requested feature for Viper is adding more value formats and decoders. For example, parsing character (dot, comma, semicolon, etc) separated strings into slices. This is already available in Viper using mapstructure decode hooks. Read more about the details in [this blog post](https://sagikazarmark.hu/blog/decoding-custom-formats-with-viper/). ### Marshalling to string You may need to marshal all the settings held in viper into a string rather than write them to a file. You can use your favorite format's marshaller with the config returned by `AllSettings()`. ```go import ( yaml "gopkg.in/yaml.v2" // ... ) func yamlStringSettings() string { c := viper.AllSettings() bs, err := yaml.Marshal(c) if err != nil { log.Fatalf("unable to marshal config to YAML: %v", err) } return string(bs) } ``` ## Viper or Vipers? Viper comes ready to use out of the box. There is no configuration or initialization needed to begin using Viper. Since most applications will want to use a single central repository for their configuration, the viper package provides this. It is similar to a singleton. In all of the examples above, they demonstrate using viper in its singleton style approach. ### Working with multiple vipers You can also create many different vipers for use in your application. Each will have its own unique set of configurations and values. Each can read from a different config file, key value store, etc. All of the functions that viper package supports are mirrored as methods on a viper. Example: ```go x := viper.New() y := viper.New() x.SetDefault("ContentDir", "content") y.SetDefault("ContentDir", "foobar") //... ``` When working with multiple vipers, it is up to the user to keep track of the different vipers. ## Q & A ### Why is it called “Viper”? A: Viper is designed to be a [companion](http://en.wikipedia.org/wiki/Viper_(G.I._Joe)) to [Cobra](https://github.com/spf13/cobra). While both can operate completely independently, together they make a powerful pair to handle much of your application foundation needs. ### Why is it called “Cobra”? Is there a better name for a [commander](http://en.wikipedia.org/wiki/Cobra_Commander)? ### Does Viper support case sensitive keys? **tl;dr:** No. Viper merges configuration from various sources, many of which are either case insensitive or uses different casing than the rest of the sources (eg. env vars). In order to provide the best experience when using multiple sources, the decision has been made to make all keys case insensitive. There has been several attempts to implement case sensitivity, but unfortunately it's not that trivial. We might take a stab at implementing it in [Viper v2](https://github.com/spf13/viper/issues/772), but despite the initial noise, it does not seem to be requested that much. You can vote for case sensitivity by filling out this feedback form: https://forms.gle/R6faU74qPRPAzchZ9 ### Is it safe to concurrently read and write to a viper? No, you will need to synchronize access to the viper yourself (for example by using the `sync` package). Concurrent reads and writes can cause a panic. ## Troubleshooting See [TROUBLESHOOTING.md](TROUBLESHOOTING.md). viper-1.10.1/TROUBLESHOOTING.md000066400000000000000000000025771415636445600155610ustar00rootroot00000000000000# Troubleshooting ## Unmarshaling doesn't work The most common reason for this issue is improper use of struct tags (eg. `yaml` or `json`). Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshaling values which uses `mapstructure` tags by default. Please refer to the library's documentation for using other struct tags. ## Cannot find package Viper installation seems to fail a lot lately with the following (or a similar) error: ``` cannot find package "github.com/hashicorp/hcl/tree/hcl1" in any of: /usr/local/Cellar/go/1.15.7_1/libexec/src/github.com/hashicorp/hcl/tree/hcl1 (from $GOROOT) /Users/user/go/src/github.com/hashicorp/hcl/tree/hcl1 (from $GOPATH) ``` As the error message suggests, Go tries to look up dependencies in `GOPATH` mode (as it's commonly called) from the `GOPATH`. Viper opted to use [Go Modules](https://github.com/golang/go/wiki/Modules) to manage its dependencies. While in many cases the two methods are interchangeable, once a dependency releases new (major) versions, `GOPATH` mode is no longer able to decide which version to use, so it'll either use one that's already present or pick a version (usually the `master` branch). The solution is easy: switch to using Go Modules. Please refer to the [wiki](https://github.com/golang/go/wiki/Modules) on how to do that. **tl;dr* `export GO111MODULE=on` viper-1.10.1/flags.go000066400000000000000000000025001415636445600143550ustar00rootroot00000000000000package viper import "github.com/spf13/pflag" // FlagValueSet is an interface that users can implement // to bind a set of flags to viper. type FlagValueSet interface { VisitAll(fn func(FlagValue)) } // FlagValue is an interface that users can implement // to bind different flags to viper. type FlagValue interface { HasChanged() bool Name() string ValueString() string ValueType() string } // pflagValueSet is a wrapper around *pflag.ValueSet // that implements FlagValueSet. type pflagValueSet struct { flags *pflag.FlagSet } // VisitAll iterates over all *pflag.Flag inside the *pflag.FlagSet. func (p pflagValueSet) VisitAll(fn func(flag FlagValue)) { p.flags.VisitAll(func(flag *pflag.Flag) { fn(pflagValue{flag}) }) } // pflagValue is a wrapper aroung *pflag.flag // that implements FlagValue type pflagValue struct { flag *pflag.Flag } // HasChanged returns whether the flag has changes or not. func (p pflagValue) HasChanged() bool { return p.flag.Changed } // Name returns the name of the flag. func (p pflagValue) Name() string { return p.flag.Name } // ValueString returns the value of the flag as a string. func (p pflagValue) ValueString() string { return p.flag.Value.String() } // ValueType returns the type of the flag as a string. func (p pflagValue) ValueType() string { return p.flag.Value.Type() } viper-1.10.1/flags_test.go000066400000000000000000000024611415636445600154220ustar00rootroot00000000000000package viper import ( "testing" "github.com/spf13/pflag" "github.com/stretchr/testify/assert" ) func TestBindFlagValueSet(t *testing.T) { flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) testValues := map[string]*string{ "host": nil, "port": nil, "endpoint": nil, } mutatedTestValues := map[string]string{ "host": "localhost", "port": "6060", "endpoint": "/public", } for name := range testValues { testValues[name] = flagSet.String(name, "", "test") } flagValueSet := pflagValueSet{flagSet} err := BindFlagValues(flagValueSet) if err != nil { t.Fatalf("error binding flag set, %v", err) } flagSet.VisitAll(func(flag *pflag.Flag) { flag.Value.Set(mutatedTestValues[flag.Name]) flag.Changed = true }) for name, expected := range mutatedTestValues { assert.Equal(t, Get(name), expected) } } func TestBindFlagValue(t *testing.T) { testString := "testing" testValue := newStringValue(testString, &testString) flag := &pflag.Flag{ Name: "testflag", Value: testValue, Changed: false, } flagValue := pflagValue{flag} BindFlagValue("testvalue", flagValue) assert.Equal(t, testString, Get("testvalue")) flag.Value.Set("testing_mutate") flag.Changed = true // hack for pflag usage assert.Equal(t, "testing_mutate", Get("testvalue")) } viper-1.10.1/fs.go000066400000000000000000000020611415636445600136730ustar00rootroot00000000000000//go:build go1.16 && finder // +build go1.16,finder package viper import ( "errors" "io/fs" "path" ) type finder struct { paths []string fileNames []string extensions []string withoutExtension bool } func (f finder) Find(fsys fs.FS) (string, error) { for _, searchPath := range f.paths { for _, fileName := range f.fileNames { for _, extension := range f.extensions { filePath := path.Join(searchPath, fileName+"."+extension) ok, err := fileExists(fsys, filePath) if err != nil { return "", err } if ok { return filePath, nil } } if f.withoutExtension { filePath := path.Join(searchPath, fileName) ok, err := fileExists(fsys, filePath) if err != nil { return "", err } if ok { return filePath, nil } } } } return "", nil } func fileExists(fsys fs.FS, filePath string) (bool, error) { fileInfo, err := fs.Stat(fsys, filePath) if err == nil { return !fileInfo.IsDir(), nil } if errors.Is(err, fs.ErrNotExist) { return false, nil } return false, err } viper-1.10.1/fs_test.go000066400000000000000000000044251415636445600147400ustar00rootroot00000000000000//go:build go1.16 && finder // +build go1.16,finder package viper import ( "io/fs" "testing" "testing/fstest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestFinder(t *testing.T) { t.Parallel() fsys := fstest.MapFS{ "home/user/.config": &fstest.MapFile{}, "home/user/config.json": &fstest.MapFile{}, "home/user/config.yaml": &fstest.MapFile{}, "home/user/data.json": &fstest.MapFile{}, "etc/config/.config": &fstest.MapFile{}, "etc/config/a_random_file.txt": &fstest.MapFile{}, "etc/config/config.json": &fstest.MapFile{}, "etc/config/config.yaml": &fstest.MapFile{}, "etc/config/config.xml": &fstest.MapFile{}, } testCases := []struct { name string fsys func() fs.FS finder finder result string }{ { name: "find file", fsys: func() fs.FS { return fsys }, finder: finder{ paths: []string{"etc/config"}, fileNames: []string{"config"}, extensions: []string{"json"}, }, result: "etc/config/config.json", }, { name: "file not found", fsys: func() fs.FS { return fsys }, finder: finder{ paths: []string{"var/config"}, fileNames: []string{"config"}, extensions: []string{"json"}, }, result: "", }, { name: "empty search params", fsys: func() fs.FS { return fsys }, finder: finder{}, result: "", }, { name: "precedence", fsys: func() fs.FS { return fsys }, finder: finder{ paths: []string{"var/config", "home/user", "etc/config"}, fileNames: []string{"aconfig", "config"}, extensions: []string{"zml", "xml", "json"}, }, result: "home/user/config.json", }, { name: "without extension", fsys: func() fs.FS { return fsys }, finder: finder{ paths: []string{"var/config", "home/user", "etc/config"}, fileNames: []string{".config"}, extensions: []string{"zml", "xml", "json"}, withoutExtension: true, }, result: "home/user/.config", }, } for _, testCase := range testCases { testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() fsys := testCase.fsys() result, err := testCase.finder.Find(fsys) require.NoError(t, err) assert.Equal(t, testCase.result, result) }) } } viper-1.10.1/go.mod000066400000000000000000000057631415636445600140560ustar00rootroot00000000000000module github.com/spf13/viper go 1.17 require ( github.com/fsnotify/fsnotify v1.5.1 github.com/hashicorp/hcl v1.0.0 github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.3 github.com/pelletier/go-toml v1.9.4 github.com/sagikazarmark/crypt v0.4.0 github.com/spf13/afero v1.6.0 github.com/spf13/cast v1.4.1 github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 github.com/subosito/gotenv v1.2.0 gopkg.in/ini.v1 v1.66.2 gopkg.in/yaml.v2 v2.4.0 ) require ( cloud.google.com/go v0.99.0 // indirect cloud.google.com/go/firestore v1.6.1 // indirect github.com/armon/go-metrics v0.3.10 // indirect github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/envoyproxy/go-control-plane v0.10.1 // indirect github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect github.com/fatih/color v1.13.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/googleapis/gax-go/v2 v2.1.1 // indirect github.com/hashicorp/consul/api v1.12.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.0.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/serf v0.9.6 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.etcd.io/etcd/api/v3 v3.5.1 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect go.etcd.io/etcd/client/v2 v2.305.1 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/api v0.63.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) viper-1.10.1/go.sum000066400000000000000000002357551415636445600141110ustar00rootroot00000000000000cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go v0.99.0 h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.6.1 h1:8rBq3zRjnHx8UtBvaOWqBB1xq9jH6/wltfQLlTMh2Fw= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0 h1:t/LhUZLVitR1Ow2YOnduCsavhwFUklBMoGVYUCqmCqk= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 h1:hzAQntlaYRkVSFEfj9OTWlVV1H155FMD8BTKktLv0QI= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 h1:KwaoQzs/WeUxxJqiJsZ4euOly1Az/IgZXXSxlD/UBNk= github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.1 h1:cgDRLG7bs59Zd+apAWuzLQL95obVYAymNJek76W3mgw= github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.2 h1:JiO+kJTpmYGjEodY7O1Zk8oZcNz1+f30UtwtXoFUPzE= github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.12.0 h1:k3y1FYv6nuKyNTqj6w9gXOx5r5CfLj/k/euUeBXj1OY= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.0.0 h1:bkKf0BeBXcSYa7f5Fyi9gMuQ8gNsxeiNpZjR6VxNZeo= github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= github.com/hashicorp/memberlist v0.3.0 h1:8+567mCcFDnS5ADl7lrpxPMWiFCElyUEeW0gtj34fMA= github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.9.6 h1:uuEX1kLR6aoda1TBttmJQKDLZE1Ob7KN0NPdE7EtCDc= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.4.0 h1:Rqcx6Sf/bWQUmmfGQhcFx3wQQEfb2UZWhAKvGRairm0= github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/etcd/api/v3 v3.5.1 h1:v28cktvBq+7vGyJXF8G+rWJmj+1XUmMtqcLnH8hDocM= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.1 h1:XIQcHCFSG53bJETYeRJtIxdLv2EWRGxcfzR8lSnTH4E= go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.1 h1:vtxYCKWA9x31w0WJj7DdqsHFNjhkigdAnziDtkZb/l4= go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= google.golang.org/api v0.63.0 h1:n2bqqK895ygnBpdPDYetfy23K7fJ22wsrZKCyfuRkkA= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa h1:I0YcKz0I7OAhddo7ya8kMnvprhcWM045PmkBdMO9zN0= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.43.0 h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM= google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= viper-1.10.1/internal/000077500000000000000000000000001415636445600145515ustar00rootroot00000000000000viper-1.10.1/internal/encoding/000077500000000000000000000000001415636445600163375ustar00rootroot00000000000000viper-1.10.1/internal/encoding/decoder.go000066400000000000000000000031151415636445600202730ustar00rootroot00000000000000package encoding import ( "sync" ) // Decoder decodes the contents of b into a v representation. // It's primarily used for decoding contents of a file into a map[string]interface{}. type Decoder interface { Decode(b []byte, v interface{}) error } const ( // ErrDecoderNotFound is returned when there is no decoder registered for a format. ErrDecoderNotFound = encodingError("decoder not found for this format") // ErrDecoderFormatAlreadyRegistered is returned when an decoder is already registered for a format. ErrDecoderFormatAlreadyRegistered = encodingError("decoder already registered for this format") ) // DecoderRegistry can choose an appropriate Decoder based on the provided format. type DecoderRegistry struct { decoders map[string]Decoder mu sync.RWMutex } // NewDecoderRegistry returns a new, initialized DecoderRegistry. func NewDecoderRegistry() *DecoderRegistry { return &DecoderRegistry{ decoders: make(map[string]Decoder), } } // RegisterDecoder registers a Decoder for a format. // Registering a Decoder for an already existing format is not supported. func (e *DecoderRegistry) RegisterDecoder(format string, enc Decoder) error { e.mu.Lock() defer e.mu.Unlock() if _, ok := e.decoders[format]; ok { return ErrDecoderFormatAlreadyRegistered } e.decoders[format] = enc return nil } // Decode calls the underlying Decoder based on the format. func (e *DecoderRegistry) Decode(format string, b []byte, v interface{}) error { e.mu.RLock() decoder, ok := e.decoders[format] e.mu.RUnlock() if !ok { return ErrDecoderNotFound } return decoder.Decode(b, v) } viper-1.10.1/internal/encoding/decoder_test.go000066400000000000000000000027561415636445600213440ustar00rootroot00000000000000package encoding import ( "testing" ) type decoder struct { v interface{} } func (d decoder) Decode(_ []byte, v interface{}) error { rv := v.(*string) *rv = d.v.(string) return nil } func TestDecoderRegistry_RegisterDecoder(t *testing.T) { t.Run("OK", func(t *testing.T) { registry := NewDecoderRegistry() err := registry.RegisterDecoder("myformat", decoder{}) if err != nil { t.Fatal(err) } }) t.Run("AlreadyRegistered", func(t *testing.T) { registry := NewDecoderRegistry() err := registry.RegisterDecoder("myformat", decoder{}) if err != nil { t.Fatal(err) } err = registry.RegisterDecoder("myformat", decoder{}) if err != ErrDecoderFormatAlreadyRegistered { t.Fatalf("expected ErrDecoderFormatAlreadyRegistered, got: %v", err) } }) } func TestDecoderRegistry_Decode(t *testing.T) { t.Run("OK", func(t *testing.T) { registry := NewDecoderRegistry() decoder := decoder{ v: "decoded value", } err := registry.RegisterDecoder("myformat", decoder) if err != nil { t.Fatal(err) } var v string err = registry.Decode("myformat", []byte("some value"), &v) if err != nil { t.Fatal(err) } if v != "decoded value" { t.Fatalf("expected 'decoded value', got: %#v", v) } }) t.Run("DecoderNotFound", func(t *testing.T) { registry := NewDecoderRegistry() var v string err := registry.Decode("myformat", []byte("some value"), &v) if err != ErrDecoderNotFound { t.Fatalf("expected ErrDecoderNotFound, got: %v", err) } }) } viper-1.10.1/internal/encoding/encoder.go000066400000000000000000000030221415636445600203020ustar00rootroot00000000000000package encoding import ( "sync" ) // Encoder encodes the contents of v into a byte representation. // It's primarily used for encoding a map[string]interface{} into a file format. type Encoder interface { Encode(v interface{}) ([]byte, error) } const ( // ErrEncoderNotFound is returned when there is no encoder registered for a format. ErrEncoderNotFound = encodingError("encoder not found for this format") // ErrEncoderFormatAlreadyRegistered is returned when an encoder is already registered for a format. ErrEncoderFormatAlreadyRegistered = encodingError("encoder already registered for this format") ) // EncoderRegistry can choose an appropriate Encoder based on the provided format. type EncoderRegistry struct { encoders map[string]Encoder mu sync.RWMutex } // NewEncoderRegistry returns a new, initialized EncoderRegistry. func NewEncoderRegistry() *EncoderRegistry { return &EncoderRegistry{ encoders: make(map[string]Encoder), } } // RegisterEncoder registers an Encoder for a format. // Registering a Encoder for an already existing format is not supported. func (e *EncoderRegistry) RegisterEncoder(format string, enc Encoder) error { e.mu.Lock() defer e.mu.Unlock() if _, ok := e.encoders[format]; ok { return ErrEncoderFormatAlreadyRegistered } e.encoders[format] = enc return nil } func (e *EncoderRegistry) Encode(format string, v interface{}) ([]byte, error) { e.mu.RLock() encoder, ok := e.encoders[format] e.mu.RUnlock() if !ok { return nil, ErrEncoderNotFound } return encoder.Encode(v) } viper-1.10.1/internal/encoding/encoder_test.go000066400000000000000000000026551415636445600213540ustar00rootroot00000000000000package encoding import ( "testing" ) type encoder struct { b []byte } func (e encoder) Encode(_ interface{}) ([]byte, error) { return e.b, nil } func TestEncoderRegistry_RegisterEncoder(t *testing.T) { t.Run("OK", func(t *testing.T) { registry := NewEncoderRegistry() err := registry.RegisterEncoder("myformat", encoder{}) if err != nil { t.Fatal(err) } }) t.Run("AlreadyRegistered", func(t *testing.T) { registry := NewEncoderRegistry() err := registry.RegisterEncoder("myformat", encoder{}) if err != nil { t.Fatal(err) } err = registry.RegisterEncoder("myformat", encoder{}) if err != ErrEncoderFormatAlreadyRegistered { t.Fatalf("expected ErrEncoderFormatAlreadyRegistered, got: %v", err) } }) } func TestEncoderRegistry_Decode(t *testing.T) { t.Run("OK", func(t *testing.T) { registry := NewEncoderRegistry() encoder := encoder{ b: []byte("encoded value"), } err := registry.RegisterEncoder("myformat", encoder) if err != nil { t.Fatal(err) } b, err := registry.Encode("myformat", "some value") if err != nil { t.Fatal(err) } if string(b) != "encoded value" { t.Fatalf("expected 'encoded value', got: %#v", string(b)) } }) t.Run("EncoderNotFound", func(t *testing.T) { registry := NewEncoderRegistry() _, err := registry.Encode("myformat", "some value") if err != ErrEncoderNotFound { t.Fatalf("expected ErrEncoderNotFound, got: %v", err) } }) } viper-1.10.1/internal/encoding/error.go000066400000000000000000000001511415636445600200140ustar00rootroot00000000000000package encoding type encodingError string func (e encodingError) Error() string { return string(e) } viper-1.10.1/internal/encoding/hcl/000077500000000000000000000000001415636445600171055ustar00rootroot00000000000000viper-1.10.1/internal/encoding/hcl/codec.go000066400000000000000000000013461415636445600205150ustar00rootroot00000000000000package hcl import ( "bytes" "encoding/json" "github.com/hashicorp/hcl" "github.com/hashicorp/hcl/hcl/printer" ) // Codec implements the encoding.Encoder and encoding.Decoder interfaces for HCL encoding. // TODO: add printer config to the codec? type Codec struct{} func (Codec) Encode(v interface{}) ([]byte, error) { b, err := json.Marshal(v) if err != nil { return nil, err } // TODO: use printer.Format? Is the trailing newline an issue? ast, err := hcl.Parse(string(b)) if err != nil { return nil, err } var buf bytes.Buffer err = printer.Fprint(&buf, ast.Node) if err != nil { return nil, err } return buf.Bytes(), nil } func (Codec) Decode(b []byte, v interface{}) error { return hcl.Unmarshal(b, v) } viper-1.10.1/internal/encoding/json/000077500000000000000000000000001415636445600173105ustar00rootroot00000000000000viper-1.10.1/internal/encoding/json/codec.go000066400000000000000000000006141415636445600207150ustar00rootroot00000000000000package json import ( "encoding/json" ) // Codec implements the encoding.Encoder and encoding.Decoder interfaces for JSON encoding. type Codec struct{} func (Codec) Encode(v interface{}) ([]byte, error) { // TODO: expose prefix and indent in the Codec as setting? return json.MarshalIndent(v, "", " ") } func (Codec) Decode(b []byte, v interface{}) error { return json.Unmarshal(b, v) } viper-1.10.1/internal/encoding/toml/000077500000000000000000000000001415636445600173125ustar00rootroot00000000000000viper-1.10.1/internal/encoding/toml/codec.go000066400000000000000000000013741415636445600207230ustar00rootroot00000000000000package toml import ( "github.com/pelletier/go-toml" ) // Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding. type Codec struct{} func (Codec) Encode(v interface{}) ([]byte, error) { if m, ok := v.(map[string]interface{}); ok { t, err := toml.TreeFromMap(m) if err != nil { return nil, err } s, err := t.ToTomlString() if err != nil { return nil, err } return []byte(s), nil } return toml.Marshal(v) } func (Codec) Decode(b []byte, v interface{}) error { tree, err := toml.LoadBytes(b) if err != nil { return err } if m, ok := v.(*map[string]interface{}); ok { vmap := *m tmap := tree.ToMap() for k, v := range tmap { vmap[k] = v } return nil } return tree.Unmarshal(v) } viper-1.10.1/internal/encoding/yaml/000077500000000000000000000000001415636445600173015ustar00rootroot00000000000000viper-1.10.1/internal/encoding/yaml/codec.go000066400000000000000000000004761415636445600207140ustar00rootroot00000000000000package yaml import "gopkg.in/yaml.v2" // Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding. type Codec struct{} func (Codec) Encode(v interface{}) ([]byte, error) { return yaml.Marshal(v) } func (Codec) Decode(b []byte, v interface{}) error { return yaml.Unmarshal(b, v) } viper-1.10.1/internal/testutil/000077500000000000000000000000001415636445600164265ustar00rootroot00000000000000viper-1.10.1/internal/testutil/env_go1_16.go000066400000000000000000000016631415636445600206270ustar00rootroot00000000000000//go:build !go1.17 // +build !go1.17 package testutil import ( "os" "testing" ) // Based on https://github.com/frankban/quicktest/blob/577841610793d24f99e31cc2c0ef3a541fefd7c7/patch.go#L34-L64 // Licensed under the MIT license // Copyright (c) 2017 Canonical Ltd. // Setenv sets an environment variable to a temporary value for the // duration of the test. // // At the end of the test (see "Deferred execution" in the package docs), the // environment variable is returned to its original value. func Setenv(t *testing.T, name, val string) { setenv(t, name, val, true) } // setenv sets or unsets an environment variable to a temporary value for the // duration of the test func setenv(t *testing.T, name, val string, valOK bool) { oldVal, oldOK := os.LookupEnv(name) if valOK { os.Setenv(name, val) } else { os.Unsetenv(name) } t.Cleanup(func() { if oldOK { os.Setenv(name, oldVal) } else { os.Unsetenv(name) } }) } viper-1.10.1/internal/testutil/env_go1_17.go000066400000000000000000000005011415636445600206160ustar00rootroot00000000000000//go:build go1.17 // +build go1.17 package testutil import ( "testing" ) // Setenv sets an environment variable to a temporary value for the // duration of the test. // // This shim can be removed once support for Go <1.17 is dropped. func Setenv(t *testing.T, name, val string) { t.Helper() t.Setenv(name, val) } viper-1.10.1/internal/testutil/filepath.go000066400000000000000000000003651415636445600205550ustar00rootroot00000000000000package testutil import ( "path/filepath" "testing" ) // AbsFilePath calls filepath.Abs on path. func AbsFilePath(t *testing.T, path string) string { t.Helper() s, err := filepath.Abs(path) if err != nil { t.Fatal(err) } return s } viper-1.10.1/logger.go000066400000000000000000000037561415636445600145560ustar00rootroot00000000000000package viper import ( "fmt" jww "github.com/spf13/jwalterweatherman" ) // Logger is a unified interface for various logging use cases and practices, including: // - leveled logging // - structured logging type Logger interface { // Trace logs a Trace event. // // Even more fine-grained information than Debug events. // Loggers not supporting this level should fall back to Debug. Trace(msg string, keyvals ...interface{}) // Debug logs a Debug event. // // A verbose series of information events. // They are useful when debugging the system. Debug(msg string, keyvals ...interface{}) // Info logs an Info event. // // General information about what's happening inside the system. Info(msg string, keyvals ...interface{}) // Warn logs a Warn(ing) event. // // Non-critical events that should be looked at. Warn(msg string, keyvals ...interface{}) // Error logs an Error event. // // Critical events that require immediate attention. // Loggers commonly provide Fatal and Panic levels above Error level, // but exiting and panicing is out of scope for a logging library. Error(msg string, keyvals ...interface{}) } type jwwLogger struct{} func (jwwLogger) Trace(msg string, keyvals ...interface{}) { jww.TRACE.Printf(jwwLogMessage(msg, keyvals...)) } func (jwwLogger) Debug(msg string, keyvals ...interface{}) { jww.DEBUG.Printf(jwwLogMessage(msg, keyvals...)) } func (jwwLogger) Info(msg string, keyvals ...interface{}) { jww.INFO.Printf(jwwLogMessage(msg, keyvals...)) } func (jwwLogger) Warn(msg string, keyvals ...interface{}) { jww.WARN.Printf(jwwLogMessage(msg, keyvals...)) } func (jwwLogger) Error(msg string, keyvals ...interface{}) { jww.ERROR.Printf(jwwLogMessage(msg, keyvals...)) } func jwwLogMessage(msg string, keyvals ...interface{}) string { out := msg if len(keyvals) > 0 && len(keyvals)%2 == 1 { keyvals = append(keyvals, nil) } for i := 0; i <= len(keyvals)-2; i += 2 { out = fmt.Sprintf("%s %v=%v", out, keyvals[i], keyvals[i+1]) } return out } viper-1.10.1/overrides_test.go000066400000000000000000000144041415636445600163300ustar00rootroot00000000000000package viper import ( "fmt" "strings" "testing" "github.com/spf13/cast" "github.com/stretchr/testify/assert" ) type layer int const ( defaultLayer layer = iota + 1 overrideLayer ) func TestNestedOverrides(t *testing.T) { assert := assert.New(t) var v *Viper // Case 0: value overridden by a value overrideDefault(assert, "tom", 10, "tom", 20) // "tom" is first given 10 as default value, then overridden by 20 override(assert, "tom", 10, "tom", 20) // "tom" is first given value 10, then overridden by 20 overrideDefault(assert, "tom.age", 10, "tom.age", 20) override(assert, "tom.age", 10, "tom.age", 20) overrideDefault(assert, "sawyer.tom.age", 10, "sawyer.tom.age", 20) override(assert, "sawyer.tom.age", 10, "sawyer.tom.age", 20) // Case 1: key:value overridden by a value v = overrideDefault(assert, "tom.age", 10, "tom", "boy") // "tom.age" is first given 10 as default value, then "tom" is overridden by "boy" assert.Nil(v.Get("tom.age")) // "tom.age" should not exist anymore v = override(assert, "tom.age", 10, "tom", "boy") assert.Nil(v.Get("tom.age")) // Case 2: value overridden by a key:value overrideDefault(assert, "tom", "boy", "tom.age", 10) // "tom" is first given "boy" as default value, then "tom" is overridden by map{"age":10} override(assert, "tom.age", 10, "tom", "boy") // Case 3: key:value overridden by a key:value v = overrideDefault(assert, "tom.size", 4, "tom.age", 10) assert.Equal(4, v.Get("tom.size")) // value should still be reachable v = override(assert, "tom.size", 4, "tom.age", 10) assert.Equal(4, v.Get("tom.size")) deepCheckValue(assert, v, overrideLayer, []string{"tom", "size"}, 4) // Case 4: key:value overridden by a map v = overrideDefault(assert, "tom.size", 4, "tom", map[string]interface{}{"age": 10}) // "tom.size" is first given "4" as default value, then "tom" is overridden by map{"age":10} assert.Equal(4, v.Get("tom.size")) // "tom.size" should still be reachable assert.Equal(10, v.Get("tom.age")) // new value should be there deepCheckValue(assert, v, overrideLayer, []string{"tom", "age"}, 10) // new value should be there v = override(assert, "tom.size", 4, "tom", map[string]interface{}{"age": 10}) assert.Nil(v.Get("tom.size")) assert.Equal(10, v.Get("tom.age")) deepCheckValue(assert, v, overrideLayer, []string{"tom", "age"}, 10) // Case 5: array overridden by a value overrideDefault(assert, "tom", []int{10, 20}, "tom", 30) override(assert, "tom", []int{10, 20}, "tom", 30) overrideDefault(assert, "tom.age", []int{10, 20}, "tom.age", 30) override(assert, "tom.age", []int{10, 20}, "tom.age", 30) // Case 6: array overridden by an array overrideDefault(assert, "tom", []int{10, 20}, "tom", []int{30, 40}) override(assert, "tom", []int{10, 20}, "tom", []int{30, 40}) overrideDefault(assert, "tom.age", []int{10, 20}, "tom.age", []int{30, 40}) v = override(assert, "tom.age", []int{10, 20}, "tom.age", []int{30, 40}) // explicit array merge: s, ok := v.Get("tom.age").([]int) if assert.True(ok, "tom[\"age\"] is not a slice") { v.Set("tom.age", append(s, []int{50, 60}...)) assert.Equal([]int{30, 40, 50, 60}, v.Get("tom.age")) deepCheckValue(assert, v, overrideLayer, []string{"tom", "age"}, []int{30, 40, 50, 60}) } } func overrideDefault(assert *assert.Assertions, firstPath string, firstValue interface{}, secondPath string, secondValue interface{}) *Viper { return overrideFromLayer(defaultLayer, assert, firstPath, firstValue, secondPath, secondValue) } func override(assert *assert.Assertions, firstPath string, firstValue interface{}, secondPath string, secondValue interface{}) *Viper { return overrideFromLayer(overrideLayer, assert, firstPath, firstValue, secondPath, secondValue) } // overrideFromLayer performs the sequential override and low-level checks. // // First assignment is made on layer l for path firstPath with value firstValue, // the second one on the override layer (i.e., with the Set() function) // for path secondPath with value secondValue. // // firstPath and secondPath can include an arbitrary number of dots to indicate // a nested element. // // After each assignment, the value is checked, retrieved both by its full path // and by its key sequence (successive maps). func overrideFromLayer(l layer, assert *assert.Assertions, firstPath string, firstValue interface{}, secondPath string, secondValue interface{}) *Viper { v := New() firstKeys := strings.Split(firstPath, v.keyDelim) if assert == nil || len(firstKeys) == 0 || len(firstKeys[0]) == 0 { return v } // Set and check first value switch l { case defaultLayer: v.SetDefault(firstPath, firstValue) case overrideLayer: v.Set(firstPath, firstValue) default: return v } assert.Equal(firstValue, v.Get(firstPath)) deepCheckValue(assert, v, l, firstKeys, firstValue) // Override and check new value secondKeys := strings.Split(secondPath, v.keyDelim) if len(secondKeys) == 0 || len(secondKeys[0]) == 0 { return v } v.Set(secondPath, secondValue) assert.Equal(secondValue, v.Get(secondPath)) deepCheckValue(assert, v, overrideLayer, secondKeys, secondValue) return v } // deepCheckValue checks that all given keys correspond to a valid path in the // configuration map of the given layer, and that the final value equals the one given func deepCheckValue(assert *assert.Assertions, v *Viper, l layer, keys []string, value interface{}) { if assert == nil || v == nil || len(keys) == 0 || len(keys[0]) == 0 { return } // init var val interface{} var ms string switch l { case defaultLayer: val = v.defaults ms = "v.defaults" case overrideLayer: val = v.override ms = "v.override" } // loop through map var m map[string]interface{} err := false for _, k := range keys { if val == nil { assert.Fail(fmt.Sprintf("%s is not a map[string]interface{}", ms)) return } // deep scan of the map to get the final value switch val.(type) { case map[interface{}]interface{}: m = cast.ToStringMap(val) case map[string]interface{}: m = val.(map[string]interface{}) default: assert.Fail(fmt.Sprintf("%s is not a map[string]interface{}", ms)) return } ms = ms + "[\"" + k + "\"]" val = m[k] } if !err { assert.Equal(value, val) } } viper-1.10.1/remote/000077500000000000000000000000001415636445600142305ustar00rootroot00000000000000viper-1.10.1/remote/remote.go000066400000000000000000000052111415636445600160510ustar00rootroot00000000000000// Copyright © 2015 Steve Francia . // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. // Package remote integrates the remote features of Viper. package remote import ( "bytes" "io" "os" crypt "github.com/sagikazarmark/crypt/config" "github.com/spf13/viper" ) type remoteConfigProvider struct{} func (rc remoteConfigProvider) Get(rp viper.RemoteProvider) (io.Reader, error) { cm, err := getConfigManager(rp) if err != nil { return nil, err } b, err := cm.Get(rp.Path()) if err != nil { return nil, err } return bytes.NewReader(b), nil } func (rc remoteConfigProvider) Watch(rp viper.RemoteProvider) (io.Reader, error) { cm, err := getConfigManager(rp) if err != nil { return nil, err } resp, err := cm.Get(rp.Path()) if err != nil { return nil, err } return bytes.NewReader(resp), nil } func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.RemoteResponse, chan bool) { cm, err := getConfigManager(rp) if err != nil { return nil, nil } quit := make(chan bool) quitwc := make(chan bool) viperResponsCh := make(chan *viper.RemoteResponse) cryptoResponseCh := cm.Watch(rp.Path(), quit) // need this function to convert the Channel response form crypt.Response to viper.Response go func(cr <-chan *crypt.Response, vr chan<- *viper.RemoteResponse, quitwc <-chan bool, quit chan<- bool) { for { select { case <-quitwc: quit <- true return case resp := <-cr: vr <- &viper.RemoteResponse{ Error: resp.Error, Value: resp.Value, } } } }(cryptoResponseCh, viperResponsCh, quitwc, quit) return viperResponsCh, quitwc } func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) { var cm crypt.ConfigManager var err error if rp.SecretKeyring() != "" { var kr *os.File kr, err = os.Open(rp.SecretKeyring()) if err != nil { return nil, err } defer kr.Close() switch rp.Provider() { case "etcd": cm, err = crypt.NewEtcdConfigManager([]string{rp.Endpoint()}, kr) case "firestore": cm, err = crypt.NewFirestoreConfigManager([]string{rp.Endpoint()}, kr) default: cm, err = crypt.NewConsulConfigManager([]string{rp.Endpoint()}, kr) } } else { switch rp.Provider() { case "etcd": cm, err = crypt.NewStandardEtcdConfigManager([]string{rp.Endpoint()}) case "firestore": cm, err = crypt.NewStandardFirestoreConfigManager([]string{rp.Endpoint()}) default: cm, err = crypt.NewStandardConsulConfigManager([]string{rp.Endpoint()}) } } if err != nil { return nil, err } return cm, nil } func init() { viper.RemoteConfig = &remoteConfigProvider{} } viper-1.10.1/util.go000066400000000000000000000115641415636445600142500ustar00rootroot00000000000000// Copyright © 2014 Steve Francia . // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. // Viper is a application configuration system. // It believes that applications can be configured a variety of ways // via flags, ENVIRONMENT variables, configuration files retrieved // from the file system, or a remote key/value store. package viper import ( "fmt" "os" "path/filepath" "runtime" "strings" "unicode" "github.com/spf13/cast" ) // ConfigParseError denotes failing to parse configuration file. type ConfigParseError struct { err error } // Error returns the formatted configuration error. func (pe ConfigParseError) Error() string { return fmt.Sprintf("While parsing config: %s", pe.err.Error()) } // toCaseInsensitiveValue checks if the value is a map; // if so, create a copy and lower-case the keys recursively. func toCaseInsensitiveValue(value interface{}) interface{} { switch v := value.(type) { case map[interface{}]interface{}: value = copyAndInsensitiviseMap(cast.ToStringMap(v)) case map[string]interface{}: value = copyAndInsensitiviseMap(v) } return value } // copyAndInsensitiviseMap behaves like insensitiviseMap, but creates a copy of // any map it makes case insensitive. func copyAndInsensitiviseMap(m map[string]interface{}) map[string]interface{} { nm := make(map[string]interface{}) for key, val := range m { lkey := strings.ToLower(key) switch v := val.(type) { case map[interface{}]interface{}: nm[lkey] = copyAndInsensitiviseMap(cast.ToStringMap(v)) case map[string]interface{}: nm[lkey] = copyAndInsensitiviseMap(v) default: nm[lkey] = v } } return nm } func insensitiviseMap(m map[string]interface{}) { for key, val := range m { switch val.(type) { case map[interface{}]interface{}: // nested map: cast and recursively insensitivise val = cast.ToStringMap(val) insensitiviseMap(val.(map[string]interface{})) case map[string]interface{}: // nested map: recursively insensitivise insensitiviseMap(val.(map[string]interface{})) } lower := strings.ToLower(key) if key != lower { // remove old key (not lower-cased) delete(m, key) } // update map m[lower] = val } } func absPathify(logger Logger, inPath string) string { logger.Info("trying to resolve absolute path", "path", inPath) if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) { inPath = userHomeDir() + inPath[5:] } inPath = os.ExpandEnv(inPath) if filepath.IsAbs(inPath) { return filepath.Clean(inPath) } p, err := filepath.Abs(inPath) if err == nil { return filepath.Clean(p) } logger.Error(fmt.Errorf("could not discover absolute path: %w", err).Error()) return "" } func stringInSlice(a string, list []string) bool { for _, b := range list { if b == a { return true } } return false } func userHomeDir() string { if runtime.GOOS == "windows" { home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") if home == "" { home = os.Getenv("USERPROFILE") } return home } return os.Getenv("HOME") } func safeMul(a, b uint) uint { c := a * b if a > 1 && b > 1 && c/b != a { return 0 } return c } // parseSizeInBytes converts strings like 1GB or 12 mb into an unsigned integer number of bytes func parseSizeInBytes(sizeStr string) uint { sizeStr = strings.TrimSpace(sizeStr) lastChar := len(sizeStr) - 1 multiplier := uint(1) if lastChar > 0 { if sizeStr[lastChar] == 'b' || sizeStr[lastChar] == 'B' { if lastChar > 1 { switch unicode.ToLower(rune(sizeStr[lastChar-1])) { case 'k': multiplier = 1 << 10 sizeStr = strings.TrimSpace(sizeStr[:lastChar-1]) case 'm': multiplier = 1 << 20 sizeStr = strings.TrimSpace(sizeStr[:lastChar-1]) case 'g': multiplier = 1 << 30 sizeStr = strings.TrimSpace(sizeStr[:lastChar-1]) default: multiplier = 1 sizeStr = strings.TrimSpace(sizeStr[:lastChar]) } } } } size := cast.ToInt(sizeStr) if size < 0 { size = 0 } return safeMul(uint(size), multiplier) } // deepSearch scans deep maps, following the key indexes listed in the // sequence "path". // The last value is expected to be another map, and is returned. // // In case intermediate keys do not exist, or map to a non-map value, // a new map is created and inserted, and the search continues from there: // the initial map "m" may be modified! func deepSearch(m map[string]interface{}, path []string) map[string]interface{} { for _, k := range path { m2, ok := m[k] if !ok { // intermediate key does not exist // => create it and continue from there m3 := make(map[string]interface{}) m[k] = m3 m = m3 continue } m3, ok := m2.(map[string]interface{}) if !ok { // intermediate key is a value // => replace with a new map m3 = make(map[string]interface{}) m[k] = m3 } // continue search from here m = m3 } return m } viper-1.10.1/util_test.go000066400000000000000000000042331415636445600153020ustar00rootroot00000000000000// Copyright © 2016 Steve Francia . // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. // Viper is a application configuration system. // It believes that applications can be configured a variety of ways // via flags, ENVIRONMENT variables, configuration files retrieved // from the file system, or a remote key/value store. package viper import ( "os" "path/filepath" "reflect" "testing" "github.com/spf13/viper/internal/testutil" ) func TestCopyAndInsensitiviseMap(t *testing.T) { var ( given = map[string]interface{}{ "Foo": 32, "Bar": map[interface{}]interface{}{ "ABc": "A", "cDE": "B", }, } expected = map[string]interface{}{ "foo": 32, "bar": map[string]interface{}{ "abc": "A", "cde": "B", }, } ) got := copyAndInsensitiviseMap(given) if !reflect.DeepEqual(got, expected) { t.Fatalf("Got %q\nexpected\n%q", got, expected) } if _, ok := given["foo"]; ok { t.Fatal("Input map changed") } if _, ok := given["bar"]; ok { t.Fatal("Input map changed") } m := given["Bar"].(map[interface{}]interface{}) if _, ok := m["ABc"]; !ok { t.Fatal("Input map changed") } } func TestAbsPathify(t *testing.T) { skipWindows(t) home := userHomeDir() homer := filepath.Join(home, "homer") wd, _ := os.Getwd() testutil.Setenv(t, "HOMER_ABSOLUTE_PATH", homer) testutil.Setenv(t, "VAR_WITH_RELATIVE_PATH", "relative") tests := []struct { input string output string }{ {"", wd}, {"sub", filepath.Join(wd, "sub")}, {"./", wd}, {"./sub", filepath.Join(wd, "sub")}, {"$HOME", home}, {"$HOME/", home}, {"$HOME/sub", filepath.Join(home, "sub")}, {"$HOMER_ABSOLUTE_PATH", homer}, {"$HOMER_ABSOLUTE_PATH/", homer}, {"$HOMER_ABSOLUTE_PATH/sub", filepath.Join(homer, "sub")}, {"$VAR_WITH_RELATIVE_PATH", filepath.Join(wd, "relative")}, {"$VAR_WITH_RELATIVE_PATH/", filepath.Join(wd, "relative")}, {"$VAR_WITH_RELATIVE_PATH/sub", filepath.Join(wd, "relative", "sub")}, } for _, test := range tests { got := absPathify(jwwLogger{}, test.input) if got != test.output { t.Errorf("Got %v\nexpected\n%q", got, test.output) } } } viper-1.10.1/viper.go000066400000000000000000001676531415636445600144330ustar00rootroot00000000000000// Copyright © 2014 Steve Francia . // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. // Viper is an application configuration system. // It believes that applications can be configured a variety of ways // via flags, ENVIRONMENT variables, configuration files retrieved // from the file system, or a remote key/value store. // Each item takes precedence over the item below it: // overrides // flag // env // config // key/value store // default package viper import ( "bytes" "encoding/csv" "errors" "fmt" "io" "log" "os" "path/filepath" "reflect" "strconv" "strings" "sync" "time" "github.com/fsnotify/fsnotify" "github.com/magiconair/properties" "github.com/mitchellh/mapstructure" "github.com/spf13/afero" "github.com/spf13/cast" "github.com/spf13/pflag" "github.com/subosito/gotenv" "gopkg.in/ini.v1" "github.com/spf13/viper/internal/encoding" "github.com/spf13/viper/internal/encoding/hcl" "github.com/spf13/viper/internal/encoding/json" "github.com/spf13/viper/internal/encoding/toml" "github.com/spf13/viper/internal/encoding/yaml" ) // ConfigMarshalError happens when failing to marshal the configuration. type ConfigMarshalError struct { err error } // Error returns the formatted configuration error. func (e ConfigMarshalError) Error() string { return fmt.Sprintf("While marshaling config: %s", e.err.Error()) } var v *Viper type RemoteResponse struct { Value []byte Error error } var ( encoderRegistry = encoding.NewEncoderRegistry() decoderRegistry = encoding.NewDecoderRegistry() ) func init() { v = New() { codec := yaml.Codec{} encoderRegistry.RegisterEncoder("yaml", codec) decoderRegistry.RegisterDecoder("yaml", codec) encoderRegistry.RegisterEncoder("yml", codec) decoderRegistry.RegisterDecoder("yml", codec) } { codec := json.Codec{} encoderRegistry.RegisterEncoder("json", codec) decoderRegistry.RegisterDecoder("json", codec) } { codec := toml.Codec{} encoderRegistry.RegisterEncoder("toml", codec) decoderRegistry.RegisterDecoder("toml", codec) } { codec := hcl.Codec{} encoderRegistry.RegisterEncoder("hcl", codec) decoderRegistry.RegisterDecoder("hcl", codec) encoderRegistry.RegisterEncoder("tfvars", codec) decoderRegistry.RegisterDecoder("tfvars", codec) } } type remoteConfigFactory interface { Get(rp RemoteProvider) (io.Reader, error) Watch(rp RemoteProvider) (io.Reader, error) WatchChannel(rp RemoteProvider) (<-chan *RemoteResponse, chan bool) } // RemoteConfig is optional, see the remote package var RemoteConfig remoteConfigFactory // UnsupportedConfigError denotes encountering an unsupported // configuration filetype. type UnsupportedConfigError string // Error returns the formatted configuration error. func (str UnsupportedConfigError) Error() string { return fmt.Sprintf("Unsupported Config Type %q", string(str)) } // UnsupportedRemoteProviderError denotes encountering an unsupported remote // provider. Currently only etcd and Consul are supported. type UnsupportedRemoteProviderError string // Error returns the formatted remote provider error. func (str UnsupportedRemoteProviderError) Error() string { return fmt.Sprintf("Unsupported Remote Provider Type %q", string(str)) } // RemoteConfigError denotes encountering an error while trying to // pull the configuration from the remote provider. type RemoteConfigError string // Error returns the formatted remote provider error func (rce RemoteConfigError) Error() string { return fmt.Sprintf("Remote Configurations Error: %s", string(rce)) } // ConfigFileNotFoundError denotes failing to find configuration file. type ConfigFileNotFoundError struct { name, locations string } // Error returns the formatted configuration error. func (fnfe ConfigFileNotFoundError) Error() string { return fmt.Sprintf("Config File %q Not Found in %q", fnfe.name, fnfe.locations) } // ConfigFileAlreadyExistsError denotes failure to write new configuration file. type ConfigFileAlreadyExistsError string // Error returns the formatted error when configuration already exists. func (faee ConfigFileAlreadyExistsError) Error() string { return fmt.Sprintf("Config File %q Already Exists", string(faee)) } // A DecoderConfigOption can be passed to viper.Unmarshal to configure // mapstructure.DecoderConfig options type DecoderConfigOption func(*mapstructure.DecoderConfig) // DecodeHook returns a DecoderConfigOption which overrides the default // DecoderConfig.DecodeHook value, the default is: // // mapstructure.ComposeDecodeHookFunc( // mapstructure.StringToTimeDurationHookFunc(), // mapstructure.StringToSliceHookFunc(","), // ) func DecodeHook(hook mapstructure.DecodeHookFunc) DecoderConfigOption { return func(c *mapstructure.DecoderConfig) { c.DecodeHook = hook } } // Viper is a prioritized configuration registry. It // maintains a set of configuration sources, fetches // values to populate those, and provides them according // to the source's priority. // The priority of the sources is the following: // 1. overrides // 2. flags // 3. env. variables // 4. config file // 5. key/value store // 6. defaults // // For example, if values from the following sources were loaded: // // Defaults : { // "secret": "", // "user": "default", // "endpoint": "https://localhost" // } // Config : { // "user": "root" // "secret": "defaultsecret" // } // Env : { // "secret": "somesecretkey" // } // // The resulting config will have the following values: // // { // "secret": "somesecretkey", // "user": "root", // "endpoint": "https://localhost" // } // // Note: Vipers are not safe for concurrent Get() and Set() operations. type Viper struct { // Delimiter that separates a list of keys // used to access a nested value in one go keyDelim string // A set of paths to look for the config file in configPaths []string // The filesystem to read config from. fs afero.Fs // A set of remote providers to search for the configuration remoteProviders []*defaultRemoteProvider // Name of file to look for inside the path configName string configFile string configType string configPermissions os.FileMode envPrefix string // Specific commands for ini parsing iniLoadOptions ini.LoadOptions automaticEnvApplied bool envKeyReplacer StringReplacer allowEmptyEnv bool config map[string]interface{} override map[string]interface{} defaults map[string]interface{} kvstore map[string]interface{} pflags map[string]FlagValue env map[string][]string aliases map[string]string typeByDefValue bool // Store read properties on the object so that we can write back in order with comments. // This will only be used if the configuration read is a properties file. properties *properties.Properties onConfigChange func(fsnotify.Event) logger Logger } // New returns an initialized Viper instance. func New() *Viper { v := new(Viper) v.keyDelim = "." v.configName = "config" v.configPermissions = os.FileMode(0o644) v.fs = afero.NewOsFs() v.config = make(map[string]interface{}) v.override = make(map[string]interface{}) v.defaults = make(map[string]interface{}) v.kvstore = make(map[string]interface{}) v.pflags = make(map[string]FlagValue) v.env = make(map[string][]string) v.aliases = make(map[string]string) v.typeByDefValue = false v.logger = jwwLogger{} return v } // Option configures Viper using the functional options paradigm popularized by Rob Pike and Dave Cheney. // If you're unfamiliar with this style, // see https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html and // https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis. type Option interface { apply(v *Viper) } type optionFunc func(v *Viper) func (fn optionFunc) apply(v *Viper) { fn(v) } // KeyDelimiter sets the delimiter used for determining key parts. // By default it's value is ".". func KeyDelimiter(d string) Option { return optionFunc(func(v *Viper) { v.keyDelim = d }) } // StringReplacer applies a set of replacements to a string. type StringReplacer interface { // Replace returns a copy of s with all replacements performed. Replace(s string) string } // EnvKeyReplacer sets a replacer used for mapping environment variables to internal keys. func EnvKeyReplacer(r StringReplacer) Option { return optionFunc(func(v *Viper) { v.envKeyReplacer = r }) } // NewWithOptions creates a new Viper instance. func NewWithOptions(opts ...Option) *Viper { v := New() for _, opt := range opts { opt.apply(v) } return v } // Reset is intended for testing, will reset all to default settings. // In the public interface for the viper package so applications // can use it in their testing as well. func Reset() { v = New() SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "tfvars", "dotenv", "env", "ini"} SupportedRemoteProviders = []string{"etcd", "consul", "firestore"} } type defaultRemoteProvider struct { provider string endpoint string path string secretKeyring string } func (rp defaultRemoteProvider) Provider() string { return rp.provider } func (rp defaultRemoteProvider) Endpoint() string { return rp.endpoint } func (rp defaultRemoteProvider) Path() string { return rp.path } func (rp defaultRemoteProvider) SecretKeyring() string { return rp.secretKeyring } // RemoteProvider stores the configuration necessary // to connect to a remote key/value store. // Optional secretKeyring to unencrypt encrypted values // can be provided. type RemoteProvider interface { Provider() string Endpoint() string Path() string SecretKeyring() string } // SupportedExts are universally supported extensions. var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "tfvars", "dotenv", "env", "ini"} // SupportedRemoteProviders are universally supported remote providers. var SupportedRemoteProviders = []string{"etcd", "consul", "firestore"} func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) } func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) { v.onConfigChange = run } func WatchConfig() { v.WatchConfig() } func (v *Viper) WatchConfig() { initWG := sync.WaitGroup{} initWG.Add(1) go func() { watcher, err := newWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() // we have to watch the entire directory to pick up renames/atomic saves in a cross-platform way filename, err := v.getConfigFile() if err != nil { log.Printf("error: %v\n", err) initWG.Done() return } configFile := filepath.Clean(filename) configDir, _ := filepath.Split(configFile) realConfigFile, _ := filepath.EvalSymlinks(filename) eventsWG := sync.WaitGroup{} eventsWG.Add(1) go func() { for { select { case event, ok := <-watcher.Events: if !ok { // 'Events' channel is closed eventsWG.Done() return } currentConfigFile, _ := filepath.EvalSymlinks(filename) // we only care about the config file with the following cases: // 1 - if the config file was modified or created // 2 - if the real path to the config file changed (eg: k8s ConfigMap replacement) const writeOrCreateMask = fsnotify.Write | fsnotify.Create if (filepath.Clean(event.Name) == configFile && event.Op&writeOrCreateMask != 0) || (currentConfigFile != "" && currentConfigFile != realConfigFile) { realConfigFile = currentConfigFile err := v.ReadInConfig() if err != nil { log.Printf("error reading config file: %v\n", err) } if v.onConfigChange != nil { v.onConfigChange(event) } } else if filepath.Clean(event.Name) == configFile && event.Op&fsnotify.Remove&fsnotify.Remove != 0 { eventsWG.Done() return } case err, ok := <-watcher.Errors: if ok { // 'Errors' channel is not closed log.Printf("watcher error: %v\n", err) } eventsWG.Done() return } } }() watcher.Add(configDir) initWG.Done() // done initializing the watch in this go routine, so the parent routine can move on... eventsWG.Wait() // now, wait for event loop to end in this go-routine... }() initWG.Wait() // make sure that the go routine above fully ended before returning } // SetConfigFile explicitly defines the path, name and extension of the config file. // Viper will use this and not check any of the config paths. func SetConfigFile(in string) { v.SetConfigFile(in) } func (v *Viper) SetConfigFile(in string) { if in != "" { v.configFile = in } } // SetEnvPrefix defines a prefix that ENVIRONMENT variables will use. // E.g. if your prefix is "spf", the env registry will look for env // variables that start with "SPF_". func SetEnvPrefix(in string) { v.SetEnvPrefix(in) } func (v *Viper) SetEnvPrefix(in string) { if in != "" { v.envPrefix = in } } func (v *Viper) mergeWithEnvPrefix(in string) string { if v.envPrefix != "" { return strings.ToUpper(v.envPrefix + "_" + in) } return strings.ToUpper(in) } // AllowEmptyEnv tells Viper to consider set, // but empty environment variables as valid values instead of falling back. // For backward compatibility reasons this is false by default. func AllowEmptyEnv(allowEmptyEnv bool) { v.AllowEmptyEnv(allowEmptyEnv) } func (v *Viper) AllowEmptyEnv(allowEmptyEnv bool) { v.allowEmptyEnv = allowEmptyEnv } // TODO: should getEnv logic be moved into find(). Can generalize the use of // rewriting keys many things, Ex: Get('someKey') -> some_key // (camel case to snake case for JSON keys perhaps) // getEnv is a wrapper around os.Getenv which replaces characters in the original // key. This allows env vars which have different keys than the config object // keys. func (v *Viper) getEnv(key string) (string, bool) { if v.envKeyReplacer != nil { key = v.envKeyReplacer.Replace(key) } val, ok := os.LookupEnv(key) return val, ok && (v.allowEmptyEnv || val != "") } // ConfigFileUsed returns the file used to populate the config registry. func ConfigFileUsed() string { return v.ConfigFileUsed() } func (v *Viper) ConfigFileUsed() string { return v.configFile } // AddConfigPath adds a path for Viper to search for the config file in. // Can be called multiple times to define multiple search paths. func AddConfigPath(in string) { v.AddConfigPath(in) } func (v *Viper) AddConfigPath(in string) { if in != "" { absin := absPathify(v.logger, in) v.logger.Info("adding path to search paths", "path", absin) if !stringInSlice(absin, v.configPaths) { v.configPaths = append(v.configPaths, absin) } } } // AddRemoteProvider adds a remote configuration source. // Remote Providers are searched in the order they are added. // provider is a string value: "etcd", "consul" or "firestore" are currently supported. // endpoint is the url. etcd requires http://ip:port consul requires ip:port // path is the path in the k/v store to retrieve configuration // To retrieve a config file called myapp.json from /configs/myapp.json // you should set path to /configs and set config name (SetConfigName()) to // "myapp" func AddRemoteProvider(provider, endpoint, path string) error { return v.AddRemoteProvider(provider, endpoint, path) } func (v *Viper) AddRemoteProvider(provider, endpoint, path string) error { if !stringInSlice(provider, SupportedRemoteProviders) { return UnsupportedRemoteProviderError(provider) } if provider != "" && endpoint != "" { v.logger.Info("adding remote provider", "provider", provider, "endpoint", endpoint) rp := &defaultRemoteProvider{ endpoint: endpoint, provider: provider, path: path, } if !v.providerPathExists(rp) { v.remoteProviders = append(v.remoteProviders, rp) } } return nil } // AddSecureRemoteProvider adds a remote configuration source. // Secure Remote Providers are searched in the order they are added. // provider is a string value: "etcd", "consul" or "firestore" are currently supported. // endpoint is the url. etcd requires http://ip:port consul requires ip:port // secretkeyring is the filepath to your openpgp secret keyring. e.g. /etc/secrets/myring.gpg // path is the path in the k/v store to retrieve configuration // To retrieve a config file called myapp.json from /configs/myapp.json // you should set path to /configs and set config name (SetConfigName()) to // "myapp" // Secure Remote Providers are implemented with github.com/bketelsen/crypt func AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error { return v.AddSecureRemoteProvider(provider, endpoint, path, secretkeyring) } func (v *Viper) AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error { if !stringInSlice(provider, SupportedRemoteProviders) { return UnsupportedRemoteProviderError(provider) } if provider != "" && endpoint != "" { v.logger.Info("adding remote provider", "provider", provider, "endpoint", endpoint) rp := &defaultRemoteProvider{ endpoint: endpoint, provider: provider, path: path, secretKeyring: secretkeyring, } if !v.providerPathExists(rp) { v.remoteProviders = append(v.remoteProviders, rp) } } return nil } func (v *Viper) providerPathExists(p *defaultRemoteProvider) bool { for _, y := range v.remoteProviders { if reflect.DeepEqual(y, p) { return true } } return false } // searchMap recursively searches for a value for path in source map. // Returns nil if not found. // Note: This assumes that the path entries and map keys are lower cased. func (v *Viper) searchMap(source map[string]interface{}, path []string) interface{} { if len(path) == 0 { return source } next, ok := source[path[0]] if ok { // Fast path if len(path) == 1 { return next } // Nested case switch next.(type) { case map[interface{}]interface{}: return v.searchMap(cast.ToStringMap(next), path[1:]) case map[string]interface{}: // Type assertion is safe here since it is only reached // if the type of `next` is the same as the type being asserted return v.searchMap(next.(map[string]interface{}), path[1:]) default: // got a value but nested key expected, return "nil" for not found return nil } } return nil } // searchIndexableWithPathPrefixes recursively searches for a value for path in source map/slice. // // While searchMap() considers each path element as a single map key or slice index, this // function searches for, and prioritizes, merged path elements. // e.g., if in the source, "foo" is defined with a sub-key "bar", and "foo.bar" // is also defined, this latter value is returned for path ["foo", "bar"]. // // This should be useful only at config level (other maps may not contain dots // in their keys). // // Note: This assumes that the path entries and map keys are lower cased. func (v *Viper) searchIndexableWithPathPrefixes(source interface{}, path []string) interface{} { if len(path) == 0 { return source } // search for path prefixes, starting from the longest one for i := len(path); i > 0; i-- { prefixKey := strings.ToLower(strings.Join(path[0:i], v.keyDelim)) var val interface{} switch sourceIndexable := source.(type) { case []interface{}: val = v.searchSliceWithPathPrefixes(sourceIndexable, prefixKey, i, path) case map[string]interface{}: val = v.searchMapWithPathPrefixes(sourceIndexable, prefixKey, i, path) } if val != nil { return val } } // not found return nil } // searchSliceWithPathPrefixes searches for a value for path in sourceSlice // // This function is part of the searchIndexableWithPathPrefixes recurring search and // should not be called directly from functions other than searchIndexableWithPathPrefixes. func (v *Viper) searchSliceWithPathPrefixes( sourceSlice []interface{}, prefixKey string, pathIndex int, path []string, ) interface{} { // if the prefixKey is not a number or it is out of bounds of the slice index, err := strconv.Atoi(prefixKey) if err != nil || len(sourceSlice) <= index { return nil } next := sourceSlice[index] // Fast path if pathIndex == len(path) { return next } switch n := next.(type) { case map[interface{}]interface{}: return v.searchIndexableWithPathPrefixes(cast.ToStringMap(n), path[pathIndex:]) case map[string]interface{}, []interface{}: return v.searchIndexableWithPathPrefixes(n, path[pathIndex:]) default: // got a value but nested key expected, do nothing and look for next prefix } // not found return nil } // searchMapWithPathPrefixes searches for a value for path in sourceMap // // This function is part of the searchIndexableWithPathPrefixes recurring search and // should not be called directly from functions other than searchIndexableWithPathPrefixes. func (v *Viper) searchMapWithPathPrefixes( sourceMap map[string]interface{}, prefixKey string, pathIndex int, path []string, ) interface{} { next, ok := sourceMap[prefixKey] if !ok { return nil } // Fast path if pathIndex == len(path) { return next } // Nested case switch n := next.(type) { case map[interface{}]interface{}: return v.searchIndexableWithPathPrefixes(cast.ToStringMap(n), path[pathIndex:]) case map[string]interface{}, []interface{}: return v.searchIndexableWithPathPrefixes(n, path[pathIndex:]) default: // got a value but nested key expected, do nothing and look for next prefix } // not found return nil } // isPathShadowedInDeepMap makes sure the given path is not shadowed somewhere // on its path in the map. // e.g., if "foo.bar" has a value in the given map, it “shadows” // "foo.bar.baz" in a lower-priority map func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]interface{}) string { var parentVal interface{} for i := 1; i < len(path); i++ { parentVal = v.searchMap(m, path[0:i]) if parentVal == nil { // not found, no need to add more path elements return "" } switch parentVal.(type) { case map[interface{}]interface{}: continue case map[string]interface{}: continue default: // parentVal is a regular value which shadows "path" return strings.Join(path[0:i], v.keyDelim) } } return "" } // isPathShadowedInFlatMap makes sure the given path is not shadowed somewhere // in a sub-path of the map. // e.g., if "foo.bar" has a value in the given map, it “shadows” // "foo.bar.baz" in a lower-priority map func (v *Viper) isPathShadowedInFlatMap(path []string, mi interface{}) string { // unify input map var m map[string]interface{} switch mi.(type) { case map[string]string, map[string]FlagValue: m = cast.ToStringMap(mi) default: return "" } // scan paths var parentKey string for i := 1; i < len(path); i++ { parentKey = strings.Join(path[0:i], v.keyDelim) if _, ok := m[parentKey]; ok { return parentKey } } return "" } // isPathShadowedInAutoEnv makes sure the given path is not shadowed somewhere // in the environment, when automatic env is on. // e.g., if "foo.bar" has a value in the environment, it “shadows” // "foo.bar.baz" in a lower-priority map func (v *Viper) isPathShadowedInAutoEnv(path []string) string { var parentKey string for i := 1; i < len(path); i++ { parentKey = strings.Join(path[0:i], v.keyDelim) if _, ok := v.getEnv(v.mergeWithEnvPrefix(parentKey)); ok { return parentKey } } return "" } // SetTypeByDefaultValue enables or disables the inference of a key value's // type when the Get function is used based upon a key's default value as // opposed to the value returned based on the normal fetch logic. // // For example, if a key has a default value of []string{} and the same key // is set via an environment variable to "a b c", a call to the Get function // would return a string slice for the key if the key's type is inferred by // the default value and the Get function would return: // // []string {"a", "b", "c"} // // Otherwise the Get function would return: // // "a b c" func SetTypeByDefaultValue(enable bool) { v.SetTypeByDefaultValue(enable) } func (v *Viper) SetTypeByDefaultValue(enable bool) { v.typeByDefValue = enable } // GetViper gets the global Viper instance. func GetViper() *Viper { return v } // Get can retrieve any value given the key to use. // Get is case-insensitive for a key. // Get has the behavior of returning the value associated with the first // place from where it is set. Viper will check in the following order: // override, flag, env, config file, key/value store, default // // Get returns an interface. For a specific value use one of the Get____ methods. func Get(key string) interface{} { return v.Get(key) } func (v *Viper) Get(key string) interface{} { lcaseKey := strings.ToLower(key) val := v.find(lcaseKey, true) if val == nil { return nil } if v.typeByDefValue { // TODO(bep) this branch isn't covered by a single test. valType := val path := strings.Split(lcaseKey, v.keyDelim) defVal := v.searchMap(v.defaults, path) if defVal != nil { valType = defVal } switch valType.(type) { case bool: return cast.ToBool(val) case string: return cast.ToString(val) case int32, int16, int8, int: return cast.ToInt(val) case uint: return cast.ToUint(val) case uint32: return cast.ToUint32(val) case uint64: return cast.ToUint64(val) case int64: return cast.ToInt64(val) case float64, float32: return cast.ToFloat64(val) case time.Time: return cast.ToTime(val) case time.Duration: return cast.ToDuration(val) case []string: return cast.ToStringSlice(val) case []int: return cast.ToIntSlice(val) } } return val } // Sub returns new Viper instance representing a sub tree of this instance. // Sub is case-insensitive for a key. func Sub(key string) *Viper { return v.Sub(key) } func (v *Viper) Sub(key string) *Viper { subv := New() data := v.Get(key) if data == nil { return nil } if reflect.TypeOf(data).Kind() == reflect.Map { subv.config = cast.ToStringMap(data) return subv } return nil } // GetString returns the value associated with the key as a string. func GetString(key string) string { return v.GetString(key) } func (v *Viper) GetString(key string) string { return cast.ToString(v.Get(key)) } // GetBool returns the value associated with the key as a boolean. func GetBool(key string) bool { return v.GetBool(key) } func (v *Viper) GetBool(key string) bool { return cast.ToBool(v.Get(key)) } // GetInt returns the value associated with the key as an integer. func GetInt(key string) int { return v.GetInt(key) } func (v *Viper) GetInt(key string) int { return cast.ToInt(v.Get(key)) } // GetInt32 returns the value associated with the key as an integer. func GetInt32(key string) int32 { return v.GetInt32(key) } func (v *Viper) GetInt32(key string) int32 { return cast.ToInt32(v.Get(key)) } // GetInt64 returns the value associated with the key as an integer. func GetInt64(key string) int64 { return v.GetInt64(key) } func (v *Viper) GetInt64(key string) int64 { return cast.ToInt64(v.Get(key)) } // GetUint returns the value associated with the key as an unsigned integer. func GetUint(key string) uint { return v.GetUint(key) } func (v *Viper) GetUint(key string) uint { return cast.ToUint(v.Get(key)) } // GetUint32 returns the value associated with the key as an unsigned integer. func GetUint32(key string) uint32 { return v.GetUint32(key) } func (v *Viper) GetUint32(key string) uint32 { return cast.ToUint32(v.Get(key)) } // GetUint64 returns the value associated with the key as an unsigned integer. func GetUint64(key string) uint64 { return v.GetUint64(key) } func (v *Viper) GetUint64(key string) uint64 { return cast.ToUint64(v.Get(key)) } // GetFloat64 returns the value associated with the key as a float64. func GetFloat64(key string) float64 { return v.GetFloat64(key) } func (v *Viper) GetFloat64(key string) float64 { return cast.ToFloat64(v.Get(key)) } // GetTime returns the value associated with the key as time. func GetTime(key string) time.Time { return v.GetTime(key) } func (v *Viper) GetTime(key string) time.Time { return cast.ToTime(v.Get(key)) } // GetDuration returns the value associated with the key as a duration. func GetDuration(key string) time.Duration { return v.GetDuration(key) } func (v *Viper) GetDuration(key string) time.Duration { return cast.ToDuration(v.Get(key)) } // GetIntSlice returns the value associated with the key as a slice of int values. func GetIntSlice(key string) []int { return v.GetIntSlice(key) } func (v *Viper) GetIntSlice(key string) []int { return cast.ToIntSlice(v.Get(key)) } // GetStringSlice returns the value associated with the key as a slice of strings. func GetStringSlice(key string) []string { return v.GetStringSlice(key) } func (v *Viper) GetStringSlice(key string) []string { return cast.ToStringSlice(v.Get(key)) } // GetStringMap returns the value associated with the key as a map of interfaces. func GetStringMap(key string) map[string]interface{} { return v.GetStringMap(key) } func (v *Viper) GetStringMap(key string) map[string]interface{} { return cast.ToStringMap(v.Get(key)) } // GetStringMapString returns the value associated with the key as a map of strings. func GetStringMapString(key string) map[string]string { return v.GetStringMapString(key) } func (v *Viper) GetStringMapString(key string) map[string]string { return cast.ToStringMapString(v.Get(key)) } // GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings. func GetStringMapStringSlice(key string) map[string][]string { return v.GetStringMapStringSlice(key) } func (v *Viper) GetStringMapStringSlice(key string) map[string][]string { return cast.ToStringMapStringSlice(v.Get(key)) } // GetSizeInBytes returns the size of the value associated with the given key // in bytes. func GetSizeInBytes(key string) uint { return v.GetSizeInBytes(key) } func (v *Viper) GetSizeInBytes(key string) uint { sizeStr := cast.ToString(v.Get(key)) return parseSizeInBytes(sizeStr) } // UnmarshalKey takes a single key and unmarshals it into a Struct. func UnmarshalKey(key string, rawVal interface{}, opts ...DecoderConfigOption) error { return v.UnmarshalKey(key, rawVal, opts...) } func (v *Viper) UnmarshalKey(key string, rawVal interface{}, opts ...DecoderConfigOption) error { return decode(v.Get(key), defaultDecoderConfig(rawVal, opts...)) } // Unmarshal unmarshals the config into a Struct. Make sure that the tags // on the fields of the structure are properly set. func Unmarshal(rawVal interface{}, opts ...DecoderConfigOption) error { return v.Unmarshal(rawVal, opts...) } func (v *Viper) Unmarshal(rawVal interface{}, opts ...DecoderConfigOption) error { return decode(v.AllSettings(), defaultDecoderConfig(rawVal, opts...)) } // defaultDecoderConfig returns default mapsstructure.DecoderConfig with suppot // of time.Duration values & string slices func defaultDecoderConfig(output interface{}, opts ...DecoderConfigOption) *mapstructure.DecoderConfig { c := &mapstructure.DecoderConfig{ Metadata: nil, Result: output, WeaklyTypedInput: true, DecodeHook: mapstructure.ComposeDecodeHookFunc( mapstructure.StringToTimeDurationHookFunc(), mapstructure.StringToSliceHookFunc(","), ), } for _, opt := range opts { opt(c) } return c } // A wrapper around mapstructure.Decode that mimics the WeakDecode functionality func decode(input interface{}, config *mapstructure.DecoderConfig) error { decoder, err := mapstructure.NewDecoder(config) if err != nil { return err } return decoder.Decode(input) } // UnmarshalExact unmarshals the config into a Struct, erroring if a field is nonexistent // in the destination struct. func UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error { return v.UnmarshalExact(rawVal, opts...) } func (v *Viper) UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error { config := defaultDecoderConfig(rawVal, opts...) config.ErrorUnused = true return decode(v.AllSettings(), config) } // BindPFlags binds a full flag set to the configuration, using each flag's long // name as the config key. func BindPFlags(flags *pflag.FlagSet) error { return v.BindPFlags(flags) } func (v *Viper) BindPFlags(flags *pflag.FlagSet) error { return v.BindFlagValues(pflagValueSet{flags}) } // BindPFlag binds a specific key to a pflag (as used by cobra). // Example (where serverCmd is a Cobra instance): // // serverCmd.Flags().Int("port", 1138, "Port to run Application server on") // Viper.BindPFlag("port", serverCmd.Flags().Lookup("port")) // func BindPFlag(key string, flag *pflag.Flag) error { return v.BindPFlag(key, flag) } func (v *Viper) BindPFlag(key string, flag *pflag.Flag) error { if flag == nil { return fmt.Errorf("flag for %q is nil", key) } return v.BindFlagValue(key, pflagValue{flag}) } // BindFlagValues binds a full FlagValue set to the configuration, using each flag's long // name as the config key. func BindFlagValues(flags FlagValueSet) error { return v.BindFlagValues(flags) } func (v *Viper) BindFlagValues(flags FlagValueSet) (err error) { flags.VisitAll(func(flag FlagValue) { if err = v.BindFlagValue(flag.Name(), flag); err != nil { return } }) return nil } // BindFlagValue binds a specific key to a FlagValue. func BindFlagValue(key string, flag FlagValue) error { return v.BindFlagValue(key, flag) } func (v *Viper) BindFlagValue(key string, flag FlagValue) error { if flag == nil { return fmt.Errorf("flag for %q is nil", key) } v.pflags[strings.ToLower(key)] = flag return nil } // BindEnv binds a Viper key to a ENV variable. // ENV variables are case sensitive. // If only a key is provided, it will use the env key matching the key, uppercased. // If more arguments are provided, they will represent the env variable names that // should bind to this key and will be taken in the specified order. // EnvPrefix will be used when set when env name is not provided. func BindEnv(input ...string) error { return v.BindEnv(input...) } func (v *Viper) BindEnv(input ...string) error { if len(input) == 0 { return fmt.Errorf("missing key to bind to") } key := strings.ToLower(input[0]) if len(input) == 1 { v.env[key] = append(v.env[key], v.mergeWithEnvPrefix(key)) } else { v.env[key] = append(v.env[key], input[1:]...) } return nil } // Given a key, find the value. // // Viper will check to see if an alias exists first. // Viper will then check in the following order: // flag, env, config file, key/value store. // Lastly, if no value was found and flagDefault is true, and if the key // corresponds to a flag, the flag's default value is returned. // // Note: this assumes a lower-cased key given. func (v *Viper) find(lcaseKey string, flagDefault bool) interface{} { var ( val interface{} exists bool path = strings.Split(lcaseKey, v.keyDelim) nested = len(path) > 1 ) // compute the path through the nested maps to the nested value if nested && v.isPathShadowedInDeepMap(path, castMapStringToMapInterface(v.aliases)) != "" { return nil } // if the requested key is an alias, then return the proper key lcaseKey = v.realKey(lcaseKey) path = strings.Split(lcaseKey, v.keyDelim) nested = len(path) > 1 // Set() override first val = v.searchMap(v.override, path) if val != nil { return val } if nested && v.isPathShadowedInDeepMap(path, v.override) != "" { return nil } // PFlag override next flag, exists := v.pflags[lcaseKey] if exists && flag.HasChanged() { switch flag.ValueType() { case "int", "int8", "int16", "int32", "int64": return cast.ToInt(flag.ValueString()) case "bool": return cast.ToBool(flag.ValueString()) case "stringSlice", "stringArray": s := strings.TrimPrefix(flag.ValueString(), "[") s = strings.TrimSuffix(s, "]") res, _ := readAsCSV(s) return res case "intSlice": s := strings.TrimPrefix(flag.ValueString(), "[") s = strings.TrimSuffix(s, "]") res, _ := readAsCSV(s) return cast.ToIntSlice(res) case "stringToString": return stringToStringConv(flag.ValueString()) default: return flag.ValueString() } } if nested && v.isPathShadowedInFlatMap(path, v.pflags) != "" { return nil } // Env override next if v.automaticEnvApplied { // even if it hasn't been registered, if automaticEnv is used, // check any Get request if val, ok := v.getEnv(v.mergeWithEnvPrefix(lcaseKey)); ok { return val } if nested && v.isPathShadowedInAutoEnv(path) != "" { return nil } } envkeys, exists := v.env[lcaseKey] if exists { for _, envkey := range envkeys { if val, ok := v.getEnv(envkey); ok { return val } } } if nested && v.isPathShadowedInFlatMap(path, v.env) != "" { return nil } // Config file next val = v.searchIndexableWithPathPrefixes(v.config, path) if val != nil { return val } if nested && v.isPathShadowedInDeepMap(path, v.config) != "" { return nil } // K/V store next val = v.searchMap(v.kvstore, path) if val != nil { return val } if nested && v.isPathShadowedInDeepMap(path, v.kvstore) != "" { return nil } // Default next val = v.searchMap(v.defaults, path) if val != nil { return val } if nested && v.isPathShadowedInDeepMap(path, v.defaults) != "" { return nil } if flagDefault { // last chance: if no value is found and a flag does exist for the key, // get the flag's default value even if the flag's value has not been set. if flag, exists := v.pflags[lcaseKey]; exists { switch flag.ValueType() { case "int", "int8", "int16", "int32", "int64": return cast.ToInt(flag.ValueString()) case "bool": return cast.ToBool(flag.ValueString()) case "stringSlice", "stringArray": s := strings.TrimPrefix(flag.ValueString(), "[") s = strings.TrimSuffix(s, "]") res, _ := readAsCSV(s) return res case "intSlice": s := strings.TrimPrefix(flag.ValueString(), "[") s = strings.TrimSuffix(s, "]") res, _ := readAsCSV(s) return cast.ToIntSlice(res) case "stringToString": return stringToStringConv(flag.ValueString()) default: return flag.ValueString() } } // last item, no need to check shadowing } return nil } func readAsCSV(val string) ([]string, error) { if val == "" { return []string{}, nil } stringReader := strings.NewReader(val) csvReader := csv.NewReader(stringReader) return csvReader.Read() } // mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/master/string_to_string.go#L79 // alterations are: errors are swallowed, map[string]interface{} is returned in order to enable cast.ToStringMap func stringToStringConv(val string) interface{} { val = strings.Trim(val, "[]") // An empty string would cause an empty map if len(val) == 0 { return map[string]interface{}{} } r := csv.NewReader(strings.NewReader(val)) ss, err := r.Read() if err != nil { return nil } out := make(map[string]interface{}, len(ss)) for _, pair := range ss { kv := strings.SplitN(pair, "=", 2) if len(kv) != 2 { return nil } out[kv[0]] = kv[1] } return out } // IsSet checks to see if the key has been set in any of the data locations. // IsSet is case-insensitive for a key. func IsSet(key string) bool { return v.IsSet(key) } func (v *Viper) IsSet(key string) bool { lcaseKey := strings.ToLower(key) val := v.find(lcaseKey, false) return val != nil } // AutomaticEnv makes Viper check if environment variables match any of the existing keys // (config, default or flags). If matching env vars are found, they are loaded into Viper. func AutomaticEnv() { v.AutomaticEnv() } func (v *Viper) AutomaticEnv() { v.automaticEnvApplied = true } // SetEnvKeyReplacer sets the strings.Replacer on the viper object // Useful for mapping an environmental variable to a key that does // not match it. func SetEnvKeyReplacer(r *strings.Replacer) { v.SetEnvKeyReplacer(r) } func (v *Viper) SetEnvKeyReplacer(r *strings.Replacer) { v.envKeyReplacer = r } // RegisterAlias creates an alias that provides another accessor for the same key. // This enables one to change a name without breaking the application. func RegisterAlias(alias string, key string) { v.RegisterAlias(alias, key) } func (v *Viper) RegisterAlias(alias string, key string) { v.registerAlias(alias, strings.ToLower(key)) } func (v *Viper) registerAlias(alias string, key string) { alias = strings.ToLower(alias) if alias != key && alias != v.realKey(key) { _, exists := v.aliases[alias] if !exists { // if we alias something that exists in one of the maps to another // name, we'll never be able to get that value using the original // name, so move the config value to the new realkey. if val, ok := v.config[alias]; ok { delete(v.config, alias) v.config[key] = val } if val, ok := v.kvstore[alias]; ok { delete(v.kvstore, alias) v.kvstore[key] = val } if val, ok := v.defaults[alias]; ok { delete(v.defaults, alias) v.defaults[key] = val } if val, ok := v.override[alias]; ok { delete(v.override, alias) v.override[key] = val } v.aliases[alias] = key } } else { v.logger.Warn("creating circular reference alias", "alias", alias, "key", key, "real_key", v.realKey(key)) } } func (v *Viper) realKey(key string) string { newkey, exists := v.aliases[key] if exists { v.logger.Debug("key is an alias", "alias", key, "to", newkey) return v.realKey(newkey) } return key } // InConfig checks to see if the given key (or an alias) is in the config file. func InConfig(key string) bool { return v.InConfig(key) } func (v *Viper) InConfig(key string) bool { lcaseKey := strings.ToLower(key) // if the requested key is an alias, then return the proper key lcaseKey = v.realKey(lcaseKey) path := strings.Split(lcaseKey, v.keyDelim) return v.searchIndexableWithPathPrefixes(v.config, path) != nil } // SetDefault sets the default value for this key. // SetDefault is case-insensitive for a key. // Default only used when no value is provided by the user via flag, config or ENV. func SetDefault(key string, value interface{}) { v.SetDefault(key, value) } func (v *Viper) SetDefault(key string, value interface{}) { // If alias passed in, then set the proper default key = v.realKey(strings.ToLower(key)) value = toCaseInsensitiveValue(value) path := strings.Split(key, v.keyDelim) lastKey := strings.ToLower(path[len(path)-1]) deepestMap := deepSearch(v.defaults, path[0:len(path)-1]) // set innermost value deepestMap[lastKey] = value } // Set sets the value for the key in the override register. // Set is case-insensitive for a key. // Will be used instead of values obtained via // flags, config file, ENV, default, or key/value store. func Set(key string, value interface{}) { v.Set(key, value) } func (v *Viper) Set(key string, value interface{}) { // If alias passed in, then set the proper override key = v.realKey(strings.ToLower(key)) value = toCaseInsensitiveValue(value) path := strings.Split(key, v.keyDelim) lastKey := strings.ToLower(path[len(path)-1]) deepestMap := deepSearch(v.override, path[0:len(path)-1]) // set innermost value deepestMap[lastKey] = value } // ReadInConfig will discover and load the configuration file from disk // and key/value stores, searching in one of the defined paths. func ReadInConfig() error { return v.ReadInConfig() } func (v *Viper) ReadInConfig() error { v.logger.Info("attempting to read in config file") filename, err := v.getConfigFile() if err != nil { return err } if !stringInSlice(v.getConfigType(), SupportedExts) { return UnsupportedConfigError(v.getConfigType()) } v.logger.Debug("reading file", "file", filename) file, err := afero.ReadFile(v.fs, filename) if err != nil { return err } config := make(map[string]interface{}) err = v.unmarshalReader(bytes.NewReader(file), config) if err != nil { return err } v.config = config return nil } // MergeInConfig merges a new configuration with an existing config. func MergeInConfig() error { return v.MergeInConfig() } func (v *Viper) MergeInConfig() error { v.logger.Info("attempting to merge in config file") filename, err := v.getConfigFile() if err != nil { return err } if !stringInSlice(v.getConfigType(), SupportedExts) { return UnsupportedConfigError(v.getConfigType()) } file, err := afero.ReadFile(v.fs, filename) if err != nil { return err } return v.MergeConfig(bytes.NewReader(file)) } // ReadConfig will read a configuration file, setting existing keys to nil if the // key does not exist in the file. func ReadConfig(in io.Reader) error { return v.ReadConfig(in) } func (v *Viper) ReadConfig(in io.Reader) error { v.config = make(map[string]interface{}) return v.unmarshalReader(in, v.config) } // MergeConfig merges a new configuration with an existing config. func MergeConfig(in io.Reader) error { return v.MergeConfig(in) } func (v *Viper) MergeConfig(in io.Reader) error { cfg := make(map[string]interface{}) if err := v.unmarshalReader(in, cfg); err != nil { return err } return v.MergeConfigMap(cfg) } // MergeConfigMap merges the configuration from the map given with an existing config. // Note that the map given may be modified. func MergeConfigMap(cfg map[string]interface{}) error { return v.MergeConfigMap(cfg) } func (v *Viper) MergeConfigMap(cfg map[string]interface{}) error { if v.config == nil { v.config = make(map[string]interface{}) } insensitiviseMap(cfg) mergeMaps(cfg, v.config, nil) return nil } // WriteConfig writes the current configuration to a file. func WriteConfig() error { return v.WriteConfig() } func (v *Viper) WriteConfig() error { filename, err := v.getConfigFile() if err != nil { return err } return v.writeConfig(filename, true) } // SafeWriteConfig writes current configuration to file only if the file does not exist. func SafeWriteConfig() error { return v.SafeWriteConfig() } func (v *Viper) SafeWriteConfig() error { if len(v.configPaths) < 1 { return errors.New("missing configuration for 'configPath'") } return v.SafeWriteConfigAs(filepath.Join(v.configPaths[0], v.configName+"."+v.configType)) } // WriteConfigAs writes current configuration to a given filename. func WriteConfigAs(filename string) error { return v.WriteConfigAs(filename) } func (v *Viper) WriteConfigAs(filename string) error { return v.writeConfig(filename, true) } // SafeWriteConfigAs writes current configuration to a given filename if it does not exist. func SafeWriteConfigAs(filename string) error { return v.SafeWriteConfigAs(filename) } func (v *Viper) SafeWriteConfigAs(filename string) error { alreadyExists, err := afero.Exists(v.fs, filename) if alreadyExists && err == nil { return ConfigFileAlreadyExistsError(filename) } return v.writeConfig(filename, false) } func (v *Viper) writeConfig(filename string, force bool) error { v.logger.Info("attempting to write configuration to file") var configType string ext := filepath.Ext(filename) if ext != "" && ext != filepath.Base(filename) { configType = ext[1:] } else { configType = v.configType } if configType == "" { return fmt.Errorf("config type could not be determined for %s", filename) } if !stringInSlice(configType, SupportedExts) { return UnsupportedConfigError(configType) } if v.config == nil { v.config = make(map[string]interface{}) } flags := os.O_CREATE | os.O_TRUNC | os.O_WRONLY if !force { flags |= os.O_EXCL } f, err := v.fs.OpenFile(filename, flags, v.configPermissions) if err != nil { return err } defer f.Close() if err := v.marshalWriter(f, configType); err != nil { return err } return f.Sync() } // Unmarshal a Reader into a map. // Should probably be an unexported function. func unmarshalReader(in io.Reader, c map[string]interface{}) error { return v.unmarshalReader(in, c) } func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error { buf := new(bytes.Buffer) buf.ReadFrom(in) switch format := strings.ToLower(v.getConfigType()); format { case "yaml", "yml", "json", "toml", "hcl", "tfvars": err := decoderRegistry.Decode(format, buf.Bytes(), &c) if err != nil { return ConfigParseError{err} } case "dotenv", "env": env, err := gotenv.StrictParse(buf) if err != nil { return ConfigParseError{err} } for k, v := range env { c[k] = v } case "properties", "props", "prop": v.properties = properties.NewProperties() var err error if v.properties, err = properties.Load(buf.Bytes(), properties.UTF8); err != nil { return ConfigParseError{err} } for _, key := range v.properties.Keys() { value, _ := v.properties.Get(key) // recursively build nested maps path := strings.Split(key, ".") lastKey := strings.ToLower(path[len(path)-1]) deepestMap := deepSearch(c, path[0:len(path)-1]) // set innermost value deepestMap[lastKey] = value } case "ini": cfg := ini.Empty(v.iniLoadOptions) err := cfg.Append(buf.Bytes()) if err != nil { return ConfigParseError{err} } sections := cfg.Sections() for i := 0; i < len(sections); i++ { section := sections[i] keys := section.Keys() for j := 0; j < len(keys); j++ { key := keys[j] value := cfg.Section(section.Name()).Key(key.Name()).String() c[section.Name()+"."+key.Name()] = value } } } insensitiviseMap(c) return nil } // Marshal a map into Writer. func (v *Viper) marshalWriter(f afero.File, configType string) error { c := v.AllSettings() switch configType { case "yaml", "yml", "json", "toml", "hcl", "tfvars": b, err := encoderRegistry.Encode(configType, c) if err != nil { return ConfigMarshalError{err} } _, err = f.WriteString(string(b)) if err != nil { return ConfigMarshalError{err} } case "prop", "props", "properties": if v.properties == nil { v.properties = properties.NewProperties() } p := v.properties for _, key := range v.AllKeys() { _, _, err := p.Set(key, v.GetString(key)) if err != nil { return ConfigMarshalError{err} } } _, err := p.WriteComment(f, "#", properties.UTF8) if err != nil { return ConfigMarshalError{err} } case "dotenv", "env": lines := []string{} for _, key := range v.AllKeys() { envName := strings.ToUpper(strings.Replace(key, ".", "_", -1)) val := v.Get(key) lines = append(lines, fmt.Sprintf("%v=%v", envName, val)) } s := strings.Join(lines, "\n") if _, err := f.WriteString(s); err != nil { return ConfigMarshalError{err} } case "ini": keys := v.AllKeys() cfg := ini.Empty() ini.PrettyFormat = false for i := 0; i < len(keys); i++ { key := keys[i] lastSep := strings.LastIndex(key, ".") sectionName := key[:(lastSep)] keyName := key[(lastSep + 1):] if sectionName == "default" { sectionName = "" } cfg.Section(sectionName).Key(keyName).SetValue(v.GetString(key)) } cfg.WriteTo(f) } return nil } func keyExists(k string, m map[string]interface{}) string { lk := strings.ToLower(k) for mk := range m { lmk := strings.ToLower(mk) if lmk == lk { return mk } } return "" } func castToMapStringInterface( src map[interface{}]interface{}) map[string]interface{} { tgt := map[string]interface{}{} for k, v := range src { tgt[fmt.Sprintf("%v", k)] = v } return tgt } func castMapStringSliceToMapInterface(src map[string][]string) map[string]interface{} { tgt := map[string]interface{}{} for k, v := range src { tgt[k] = v } return tgt } func castMapStringToMapInterface(src map[string]string) map[string]interface{} { tgt := map[string]interface{}{} for k, v := range src { tgt[k] = v } return tgt } func castMapFlagToMapInterface(src map[string]FlagValue) map[string]interface{} { tgt := map[string]interface{}{} for k, v := range src { tgt[k] = v } return tgt } // mergeMaps merges two maps. The `itgt` parameter is for handling go-yaml's // insistence on parsing nested structures as `map[interface{}]interface{}` // instead of using a `string` as the key for nest structures beyond one level // deep. Both map types are supported as there is a go-yaml fork that uses // `map[string]interface{}` instead. func mergeMaps( src, tgt map[string]interface{}, itgt map[interface{}]interface{}) { for sk, sv := range src { tk := keyExists(sk, tgt) if tk == "" { v.logger.Trace("", "tk", "\"\"", fmt.Sprintf("tgt[%s]", sk), sv) tgt[sk] = sv if itgt != nil { itgt[sk] = sv } continue } tv, ok := tgt[tk] if !ok { v.logger.Trace("", fmt.Sprintf("ok[%s]", tk), false, fmt.Sprintf("tgt[%s]", sk), sv) tgt[sk] = sv if itgt != nil { itgt[sk] = sv } continue } svType := reflect.TypeOf(sv) tvType := reflect.TypeOf(tv) if tvType != nil && svType != tvType { // Allow for the target to be nil v.logger.Error( "svType != tvType", "key", sk, "st", svType, "tt", tvType, "sv", sv, "tv", tv, ) continue } v.logger.Trace( "processing", "key", sk, "st", svType, "tt", tvType, "sv", sv, "tv", tv, ) switch ttv := tv.(type) { case map[interface{}]interface{}: v.logger.Trace("merging maps (must convert)") tsv := sv.(map[interface{}]interface{}) ssv := castToMapStringInterface(tsv) stv := castToMapStringInterface(ttv) mergeMaps(ssv, stv, ttv) case map[string]interface{}: v.logger.Trace("merging maps") mergeMaps(sv.(map[string]interface{}), ttv, nil) default: v.logger.Trace("setting value") tgt[tk] = sv if itgt != nil { itgt[tk] = sv } } } } // ReadRemoteConfig attempts to get configuration from a remote source // and read it in the remote configuration registry. func ReadRemoteConfig() error { return v.ReadRemoteConfig() } func (v *Viper) ReadRemoteConfig() error { return v.getKeyValueConfig() } func WatchRemoteConfig() error { return v.WatchRemoteConfig() } func (v *Viper) WatchRemoteConfig() error { return v.watchKeyValueConfig() } func (v *Viper) WatchRemoteConfigOnChannel() error { return v.watchKeyValueConfigOnChannel() } // Retrieve the first found remote configuration. func (v *Viper) getKeyValueConfig() error { if RemoteConfig == nil { return RemoteConfigError("Enable the remote features by doing a blank import of the viper/remote package: '_ github.com/spf13/viper/remote'") } for _, rp := range v.remoteProviders { val, err := v.getRemoteConfig(rp) if err != nil { v.logger.Error(fmt.Errorf("get remote config: %w", err).Error()) continue } v.kvstore = val return nil } return RemoteConfigError("No Files Found") } func (v *Viper) getRemoteConfig(provider RemoteProvider) (map[string]interface{}, error) { reader, err := RemoteConfig.Get(provider) if err != nil { return nil, err } err = v.unmarshalReader(reader, v.kvstore) return v.kvstore, err } // Retrieve the first found remote configuration. func (v *Viper) watchKeyValueConfigOnChannel() error { for _, rp := range v.remoteProviders { respc, _ := RemoteConfig.WatchChannel(rp) // Todo: Add quit channel go func(rc <-chan *RemoteResponse) { for { b := <-rc reader := bytes.NewReader(b.Value) v.unmarshalReader(reader, v.kvstore) } }(respc) return nil } return RemoteConfigError("No Files Found") } // Retrieve the first found remote configuration. func (v *Viper) watchKeyValueConfig() error { for _, rp := range v.remoteProviders { val, err := v.watchRemoteConfig(rp) if err != nil { continue } v.kvstore = val return nil } return RemoteConfigError("No Files Found") } func (v *Viper) watchRemoteConfig(provider RemoteProvider) (map[string]interface{}, error) { reader, err := RemoteConfig.Watch(provider) if err != nil { return nil, err } err = v.unmarshalReader(reader, v.kvstore) return v.kvstore, err } // AllKeys returns all keys holding a value, regardless of where they are set. // Nested keys are returned with a v.keyDelim separator func AllKeys() []string { return v.AllKeys() } func (v *Viper) AllKeys() []string { m := map[string]bool{} // add all paths, by order of descending priority to ensure correct shadowing m = v.flattenAndMergeMap(m, castMapStringToMapInterface(v.aliases), "") m = v.flattenAndMergeMap(m, v.override, "") m = v.mergeFlatMap(m, castMapFlagToMapInterface(v.pflags)) m = v.mergeFlatMap(m, castMapStringSliceToMapInterface(v.env)) m = v.flattenAndMergeMap(m, v.config, "") m = v.flattenAndMergeMap(m, v.kvstore, "") m = v.flattenAndMergeMap(m, v.defaults, "") // convert set of paths to list a := make([]string, 0, len(m)) for x := range m { a = append(a, x) } return a } // flattenAndMergeMap recursively flattens the given map into a map[string]bool // of key paths (used as a set, easier to manipulate than a []string): // - each path is merged into a single key string, delimited with v.keyDelim // - if a path is shadowed by an earlier value in the initial shadow map, // it is skipped. // The resulting set of paths is merged to the given shadow set at the same time. func (v *Viper) flattenAndMergeMap(shadow map[string]bool, m map[string]interface{}, prefix string) map[string]bool { if shadow != nil && prefix != "" && shadow[prefix] { // prefix is shadowed => nothing more to flatten return shadow } if shadow == nil { shadow = make(map[string]bool) } var m2 map[string]interface{} if prefix != "" { prefix += v.keyDelim } for k, val := range m { fullKey := prefix + k switch val.(type) { case map[string]interface{}: m2 = val.(map[string]interface{}) case map[interface{}]interface{}: m2 = cast.ToStringMap(val) default: // immediate value shadow[strings.ToLower(fullKey)] = true continue } // recursively merge to shadow map shadow = v.flattenAndMergeMap(shadow, m2, fullKey) } return shadow } // mergeFlatMap merges the given maps, excluding values of the second map // shadowed by values from the first map. func (v *Viper) mergeFlatMap(shadow map[string]bool, m map[string]interface{}) map[string]bool { // scan keys outer: for k := range m { path := strings.Split(k, v.keyDelim) // scan intermediate paths var parentKey string for i := 1; i < len(path); i++ { parentKey = strings.Join(path[0:i], v.keyDelim) if shadow[parentKey] { // path is shadowed, continue continue outer } } // add key shadow[strings.ToLower(k)] = true } return shadow } // AllSettings merges all settings and returns them as a map[string]interface{}. func AllSettings() map[string]interface{} { return v.AllSettings() } func (v *Viper) AllSettings() map[string]interface{} { m := map[string]interface{}{} // start from the list of keys, and construct the map one value at a time for _, k := range v.AllKeys() { value := v.Get(k) if value == nil { // should not happen, since AllKeys() returns only keys holding a value, // check just in case anything changes continue } path := strings.Split(k, v.keyDelim) lastKey := strings.ToLower(path[len(path)-1]) deepestMap := deepSearch(m, path[0:len(path)-1]) // set innermost value deepestMap[lastKey] = value } return m } // SetFs sets the filesystem to use to read configuration. func SetFs(fs afero.Fs) { v.SetFs(fs) } func (v *Viper) SetFs(fs afero.Fs) { v.fs = fs } // SetConfigName sets name for the config file. // Does not include extension. func SetConfigName(in string) { v.SetConfigName(in) } func (v *Viper) SetConfigName(in string) { if in != "" { v.configName = in v.configFile = "" } } // SetConfigType sets the type of the configuration returned by the // remote source, e.g. "json". func SetConfigType(in string) { v.SetConfigType(in) } func (v *Viper) SetConfigType(in string) { if in != "" { v.configType = in } } // SetConfigPermissions sets the permissions for the config file. func SetConfigPermissions(perm os.FileMode) { v.SetConfigPermissions(perm) } func (v *Viper) SetConfigPermissions(perm os.FileMode) { v.configPermissions = perm.Perm() } // IniLoadOptions sets the load options for ini parsing. func IniLoadOptions(in ini.LoadOptions) Option { return optionFunc(func(v *Viper) { v.iniLoadOptions = in }) } func (v *Viper) getConfigType() string { if v.configType != "" { return v.configType } cf, err := v.getConfigFile() if err != nil { return "" } ext := filepath.Ext(cf) if len(ext) > 1 { return ext[1:] } return "" } func (v *Viper) getConfigFile() (string, error) { if v.configFile == "" { cf, err := v.findConfigFile() if err != nil { return "", err } v.configFile = cf } return v.configFile, nil } // Debug prints all configuration registries for debugging // purposes. func Debug() { v.Debug() } func (v *Viper) Debug() { fmt.Printf("Aliases:\n%#v\n", v.aliases) fmt.Printf("Override:\n%#v\n", v.override) fmt.Printf("PFlags:\n%#v\n", v.pflags) fmt.Printf("Env:\n%#v\n", v.env) fmt.Printf("Key/Value Store:\n%#v\n", v.kvstore) fmt.Printf("Config:\n%#v\n", v.config) fmt.Printf("Defaults:\n%#v\n", v.defaults) } viper-1.10.1/viper_go1_15.go000066400000000000000000000026001415636445600154620ustar00rootroot00000000000000//go:build !go1.16 || !finder // +build !go1.16 !finder package viper import ( "fmt" "os" "path/filepath" "github.com/spf13/afero" ) // Search all configPaths for any config file. // Returns the first path that exists (and is a config file). func (v *Viper) findConfigFile() (string, error) { v.logger.Info("searching for config in paths", "paths", v.configPaths) for _, cp := range v.configPaths { file := v.searchInPath(cp) if file != "" { return file, nil } } return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)} } func (v *Viper) searchInPath(in string) (filename string) { v.logger.Debug("searching for config in path", "path", in) for _, ext := range SupportedExts { v.logger.Debug("checking if file exists", "file", filepath.Join(in, v.configName+"."+ext)) if b, _ := exists(v.fs, filepath.Join(in, v.configName+"."+ext)); b { v.logger.Debug("found file", "file", filepath.Join(in, v.configName+"."+ext)) return filepath.Join(in, v.configName+"."+ext) } } if v.configType != "" { if b, _ := exists(v.fs, filepath.Join(in, v.configName)); b { return filepath.Join(in, v.configName) } } return "" } // Check if file Exists func exists(fs afero.Fs, path string) (bool, error) { stat, err := fs.Stat(path) if err == nil { return !stat.IsDir(), nil } if os.IsNotExist(err) { return false, nil } return false, err } viper-1.10.1/viper_go1_16.go000066400000000000000000000012261415636445600154660ustar00rootroot00000000000000//go:build go1.16 && finder // +build go1.16,finder package viper import ( "fmt" "github.com/spf13/afero" ) // Search all configPaths for any config file. // Returns the first path that exists (and is a config file). func (v *Viper) findConfigFile() (string, error) { finder := finder{ paths: v.configPaths, fileNames: []string{v.configName}, extensions: SupportedExts, withoutExtension: v.configType != "", } file, err := finder.Find(afero.NewIOFS(v.fs)) if err != nil { return "", err } if file == "" { return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)} } return file, nil } viper-1.10.1/viper_test.go000066400000000000000000001620061415636445600154550ustar00rootroot00000000000000// Copyright © 2014 Steve Francia . // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. package viper import ( "bytes" "encoding/json" "io" "io/ioutil" "os" "os/exec" "path" "path/filepath" "reflect" "runtime" "sort" "strings" "sync" "testing" "time" "github.com/fsnotify/fsnotify" "github.com/mitchellh/mapstructure" "github.com/spf13/afero" "github.com/spf13/cast" "github.com/spf13/pflag" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/spf13/viper/internal/testutil" ) var yamlExample = []byte(`Hacker: true name: steve hobbies: - skateboarding - snowboarding - go clothing: jacket: leather trousers: denim pants: size: large age: 35 eyes : brown beard: true `) var yamlExampleWithExtras = []byte(`Existing: true Bogus: true `) type testUnmarshalExtra struct { Existing bool } var tomlExample = []byte(` title = "TOML Example" [owner] organization = "MongoDB" Bio = "MongoDB Chief Developer Advocate & Hacker at Large" dob = 1979-05-27T07:32:00Z # First class dates? Why not?`) var dotenvExample = []byte(` TITLE_DOTENV="DotEnv Example" TYPE_DOTENV=donut NAME_DOTENV=Cake`) var jsonExample = []byte(`{ "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters": { "batter": [ { "type": "Regular" }, { "type": "Chocolate" }, { "type": "Blueberry" }, { "type": "Devil's Food" } ] } }`) var hclExample = []byte(` id = "0001" type = "donut" name = "Cake" ppu = 0.55 foos { foo { key = 1 } foo { key = 2 } foo { key = 3 } foo { key = 4 } }`) var propertiesExample = []byte(` p_id: 0001 p_type: donut p_name: Cake p_ppu: 0.55 p_batters.batter.type: Regular `) var remoteExample = []byte(`{ "id":"0002", "type":"cronut", "newkey":"remote" }`) var iniExample = []byte(`; Package name NAME = ini ; Package version VERSION = v1 ; Package import path IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s # Information about package author # Bio can be written in multiple lines. [author] NAME = Unknown ; Succeeding comment E-MAIL = fake@localhost GITHUB = https://github.com/%(NAME)s BIO = """Gopher. Coding addict. Good man. """ # Succeeding comment`) func initConfigs() { Reset() var r io.Reader SetConfigType("yaml") r = bytes.NewReader(yamlExample) unmarshalReader(r, v.config) SetConfigType("json") r = bytes.NewReader(jsonExample) unmarshalReader(r, v.config) SetConfigType("hcl") r = bytes.NewReader(hclExample) unmarshalReader(r, v.config) SetConfigType("properties") r = bytes.NewReader(propertiesExample) unmarshalReader(r, v.config) SetConfigType("toml") r = bytes.NewReader(tomlExample) unmarshalReader(r, v.config) SetConfigType("env") r = bytes.NewReader(dotenvExample) unmarshalReader(r, v.config) SetConfigType("json") remote := bytes.NewReader(remoteExample) unmarshalReader(remote, v.kvstore) SetConfigType("ini") r = bytes.NewReader(iniExample) unmarshalReader(r, v.config) } func initConfig(typ, config string) { Reset() SetConfigType(typ) r := strings.NewReader(config) if err := unmarshalReader(r, v.config); err != nil { panic(err) } } func initYAML() { initConfig("yaml", string(yamlExample)) } func initJSON() { Reset() SetConfigType("json") r := bytes.NewReader(jsonExample) unmarshalReader(r, v.config) } func initProperties() { Reset() SetConfigType("properties") r := bytes.NewReader(propertiesExample) unmarshalReader(r, v.config) } func initTOML() { Reset() SetConfigType("toml") r := bytes.NewReader(tomlExample) unmarshalReader(r, v.config) } func initDotEnv() { Reset() SetConfigType("env") r := bytes.NewReader(dotenvExample) unmarshalReader(r, v.config) } func initHcl() { Reset() SetConfigType("hcl") r := bytes.NewReader(hclExample) unmarshalReader(r, v.config) } func initIni() { Reset() SetConfigType("ini") r := bytes.NewReader(iniExample) unmarshalReader(r, v.config) } // make directories for testing func initDirs(t *testing.T) (string, string, func()) { var ( testDirs = []string{`a a`, `b`, `C_`} config = `improbable` ) if runtime.GOOS != "windows" { testDirs = append(testDirs, `d\d`) } root, err := ioutil.TempDir("", "") require.NoError(t, err, "Failed to create temporary directory") cleanup := true defer func() { if cleanup { os.Chdir("..") os.RemoveAll(root) } }() assert.Nil(t, err) err = os.Chdir(root) require.Nil(t, err) for _, dir := range testDirs { err = os.Mkdir(dir, 0o750) assert.Nil(t, err) err = ioutil.WriteFile( path.Join(dir, config+".toml"), []byte("key = \"value is "+dir+"\"\n"), 0o640) assert.Nil(t, err) } cleanup = false return root, config, func() { os.Chdir("..") os.RemoveAll(root) } } // stubs for PFlag Values type stringValue string func newStringValue(val string, p *string) *stringValue { *p = val return (*stringValue)(p) } func (s *stringValue) Set(val string) error { *s = stringValue(val) return nil } func (s *stringValue) Type() string { return "string" } func (s *stringValue) String() string { return string(*s) } func TestGetConfigFile(t *testing.T) { t.Run("config file set", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) require.NoError(t, err) v := New() v.SetFs(fs) v.AddConfigPath("/etc/viper") v.SetConfigFile(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) filename, err := v.getConfigFile() assert.Equal(t, testutil.AbsFilePath(t, "/etc/viper/config.yaml"), filename) assert.NoError(t, err) }) t.Run("find file", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) require.NoError(t, err) v := New() v.SetFs(fs) v.AddConfigPath("/etc/viper") filename, err := v.getConfigFile() assert.Equal(t, testutil.AbsFilePath(t, "/etc/viper/config.yaml"), filename) assert.NoError(t, err) }) t.Run("find files only", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/config"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/etc/config/config.yaml")) require.NoError(t, err) v := New() v.SetFs(fs) v.AddConfigPath("/etc") v.AddConfigPath("/etc/config") filename, err := v.getConfigFile() assert.Equal(t, testutil.AbsFilePath(t, "/etc/config/config.yaml"), filename) assert.NoError(t, err) }) t.Run("precedence", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/home/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/home/viper/config.zml")) require.NoError(t, err) err = fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.bml")) require.NoError(t, err) err = fs.Mkdir(testutil.AbsFilePath(t, "/var/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/var/viper/config.yaml")) require.NoError(t, err) v := New() v.SetFs(fs) v.AddConfigPath("/home/viper") v.AddConfigPath("/etc/viper") v.AddConfigPath("/var/viper") filename, err := v.getConfigFile() assert.Equal(t, testutil.AbsFilePath(t, "/var/viper/config.yaml"), filename) assert.NoError(t, err) }) t.Run("without extension", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/etc/viper/.dotfilenoext")) require.NoError(t, err) v := New() v.SetFs(fs) v.AddConfigPath("/etc/viper") v.SetConfigName(".dotfilenoext") v.SetConfigType("yaml") filename, err := v.getConfigFile() assert.Equal(t, testutil.AbsFilePath(t, "/etc/viper/.dotfilenoext"), filename) assert.NoError(t, err) }) t.Run("without extension and config type", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777) require.NoError(t, err) _, err = fs.Create(testutil.AbsFilePath(t, "/etc/viper/.dotfilenoext")) require.NoError(t, err) v := New() v.SetFs(fs) v.AddConfigPath("/etc/viper") v.SetConfigName(".dotfilenoext") _, err = v.getConfigFile() // unless config type is set, files without extension // are not considered assert.Error(t, err) }) } func TestReadInConfig(t *testing.T) { t.Run("config file set", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir("/etc/viper", 0o777) require.NoError(t, err) file, err := fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) require.NoError(t, err) _, err = file.Write([]byte(`key: value`)) require.NoError(t, err) file.Close() v := New() v.SetFs(fs) v.SetConfigFile(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) err = v.ReadInConfig() require.NoError(t, err) assert.Equal(t, "value", v.Get("key")) }) t.Run("find file", func(t *testing.T) { fs := afero.NewMemMapFs() err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777) require.NoError(t, err) file, err := fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) require.NoError(t, err) _, err = file.Write([]byte(`key: value`)) require.NoError(t, err) file.Close() v := New() v.SetFs(fs) v.AddConfigPath("/etc/viper") err = v.ReadInConfig() require.NoError(t, err) assert.Equal(t, "value", v.Get("key")) }) } func TestDefault(t *testing.T) { SetDefault("age", 45) assert.Equal(t, 45, Get("age")) SetDefault("clothing.jacket", "slacks") assert.Equal(t, "slacks", Get("clothing.jacket")) SetConfigType("yaml") err := ReadConfig(bytes.NewBuffer(yamlExample)) assert.NoError(t, err) assert.Equal(t, "leather", Get("clothing.jacket")) } func TestUnmarshaling(t *testing.T) { SetConfigType("yaml") r := bytes.NewReader(yamlExample) unmarshalReader(r, v.config) assert.True(t, InConfig("name")) assert.True(t, InConfig("clothing.jacket")) assert.False(t, InConfig("state")) assert.False(t, InConfig("clothing.hat")) assert.Equal(t, "steve", Get("name")) assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, Get("hobbies")) assert.Equal(t, map[string]interface{}{"jacket": "leather", "trousers": "denim", "pants": map[string]interface{}{"size": "large"}}, Get("clothing")) assert.Equal(t, 35, Get("age")) } func TestUnmarshalExact(t *testing.T) { vip := New() target := &testUnmarshalExtra{} vip.SetConfigType("yaml") r := bytes.NewReader(yamlExampleWithExtras) vip.ReadConfig(r) err := vip.UnmarshalExact(target) if err == nil { t.Fatal("UnmarshalExact should error when populating a struct from a conf that contains unused fields") } } func TestOverrides(t *testing.T) { Set("age", 40) assert.Equal(t, 40, Get("age")) } func TestDefaultPost(t *testing.T) { assert.NotEqual(t, "NYC", Get("state")) SetDefault("state", "NYC") assert.Equal(t, "NYC", Get("state")) } func TestAliases(t *testing.T) { RegisterAlias("years", "age") assert.Equal(t, 40, Get("years")) Set("years", 45) assert.Equal(t, 45, Get("age")) } func TestAliasInConfigFile(t *testing.T) { // the config file specifies "beard". If we make this an alias for // "hasbeard", we still want the old config file to work with beard. RegisterAlias("beard", "hasbeard") assert.Equal(t, true, Get("hasbeard")) Set("hasbeard", false) assert.Equal(t, false, Get("beard")) } func TestYML(t *testing.T) { initYAML() assert.Equal(t, "steve", Get("name")) } func TestJSON(t *testing.T) { initJSON() assert.Equal(t, "0001", Get("id")) } func TestProperties(t *testing.T) { initProperties() assert.Equal(t, "0001", Get("p_id")) } func TestTOML(t *testing.T) { initTOML() assert.Equal(t, "TOML Example", Get("title")) } func TestDotEnv(t *testing.T) { initDotEnv() assert.Equal(t, "DotEnv Example", Get("title_dotenv")) } func TestHCL(t *testing.T) { initHcl() assert.Equal(t, "0001", Get("id")) assert.Equal(t, 0.55, Get("ppu")) assert.Equal(t, "donut", Get("type")) assert.Equal(t, "Cake", Get("name")) Set("id", "0002") assert.Equal(t, "0002", Get("id")) assert.NotEqual(t, "cronut", Get("type")) } func TestIni(t *testing.T) { initIni() assert.Equal(t, "ini", Get("default.name")) } func TestRemotePrecedence(t *testing.T) { initJSON() remote := bytes.NewReader(remoteExample) assert.Equal(t, "0001", Get("id")) unmarshalReader(remote, v.kvstore) assert.Equal(t, "0001", Get("id")) assert.NotEqual(t, "cronut", Get("type")) assert.Equal(t, "remote", Get("newkey")) Set("newkey", "newvalue") assert.NotEqual(t, "remote", Get("newkey")) assert.Equal(t, "newvalue", Get("newkey")) Set("newkey", "remote") } func TestEnv(t *testing.T) { initJSON() BindEnv("id") BindEnv("f", "FOOD", "OLD_FOOD") testutil.Setenv(t, "ID", "13") testutil.Setenv(t, "FOOD", "apple") testutil.Setenv(t, "OLD_FOOD", "banana") testutil.Setenv(t, "NAME", "crunk") assert.Equal(t, "13", Get("id")) assert.Equal(t, "apple", Get("f")) assert.Equal(t, "Cake", Get("name")) AutomaticEnv() assert.Equal(t, "crunk", Get("name")) } func TestMultipleEnv(t *testing.T) { initJSON() BindEnv("f", "FOOD", "OLD_FOOD") testutil.Setenv(t, "OLD_FOOD", "banana") assert.Equal(t, "banana", Get("f")) } func TestEmptyEnv(t *testing.T) { initJSON() BindEnv("type") // Empty environment variable BindEnv("name") // Bound, but not set environment variable testutil.Setenv(t, "TYPE", "") assert.Equal(t, "donut", Get("type")) assert.Equal(t, "Cake", Get("name")) } func TestEmptyEnv_Allowed(t *testing.T) { initJSON() AllowEmptyEnv(true) BindEnv("type") // Empty environment variable BindEnv("name") // Bound, but not set environment variable testutil.Setenv(t, "TYPE", "") assert.Equal(t, "", Get("type")) assert.Equal(t, "Cake", Get("name")) } func TestEnvPrefix(t *testing.T) { initJSON() SetEnvPrefix("foo") // will be uppercased automatically BindEnv("id") BindEnv("f", "FOOD") // not using prefix testutil.Setenv(t, "FOO_ID", "13") testutil.Setenv(t, "FOOD", "apple") testutil.Setenv(t, "FOO_NAME", "crunk") assert.Equal(t, "13", Get("id")) assert.Equal(t, "apple", Get("f")) assert.Equal(t, "Cake", Get("name")) AutomaticEnv() assert.Equal(t, "crunk", Get("name")) } func TestAutoEnv(t *testing.T) { Reset() AutomaticEnv() testutil.Setenv(t, "FOO_BAR", "13") assert.Equal(t, "13", Get("foo_bar")) } func TestAutoEnvWithPrefix(t *testing.T) { Reset() AutomaticEnv() SetEnvPrefix("Baz") testutil.Setenv(t, "BAZ_BAR", "13") assert.Equal(t, "13", Get("bar")) } func TestSetEnvKeyReplacer(t *testing.T) { Reset() AutomaticEnv() testutil.Setenv(t, "REFRESH_INTERVAL", "30s") replacer := strings.NewReplacer("-", "_") SetEnvKeyReplacer(replacer) assert.Equal(t, "30s", Get("refresh-interval")) } func TestEnvKeyReplacer(t *testing.T) { v := NewWithOptions(EnvKeyReplacer(strings.NewReplacer("-", "_"))) v.AutomaticEnv() testutil.Setenv(t, "REFRESH_INTERVAL", "30s") assert.Equal(t, "30s", v.Get("refresh-interval")) } func TestAllKeys(t *testing.T) { initConfigs() ks := sort.StringSlice{ "title", "author.bio", "author.e-mail", "author.github", "author.name", "newkey", "owner.organization", "owner.dob", "owner.bio", "name", "beard", "ppu", "batters.batter", "hobbies", "clothing.jacket", "clothing.trousers", "default.import_path", "default.name", "default.version", "clothing.pants.size", "age", "hacker", "id", "type", "eyes", "p_id", "p_ppu", "p_batters.batter.type", "p_type", "p_name", "foos", "title_dotenv", "type_dotenv", "name_dotenv", } dob, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z") all := map[string]interface{}{ "owner": map[string]interface{}{ "organization": "MongoDB", "bio": "MongoDB Chief Developer Advocate & Hacker at Large", "dob": dob, }, "title": "TOML Example", "author": map[string]interface{}{ "e-mail": "fake@localhost", "github": "https://github.com/Unknown", "name": "Unknown", "bio": "Gopher.\nCoding addict.\nGood man.\n", }, "ppu": 0.55, "eyes": "brown", "clothing": map[string]interface{}{ "trousers": "denim", "jacket": "leather", "pants": map[string]interface{}{"size": "large"}, }, "default": map[string]interface{}{ "import_path": "gopkg.in/ini.v1", "name": "ini", "version": "v1", }, "id": "0001", "batters": map[string]interface{}{ "batter": []interface{}{ map[string]interface{}{"type": "Regular"}, map[string]interface{}{"type": "Chocolate"}, map[string]interface{}{"type": "Blueberry"}, map[string]interface{}{"type": "Devil's Food"}, }, }, "hacker": true, "beard": true, "hobbies": []interface{}{ "skateboarding", "snowboarding", "go", }, "age": 35, "type": "donut", "newkey": "remote", "name": "Cake", "p_id": "0001", "p_ppu": "0.55", "p_name": "Cake", "p_batters": map[string]interface{}{ "batter": map[string]interface{}{"type": "Regular"}, }, "p_type": "donut", "foos": []map[string]interface{}{ { "foo": []map[string]interface{}{ {"key": 1}, {"key": 2}, {"key": 3}, {"key": 4}, }, }, }, "title_dotenv": "DotEnv Example", "type_dotenv": "donut", "name_dotenv": "Cake", } allkeys := sort.StringSlice(AllKeys()) allkeys.Sort() ks.Sort() assert.Equal(t, ks, allkeys) assert.Equal(t, all, AllSettings()) } func TestAllKeysWithEnv(t *testing.T) { v := New() // bind and define environment variables (including a nested one) v.BindEnv("id") v.BindEnv("foo.bar") v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) testutil.Setenv(t, "ID", "13") testutil.Setenv(t, "FOO_BAR", "baz") expectedKeys := sort.StringSlice{"id", "foo.bar"} expectedKeys.Sort() keys := sort.StringSlice(v.AllKeys()) keys.Sort() assert.Equal(t, expectedKeys, keys) } func TestAliasesOfAliases(t *testing.T) { Set("Title", "Checking Case") RegisterAlias("Foo", "Bar") RegisterAlias("Bar", "Title") assert.Equal(t, "Checking Case", Get("FOO")) } func TestRecursiveAliases(t *testing.T) { RegisterAlias("Baz", "Roo") RegisterAlias("Roo", "baz") } func TestUnmarshal(t *testing.T) { SetDefault("port", 1313) Set("name", "Steve") Set("duration", "1s1ms") Set("modes", []int{1, 2, 3}) type config struct { Port int Name string Duration time.Duration Modes []int } var C config err := Unmarshal(&C) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } assert.Equal( t, &config{ Name: "Steve", Port: 1313, Duration: time.Second + time.Millisecond, Modes: []int{1, 2, 3}, }, &C, ) Set("port", 1234) err = Unmarshal(&C) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } assert.Equal( t, &config{ Name: "Steve", Port: 1234, Duration: time.Second + time.Millisecond, Modes: []int{1, 2, 3}, }, &C, ) } func TestUnmarshalWithDecoderOptions(t *testing.T) { Set("credentials", "{\"foo\":\"bar\"}") opt := DecodeHook(mapstructure.ComposeDecodeHookFunc( mapstructure.StringToTimeDurationHookFunc(), mapstructure.StringToSliceHookFunc(","), // Custom Decode Hook Function func(rf reflect.Kind, rt reflect.Kind, data interface{}) (interface{}, error) { if rf != reflect.String || rt != reflect.Map { return data, nil } m := map[string]string{} raw := data.(string) if raw == "" { return m, nil } return m, json.Unmarshal([]byte(raw), &m) }, )) type config struct { Credentials map[string]string } var C config err := Unmarshal(&C, opt) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } assert.Equal(t, &config{ Credentials: map[string]string{"foo": "bar"}, }, &C) } func TestBindPFlags(t *testing.T) { v := New() // create independent Viper object flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) testValues := map[string]*string{ "host": nil, "port": nil, "endpoint": nil, } mutatedTestValues := map[string]string{ "host": "localhost", "port": "6060", "endpoint": "/public", } for name := range testValues { testValues[name] = flagSet.String(name, "", "test") } err := v.BindPFlags(flagSet) if err != nil { t.Fatalf("error binding flag set, %v", err) } flagSet.VisitAll(func(flag *pflag.Flag) { flag.Value.Set(mutatedTestValues[flag.Name]) flag.Changed = true }) for name, expected := range mutatedTestValues { assert.Equal(t, expected, v.Get(name)) } } // nolint: dupl func TestBindPFlagsStringSlice(t *testing.T) { tests := []struct { Expected []string Value string }{ {[]string{}, ""}, {[]string{"jeden"}, "jeden"}, {[]string{"dwa", "trzy"}, "dwa,trzy"}, {[]string{"cztery", "piec , szesc"}, "cztery,\"piec , szesc\""}, } v := New() // create independent Viper object defaultVal := []string{"default"} v.SetDefault("stringslice", defaultVal) for _, testValue := range tests { flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) flagSet.StringSlice("stringslice", testValue.Expected, "test") for _, changed := range []bool{true, false} { flagSet.VisitAll(func(f *pflag.Flag) { f.Value.Set(testValue.Value) f.Changed = changed }) err := v.BindPFlags(flagSet) if err != nil { t.Fatalf("error binding flag set, %v", err) } type TestStr struct { StringSlice []string } val := &TestStr{} if err := v.Unmarshal(val); err != nil { t.Fatalf("%+#v cannot unmarshal: %s", testValue.Value, err) } if changed { assert.Equal(t, testValue.Expected, val.StringSlice) assert.Equal(t, testValue.Expected, v.Get("stringslice")) } else { assert.Equal(t, defaultVal, val.StringSlice) } } } } // nolint: dupl func TestBindPFlagsStringArray(t *testing.T) { tests := []struct { Expected []string Value string }{ {[]string{}, ""}, {[]string{"jeden"}, "jeden"}, {[]string{"dwa,trzy"}, "dwa,trzy"}, {[]string{"cztery,\"piec , szesc\""}, "cztery,\"piec , szesc\""}, } v := New() // create independent Viper object defaultVal := []string{"default"} v.SetDefault("stringarray", defaultVal) for _, testValue := range tests { flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) flagSet.StringArray("stringarray", testValue.Expected, "test") for _, changed := range []bool{true, false} { flagSet.VisitAll(func(f *pflag.Flag) { f.Value.Set(testValue.Value) f.Changed = changed }) err := v.BindPFlags(flagSet) if err != nil { t.Fatalf("error binding flag set, %v", err) } type TestStr struct { StringArray []string } val := &TestStr{} if err := v.Unmarshal(val); err != nil { t.Fatalf("%+#v cannot unmarshal: %s", testValue.Value, err) } if changed { assert.Equal(t, testValue.Expected, val.StringArray) assert.Equal(t, testValue.Expected, v.Get("stringarray")) } else { assert.Equal(t, defaultVal, val.StringArray) } } } } // nolint: dupl func TestBindPFlagsIntSlice(t *testing.T) { tests := []struct { Expected []int Value string }{ {[]int{}, ""}, {[]int{1}, "1"}, {[]int{2, 3}, "2,3"}, } v := New() // create independent Viper object defaultVal := []int{0} v.SetDefault("intslice", defaultVal) for _, testValue := range tests { flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) flagSet.IntSlice("intslice", testValue.Expected, "test") for _, changed := range []bool{true, false} { flagSet.VisitAll(func(f *pflag.Flag) { f.Value.Set(testValue.Value) f.Changed = changed }) err := v.BindPFlags(flagSet) if err != nil { t.Fatalf("error binding flag set, %v", err) } type TestInt struct { IntSlice []int } val := &TestInt{} if err := v.Unmarshal(val); err != nil { t.Fatalf("%+#v cannot unmarshal: %s", testValue.Value, err) } if changed { assert.Equal(t, testValue.Expected, val.IntSlice) assert.Equal(t, testValue.Expected, v.Get("intslice")) } else { assert.Equal(t, defaultVal, val.IntSlice) } } } } func TestBindPFlag(t *testing.T) { testString := "testing" testValue := newStringValue(testString, &testString) flag := &pflag.Flag{ Name: "testflag", Value: testValue, Changed: false, } BindPFlag("testvalue", flag) assert.Equal(t, testString, Get("testvalue")) flag.Value.Set("testing_mutate") flag.Changed = true // hack for pflag usage assert.Equal(t, "testing_mutate", Get("testvalue")) } func TestBindPFlagDetectNilFlag(t *testing.T) { result := BindPFlag("testvalue", nil) assert.Error(t, result) } func TestBindPFlagStringToString(t *testing.T) { tests := []struct { Expected map[string]string Value string }{ {map[string]string{}, ""}, {map[string]string{"yo": "hi"}, "yo=hi"}, {map[string]string{"yo": "hi", "oh": "hi=there"}, "yo=hi,oh=hi=there"}, {map[string]string{"yo": ""}, "yo="}, {map[string]string{"yo": "", "oh": "hi=there"}, "yo=,oh=hi=there"}, } v := New() // create independent Viper object defaultVal := map[string]string{} v.SetDefault("stringtostring", defaultVal) for _, testValue := range tests { flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) flagSet.StringToString("stringtostring", testValue.Expected, "test") for _, changed := range []bool{true, false} { flagSet.VisitAll(func(f *pflag.Flag) { f.Value.Set(testValue.Value) f.Changed = changed }) err := v.BindPFlags(flagSet) if err != nil { t.Fatalf("error binding flag set, %v", err) } type TestMap struct { StringToString map[string]string } val := &TestMap{} if err := v.Unmarshal(val); err != nil { t.Fatalf("%+#v cannot unmarshal: %s", testValue.Value, err) } if changed { assert.Equal(t, testValue.Expected, val.StringToString) } else { assert.Equal(t, defaultVal, val.StringToString) } } } } func TestBoundCaseSensitivity(t *testing.T) { assert.Equal(t, "brown", Get("eyes")) BindEnv("eYEs", "TURTLE_EYES") testutil.Setenv(t, "TURTLE_EYES", "blue") assert.Equal(t, "blue", Get("eyes")) testString := "green" testValue := newStringValue(testString, &testString) flag := &pflag.Flag{ Name: "eyeballs", Value: testValue, Changed: true, } BindPFlag("eYEs", flag) assert.Equal(t, "green", Get("eyes")) } func TestSizeInBytes(t *testing.T) { input := map[string]uint{ "": 0, "b": 0, "12 bytes": 0, "200000000000gb": 0, "12 b": 12, "43 MB": 43 * (1 << 20), "10mb": 10 * (1 << 20), "1gb": 1 << 30, } for str, expected := range input { assert.Equal(t, expected, parseSizeInBytes(str), str) } } func TestFindsNestedKeys(t *testing.T) { initConfigs() dob, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z") Set("super", map[string]interface{}{ "deep": map[string]interface{}{ "nested": "value", }, }) expected := map[string]interface{}{ "super": map[string]interface{}{ "deep": map[string]interface{}{ "nested": "value", }, }, "super.deep": map[string]interface{}{ "nested": "value", }, "super.deep.nested": "value", "owner.organization": "MongoDB", "batters.batter": []interface{}{ map[string]interface{}{ "type": "Regular", }, map[string]interface{}{ "type": "Chocolate", }, map[string]interface{}{ "type": "Blueberry", }, map[string]interface{}{ "type": "Devil's Food", }, }, "hobbies": []interface{}{ "skateboarding", "snowboarding", "go", }, "TITLE_DOTENV": "DotEnv Example", "TYPE_DOTENV": "donut", "NAME_DOTENV": "Cake", "title": "TOML Example", "newkey": "remote", "batters": map[string]interface{}{ "batter": []interface{}{ map[string]interface{}{ "type": "Regular", }, map[string]interface{}{ "type": "Chocolate", }, map[string]interface{}{ "type": "Blueberry", }, map[string]interface{}{ "type": "Devil's Food", }, }, }, "eyes": "brown", "age": 35, "owner": map[string]interface{}{ "organization": "MongoDB", "bio": "MongoDB Chief Developer Advocate & Hacker at Large", "dob": dob, }, "owner.bio": "MongoDB Chief Developer Advocate & Hacker at Large", "type": "donut", "id": "0001", "name": "Cake", "hacker": true, "ppu": 0.55, "clothing": map[string]interface{}{ "jacket": "leather", "trousers": "denim", "pants": map[string]interface{}{ "size": "large", }, }, "clothing.jacket": "leather", "clothing.pants.size": "large", "clothing.trousers": "denim", "owner.dob": dob, "beard": true, "foos": []map[string]interface{}{ { "foo": []map[string]interface{}{ { "key": 1, }, { "key": 2, }, { "key": 3, }, { "key": 4, }, }, }, }, } for key, expectedValue := range expected { assert.Equal(t, expectedValue, v.Get(key)) } } func TestReadBufConfig(t *testing.T) { v := New() v.SetConfigType("yaml") v.ReadConfig(bytes.NewBuffer(yamlExample)) t.Log(v.AllKeys()) assert.True(t, v.InConfig("name")) assert.True(t, v.InConfig("clothing.jacket")) assert.False(t, v.InConfig("state")) assert.False(t, v.InConfig("clothing.hat")) assert.Equal(t, "steve", v.Get("name")) assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, v.Get("hobbies")) assert.Equal(t, map[string]interface{}{"jacket": "leather", "trousers": "denim", "pants": map[string]interface{}{"size": "large"}}, v.Get("clothing")) assert.Equal(t, 35, v.Get("age")) } func TestIsSet(t *testing.T) { v := New() v.SetConfigType("yaml") /* config and defaults */ v.ReadConfig(bytes.NewBuffer(yamlExample)) v.SetDefault("clothing.shoes", "sneakers") assert.True(t, v.IsSet("clothing")) assert.True(t, v.IsSet("clothing.jacket")) assert.False(t, v.IsSet("clothing.jackets")) assert.True(t, v.IsSet("clothing.shoes")) /* state change */ assert.False(t, v.IsSet("helloworld")) v.Set("helloworld", "fubar") assert.True(t, v.IsSet("helloworld")) /* env */ v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) v.BindEnv("eyes") v.BindEnv("foo") v.BindEnv("clothing.hat") v.BindEnv("clothing.hats") testutil.Setenv(t, "FOO", "bar") testutil.Setenv(t, "CLOTHING_HAT", "bowler") assert.True(t, v.IsSet("eyes")) // in the config file assert.True(t, v.IsSet("foo")) // in the environment assert.True(t, v.IsSet("clothing.hat")) // in the environment assert.False(t, v.IsSet("clothing.hats")) // not defined /* flags */ flagset := pflag.NewFlagSet("testisset", pflag.ContinueOnError) flagset.Bool("foobaz", false, "foobaz") flagset.Bool("barbaz", false, "barbaz") foobaz, barbaz := flagset.Lookup("foobaz"), flagset.Lookup("barbaz") v.BindPFlag("foobaz", foobaz) v.BindPFlag("barbaz", barbaz) barbaz.Value.Set("true") barbaz.Changed = true // hack for pflag usage assert.False(t, v.IsSet("foobaz")) assert.True(t, v.IsSet("barbaz")) } func TestDirsSearch(t *testing.T) { root, config, cleanup := initDirs(t) defer cleanup() v := New() v.SetConfigName(config) v.SetDefault(`key`, `default`) entries, err := ioutil.ReadDir(root) assert.Nil(t, err) for _, e := range entries { if e.IsDir() { v.AddConfigPath(e.Name()) } } err = v.ReadInConfig() assert.Nil(t, err) assert.Equal(t, `value is `+filepath.Base(v.configPaths[0]), v.GetString(`key`)) } func TestWrongDirsSearchNotFound(t *testing.T) { _, config, cleanup := initDirs(t) defer cleanup() v := New() v.SetConfigName(config) v.SetDefault(`key`, `default`) v.AddConfigPath(`whattayoutalkingbout`) v.AddConfigPath(`thispathaintthere`) err := v.ReadInConfig() assert.Equal(t, reflect.TypeOf(ConfigFileNotFoundError{"", ""}), reflect.TypeOf(err)) // Even though config did not load and the error might have // been ignored by the client, the default still loads assert.Equal(t, `default`, v.GetString(`key`)) } func TestWrongDirsSearchNotFoundForMerge(t *testing.T) { _, config, cleanup := initDirs(t) defer cleanup() v := New() v.SetConfigName(config) v.SetDefault(`key`, `default`) v.AddConfigPath(`whattayoutalkingbout`) v.AddConfigPath(`thispathaintthere`) err := v.MergeInConfig() assert.Equal(t, reflect.TypeOf(ConfigFileNotFoundError{"", ""}), reflect.TypeOf(err)) // Even though config did not load and the error might have // been ignored by the client, the default still loads assert.Equal(t, `default`, v.GetString(`key`)) } func TestSub(t *testing.T) { v := New() v.SetConfigType("yaml") v.ReadConfig(bytes.NewBuffer(yamlExample)) subv := v.Sub("clothing") assert.Equal(t, v.Get("clothing.pants.size"), subv.Get("pants.size")) subv = v.Sub("clothing.pants") assert.Equal(t, v.Get("clothing.pants.size"), subv.Get("size")) subv = v.Sub("clothing.pants.size") assert.Equal(t, (*Viper)(nil), subv) subv = v.Sub("missing.key") assert.Equal(t, (*Viper)(nil), subv) } var hclWriteExpected = []byte(`"foos" = { "foo" = { "key" = 1 } "foo" = { "key" = 2 } "foo" = { "key" = 3 } "foo" = { "key" = 4 } } "id" = "0001" "name" = "Cake" "ppu" = 0.55 "type" = "donut"`) var jsonWriteExpected = []byte(`{ "batters": { "batter": [ { "type": "Regular" }, { "type": "Chocolate" }, { "type": "Blueberry" }, { "type": "Devil's Food" } ] }, "id": "0001", "name": "Cake", "ppu": 0.55, "type": "donut" }`) var propertiesWriteExpected = []byte(`p_id = 0001 p_type = donut p_name = Cake p_ppu = 0.55 p_batters.batter.type = Regular `) var yamlWriteExpected = []byte(`age: 35 beard: true clothing: jacket: leather pants: size: large trousers: denim eyes: brown hacker: true hobbies: - skateboarding - snowboarding - go name: steve `) func TestWriteConfig(t *testing.T) { fs := afero.NewMemMapFs() testCases := map[string]struct { configName string inConfigType string outConfigType string fileName string input []byte expectedContent []byte }{ "hcl with file extension": { configName: "c", inConfigType: "hcl", outConfigType: "hcl", fileName: "c.hcl", input: hclExample, expectedContent: hclWriteExpected, }, "hcl without file extension": { configName: "c", inConfigType: "hcl", outConfigType: "hcl", fileName: "c", input: hclExample, expectedContent: hclWriteExpected, }, "hcl with file extension and mismatch type": { configName: "c", inConfigType: "hcl", outConfigType: "json", fileName: "c.hcl", input: hclExample, expectedContent: hclWriteExpected, }, "json with file extension": { configName: "c", inConfigType: "json", outConfigType: "json", fileName: "c.json", input: jsonExample, expectedContent: jsonWriteExpected, }, "json without file extension": { configName: "c", inConfigType: "json", outConfigType: "json", fileName: "c", input: jsonExample, expectedContent: jsonWriteExpected, }, "json with file extension and mismatch type": { configName: "c", inConfigType: "json", outConfigType: "hcl", fileName: "c.json", input: jsonExample, expectedContent: jsonWriteExpected, }, "properties with file extension": { configName: "c", inConfigType: "properties", outConfigType: "properties", fileName: "c.properties", input: propertiesExample, expectedContent: propertiesWriteExpected, }, "properties without file extension": { configName: "c", inConfigType: "properties", outConfigType: "properties", fileName: "c", input: propertiesExample, expectedContent: propertiesWriteExpected, }, "yaml with file extension": { configName: "c", inConfigType: "yaml", outConfigType: "yaml", fileName: "c.yaml", input: yamlExample, expectedContent: yamlWriteExpected, }, "yaml without file extension": { configName: "c", inConfigType: "yaml", outConfigType: "yaml", fileName: "c", input: yamlExample, expectedContent: yamlWriteExpected, }, "yaml with file extension and mismatch type": { configName: "c", inConfigType: "yaml", outConfigType: "json", fileName: "c.yaml", input: yamlExample, expectedContent: yamlWriteExpected, }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { v := New() v.SetFs(fs) v.SetConfigName(tc.fileName) v.SetConfigType(tc.inConfigType) err := v.ReadConfig(bytes.NewBuffer(tc.input)) if err != nil { t.Fatal(err) } v.SetConfigType(tc.outConfigType) if err := v.WriteConfigAs(tc.fileName); err != nil { t.Fatal(err) } read, err := afero.ReadFile(fs, tc.fileName) if err != nil { t.Fatal(err) } assert.Equal(t, tc.expectedContent, read) }) } } func TestWriteConfigTOML(t *testing.T) { fs := afero.NewMemMapFs() testCases := map[string]struct { configName string configType string fileName string input []byte }{ "with file extension": { configName: "c", configType: "toml", fileName: "c.toml", input: tomlExample, }, "without file extension": { configName: "c", configType: "toml", fileName: "c", input: tomlExample, }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { v := New() v.SetFs(fs) v.SetConfigName(tc.configName) v.SetConfigType(tc.configType) err := v.ReadConfig(bytes.NewBuffer(tc.input)) if err != nil { t.Fatal(err) } if err := v.WriteConfigAs(tc.fileName); err != nil { t.Fatal(err) } // The TOML String method does not order the contents. // Therefore, we must read the generated file and compare the data. v2 := New() v2.SetFs(fs) v2.SetConfigName(tc.configName) v2.SetConfigType(tc.configType) v2.SetConfigFile(tc.fileName) err = v2.ReadInConfig() if err != nil { t.Fatal(err) } assert.Equal(t, v.GetString("title"), v2.GetString("title")) assert.Equal(t, v.GetString("owner.bio"), v2.GetString("owner.bio")) assert.Equal(t, v.GetString("owner.dob"), v2.GetString("owner.dob")) assert.Equal(t, v.GetString("owner.organization"), v2.GetString("owner.organization")) }) } } func TestWriteConfigDotEnv(t *testing.T) { fs := afero.NewMemMapFs() testCases := map[string]struct { configName string configType string fileName string input []byte }{ "with file extension": { configName: "c", configType: "env", fileName: "c.env", input: dotenvExample, }, "without file extension": { configName: "c", configType: "env", fileName: "c", input: dotenvExample, }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { v := New() v.SetFs(fs) v.SetConfigName(tc.configName) v.SetConfigType(tc.configType) err := v.ReadConfig(bytes.NewBuffer(tc.input)) if err != nil { t.Fatal(err) } if err := v.WriteConfigAs(tc.fileName); err != nil { t.Fatal(err) } // The TOML String method does not order the contents. // Therefore, we must read the generated file and compare the data. v2 := New() v2.SetFs(fs) v2.SetConfigName(tc.configName) v2.SetConfigType(tc.configType) v2.SetConfigFile(tc.fileName) err = v2.ReadInConfig() if err != nil { t.Fatal(err) } assert.Equal(t, v.GetString("title_dotenv"), v2.GetString("title_dotenv")) assert.Equal(t, v.GetString("type_dotenv"), v2.GetString("type_dotenv")) assert.Equal(t, v.GetString("kind_dotenv"), v2.GetString("kind_dotenv")) }) } } func TestSafeWriteConfig(t *testing.T) { v := New() fs := afero.NewMemMapFs() v.SetFs(fs) v.AddConfigPath("/test") v.SetConfigName("c") v.SetConfigType("yaml") require.NoError(t, v.ReadConfig(bytes.NewBuffer(yamlExample))) require.NoError(t, v.SafeWriteConfig()) read, err := afero.ReadFile(fs, testutil.AbsFilePath(t, "/test/c.yaml")) require.NoError(t, err) assert.Equal(t, yamlWriteExpected, read) } func TestSafeWriteConfigWithMissingConfigPath(t *testing.T) { v := New() fs := afero.NewMemMapFs() v.SetFs(fs) v.SetConfigName("c") v.SetConfigType("yaml") require.EqualError(t, v.SafeWriteConfig(), "missing configuration for 'configPath'") } func TestSafeWriteConfigWithExistingFile(t *testing.T) { v := New() fs := afero.NewMemMapFs() fs.Create(testutil.AbsFilePath(t, "/test/c.yaml")) v.SetFs(fs) v.AddConfigPath("/test") v.SetConfigName("c") v.SetConfigType("yaml") err := v.SafeWriteConfig() require.Error(t, err) _, ok := err.(ConfigFileAlreadyExistsError) assert.True(t, ok, "Expected ConfigFileAlreadyExistsError") } func TestSafeWriteAsConfig(t *testing.T) { v := New() fs := afero.NewMemMapFs() v.SetFs(fs) err := v.ReadConfig(bytes.NewBuffer(yamlExample)) if err != nil { t.Fatal(err) } require.NoError(t, v.SafeWriteConfigAs("/test/c.yaml")) if _, err = afero.ReadFile(fs, "/test/c.yaml"); err != nil { t.Fatal(err) } } func TestSafeWriteConfigAsWithExistingFile(t *testing.T) { v := New() fs := afero.NewMemMapFs() fs.Create("/test/c.yaml") v.SetFs(fs) err := v.SafeWriteConfigAs("/test/c.yaml") require.Error(t, err) _, ok := err.(ConfigFileAlreadyExistsError) assert.True(t, ok, "Expected ConfigFileAlreadyExistsError") } func TestWriteHiddenFile(t *testing.T) { v := New() fs := afero.NewMemMapFs() fs.Create(testutil.AbsFilePath(t, "/test/.config")) v.SetFs(fs) v.SetConfigName(".config") v.SetConfigType("yaml") v.AddConfigPath("/test") err := v.ReadInConfig() require.NoError(t, err) err = v.WriteConfig() require.NoError(t, err) } var yamlMergeExampleTgt = []byte(` hello: pop: 37890 largenum: 765432101234567 num2pow63: 9223372036854775808 universe: null world: - us - uk - fr - de `) var yamlMergeExampleSrc = []byte(` hello: pop: 45000 largenum: 7654321001234567 universe: - mw - ad ints: - 1 - 2 fu: bar `) func TestMergeConfig(t *testing.T) { v := New() v.SetConfigType("yml") if err := v.ReadConfig(bytes.NewBuffer(yamlMergeExampleTgt)); err != nil { t.Fatal(err) } if pop := v.GetInt("hello.pop"); pop != 37890 { t.Fatalf("pop != 37890, = %d", pop) } if pop := v.GetInt32("hello.pop"); pop != int32(37890) { t.Fatalf("pop != 37890, = %d", pop) } if pop := v.GetInt64("hello.largenum"); pop != int64(765432101234567) { t.Fatalf("int64 largenum != 765432101234567, = %d", pop) } if pop := v.GetUint("hello.pop"); pop != 37890 { t.Fatalf("uint pop != 37890, = %d", pop) } if pop := v.GetUint32("hello.pop"); pop != 37890 { t.Fatalf("uint32 pop != 37890, = %d", pop) } if pop := v.GetUint64("hello.num2pow63"); pop != 9223372036854775808 { t.Fatalf("uint64 num2pow63 != 9223372036854775808, = %d", pop) } if world := v.GetStringSlice("hello.world"); len(world) != 4 { t.Fatalf("len(world) != 4, = %d", len(world)) } if fu := v.GetString("fu"); fu != "" { t.Fatalf("fu != \"\", = %s", fu) } if err := v.MergeConfig(bytes.NewBuffer(yamlMergeExampleSrc)); err != nil { t.Fatal(err) } if pop := v.GetInt("hello.pop"); pop != 45000 { t.Fatalf("pop != 45000, = %d", pop) } if pop := v.GetInt32("hello.pop"); pop != int32(45000) { t.Fatalf("pop != 45000, = %d", pop) } if pop := v.GetInt64("hello.largenum"); pop != int64(7654321001234567) { t.Fatalf("int64 largenum != 7654321001234567, = %d", pop) } if world := v.GetStringSlice("hello.world"); len(world) != 4 { t.Fatalf("len(world) != 4, = %d", len(world)) } if universe := v.GetStringSlice("hello.universe"); len(universe) != 2 { t.Fatalf("len(universe) != 2, = %d", len(universe)) } if ints := v.GetIntSlice("hello.ints"); len(ints) != 2 { t.Fatalf("len(ints) != 2, = %d", len(ints)) } if fu := v.GetString("fu"); fu != "bar" { t.Fatalf("fu != \"bar\", = %s", fu) } } func TestMergeConfigNoMerge(t *testing.T) { v := New() v.SetConfigType("yml") if err := v.ReadConfig(bytes.NewBuffer(yamlMergeExampleTgt)); err != nil { t.Fatal(err) } if pop := v.GetInt("hello.pop"); pop != 37890 { t.Fatalf("pop != 37890, = %d", pop) } if world := v.GetStringSlice("hello.world"); len(world) != 4 { t.Fatalf("len(world) != 4, = %d", len(world)) } if fu := v.GetString("fu"); fu != "" { t.Fatalf("fu != \"\", = %s", fu) } if err := v.ReadConfig(bytes.NewBuffer(yamlMergeExampleSrc)); err != nil { t.Fatal(err) } if pop := v.GetInt("hello.pop"); pop != 45000 { t.Fatalf("pop != 45000, = %d", pop) } if world := v.GetStringSlice("hello.world"); len(world) != 0 { t.Fatalf("len(world) != 0, = %d", len(world)) } if universe := v.GetStringSlice("hello.universe"); len(universe) != 2 { t.Fatalf("len(universe) != 2, = %d", len(universe)) } if ints := v.GetIntSlice("hello.ints"); len(ints) != 2 { t.Fatalf("len(ints) != 2, = %d", len(ints)) } if fu := v.GetString("fu"); fu != "bar" { t.Fatalf("fu != \"bar\", = %s", fu) } } func TestMergeConfigMap(t *testing.T) { v := New() v.SetConfigType("yml") if err := v.ReadConfig(bytes.NewBuffer(yamlMergeExampleTgt)); err != nil { t.Fatal(err) } assert := func(i int) { large := v.GetInt64("hello.largenum") pop := v.GetInt("hello.pop") if large != 765432101234567 { t.Fatal("Got large num:", large) } if pop != i { t.Fatal("Got pop:", pop) } } assert(37890) update := map[string]interface{}{ "Hello": map[string]interface{}{ "Pop": 1234, }, "World": map[interface{}]interface{}{ "Rock": 345, }, } if err := v.MergeConfigMap(update); err != nil { t.Fatal(err) } if rock := v.GetInt("world.rock"); rock != 345 { t.Fatal("Got rock:", rock) } assert(1234) } func TestUnmarshalingWithAliases(t *testing.T) { v := New() v.SetDefault("ID", 1) v.Set("name", "Steve") v.Set("lastname", "Owen") v.RegisterAlias("UserID", "ID") v.RegisterAlias("Firstname", "name") v.RegisterAlias("Surname", "lastname") type config struct { ID int FirstName string Surname string } var C config err := v.Unmarshal(&C) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } assert.Equal(t, &config{ID: 1, FirstName: "Steve", Surname: "Owen"}, &C) } func TestSetConfigNameClearsFileCache(t *testing.T) { SetConfigFile("/tmp/config.yaml") SetConfigName("default") f, err := v.getConfigFile() if err == nil { t.Fatalf("config file cache should have been cleared") } assert.Empty(t, f) } func TestShadowedNestedValue(t *testing.T) { config := `name: steve clothing: jacket: leather trousers: denim pants: size: large ` initConfig("yaml", config) assert.Equal(t, "steve", GetString("name")) polyester := "polyester" SetDefault("clothing.shirt", polyester) SetDefault("clothing.jacket.price", 100) assert.Equal(t, "leather", GetString("clothing.jacket")) assert.Nil(t, Get("clothing.jacket.price")) assert.Equal(t, polyester, GetString("clothing.shirt")) clothingSettings := AllSettings()["clothing"].(map[string]interface{}) assert.Equal(t, "leather", clothingSettings["jacket"]) assert.Equal(t, polyester, clothingSettings["shirt"]) } func TestDotParameter(t *testing.T) { initJSON() // shoud take precedence over batters defined in jsonExample r := bytes.NewReader([]byte(`{ "batters.batter": [ { "type": "Small" } ] }`)) unmarshalReader(r, v.config) actual := Get("batters.batter") expected := []interface{}{map[string]interface{}{"type": "Small"}} assert.Equal(t, expected, actual) } func TestCaseInsensitive(t *testing.T) { for _, config := range []struct { typ string content string }{ {"yaml", ` aBcD: 1 eF: gH: 2 iJk: 3 Lm: nO: 4 P: Q: 5 R: 6 `}, {"json", `{ "aBcD": 1, "eF": { "iJk": 3, "Lm": { "P": { "Q": 5, "R": 6 }, "nO": 4 }, "gH": 2 } }`}, {"toml", `aBcD = 1 [eF] gH = 2 iJk = 3 [eF.Lm] nO = 4 [eF.Lm.P] Q = 5 R = 6 `}, } { doTestCaseInsensitive(t, config.typ, config.content) } } func TestCaseInsensitiveSet(t *testing.T) { Reset() m1 := map[string]interface{}{ "Foo": 32, "Bar": map[interface{}]interface{}{ "ABc": "A", "cDE": "B", }, } m2 := map[string]interface{}{ "Foo": 52, "Bar": map[interface{}]interface{}{ "bCd": "A", "eFG": "B", }, } Set("Given1", m1) Set("Number1", 42) SetDefault("Given2", m2) SetDefault("Number2", 52) // Verify SetDefault if v := Get("number2"); v != 52 { t.Fatalf("Expected 52 got %q", v) } if v := Get("given2.foo"); v != 52 { t.Fatalf("Expected 52 got %q", v) } if v := Get("given2.bar.bcd"); v != "A" { t.Fatalf("Expected A got %q", v) } if _, ok := m2["Foo"]; !ok { t.Fatal("Input map changed") } // Verify Set if v := Get("number1"); v != 42 { t.Fatalf("Expected 42 got %q", v) } if v := Get("given1.foo"); v != 32 { t.Fatalf("Expected 32 got %q", v) } if v := Get("given1.bar.abc"); v != "A" { t.Fatalf("Expected A got %q", v) } if _, ok := m1["Foo"]; !ok { t.Fatal("Input map changed") } } func TestParseNested(t *testing.T) { type duration struct { Delay time.Duration } type item struct { Name string Delay time.Duration Nested duration } config := `[[parent]] delay="100ms" [parent.nested] delay="200ms" ` initConfig("toml", config) var items []item err := v.UnmarshalKey("parent", &items) if err != nil { t.Fatalf("unable to decode into struct, %v", err) } assert.Equal(t, 1, len(items)) assert.Equal(t, 100*time.Millisecond, items[0].Delay) assert.Equal(t, 200*time.Millisecond, items[0].Nested.Delay) } func doTestCaseInsensitive(t *testing.T, typ, config string) { initConfig(typ, config) Set("RfD", true) assert.Equal(t, true, Get("rfd")) assert.Equal(t, true, Get("rFD")) assert.Equal(t, 1, cast.ToInt(Get("abcd"))) assert.Equal(t, 1, cast.ToInt(Get("Abcd"))) assert.Equal(t, 2, cast.ToInt(Get("ef.gh"))) assert.Equal(t, 3, cast.ToInt(Get("ef.ijk"))) assert.Equal(t, 4, cast.ToInt(Get("ef.lm.no"))) assert.Equal(t, 5, cast.ToInt(Get("ef.lm.p.q"))) } func newViperWithConfigFile(t *testing.T) (*Viper, string, func()) { watchDir, err := ioutil.TempDir("", "") require.Nil(t, err) configFile := path.Join(watchDir, "config.yaml") err = ioutil.WriteFile(configFile, []byte("foo: bar\n"), 0o640) require.Nil(t, err) cleanup := func() { os.RemoveAll(watchDir) } v := New() v.SetConfigFile(configFile) err = v.ReadInConfig() require.Nil(t, err) require.Equal(t, "bar", v.Get("foo")) return v, configFile, cleanup } func newViperWithSymlinkedConfigFile(t *testing.T) (*Viper, string, string, func()) { watchDir, err := ioutil.TempDir("", "") require.Nil(t, err) dataDir1 := path.Join(watchDir, "data1") err = os.Mkdir(dataDir1, 0o777) require.Nil(t, err) realConfigFile := path.Join(dataDir1, "config.yaml") t.Logf("Real config file location: %s\n", realConfigFile) err = ioutil.WriteFile(realConfigFile, []byte("foo: bar\n"), 0o640) require.Nil(t, err) cleanup := func() { os.RemoveAll(watchDir) } // now, symlink the tm `data1` dir to `data` in the baseDir os.Symlink(dataDir1, path.Join(watchDir, "data")) // and link the `/datadir1/config.yaml` to `/config.yaml` configFile := path.Join(watchDir, "config.yaml") os.Symlink(path.Join(watchDir, "data", "config.yaml"), configFile) t.Logf("Config file location: %s\n", path.Join(watchDir, "config.yaml")) // init Viper v := New() v.SetConfigFile(configFile) err = v.ReadInConfig() require.Nil(t, err) require.Equal(t, "bar", v.Get("foo")) return v, watchDir, configFile, cleanup } func TestWatchFile(t *testing.T) { if runtime.GOOS == "linux" { // TODO(bep) FIX ME t.Skip("Skip test on Linux ...") } t.Run("file content changed", func(t *testing.T) { // given a `config.yaml` file being watched v, configFile, cleanup := newViperWithConfigFile(t) defer cleanup() _, err := os.Stat(configFile) require.NoError(t, err) t.Logf("test config file: %s\n", configFile) wg := sync.WaitGroup{} wg.Add(1) var wgDoneOnce sync.Once // OnConfigChange is called twice on Windows v.OnConfigChange(func(in fsnotify.Event) { t.Logf("config file changed") wgDoneOnce.Do(func() { wg.Done() }) }) v.WatchConfig() // when overwriting the file and waiting for the custom change notification handler to be triggered err = ioutil.WriteFile(configFile, []byte("foo: baz\n"), 0o640) wg.Wait() // then the config value should have changed require.Nil(t, err) assert.Equal(t, "baz", v.Get("foo")) }) t.Run("link to real file changed (à la Kubernetes)", func(t *testing.T) { // skip if not executed on Linux if runtime.GOOS != "linux" { t.Skipf("Skipping test as symlink replacements don't work on non-linux environment...") } v, watchDir, _, _ := newViperWithSymlinkedConfigFile(t) // defer cleanup() wg := sync.WaitGroup{} v.WatchConfig() v.OnConfigChange(func(in fsnotify.Event) { t.Logf("config file changed") wg.Done() }) wg.Add(1) // when link to another `config.yaml` file dataDir2 := path.Join(watchDir, "data2") err := os.Mkdir(dataDir2, 0o777) require.Nil(t, err) configFile2 := path.Join(dataDir2, "config.yaml") err = ioutil.WriteFile(configFile2, []byte("foo: baz\n"), 0o640) require.Nil(t, err) // change the symlink using the `ln -sfn` command err = exec.Command("ln", "-sfn", dataDir2, path.Join(watchDir, "data")).Run() require.Nil(t, err) wg.Wait() // then require.Nil(t, err) assert.Equal(t, "baz", v.Get("foo")) }) } func TestUnmarshal_DotSeparatorBackwardCompatibility(t *testing.T) { flags := pflag.NewFlagSet("test", pflag.ContinueOnError) flags.String("foo.bar", "cobra_flag", "") v := New() assert.NoError(t, v.BindPFlags(flags)) config := &struct { Foo struct { Bar string } }{} assert.NoError(t, v.Unmarshal(config)) assert.Equal(t, "cobra_flag", config.Foo.Bar) } var yamlExampleWithDot = []byte(`Hacker: true name: steve hobbies: - skateboarding - snowboarding - go clothing: jacket: leather trousers: denim pants: size: large age: 35 eyes : brown beard: true emails: steve@hacker.com: created: 01/02/03 active: true `) func TestKeyDelimiter(t *testing.T) { v := NewWithOptions(KeyDelimiter("::")) v.SetConfigType("yaml") r := strings.NewReader(string(yamlExampleWithDot)) err := v.unmarshalReader(r, v.config) require.NoError(t, err) values := map[string]interface{}{ "image": map[string]interface{}{ "repository": "someImage", "tag": "1.0.0", }, "ingress": map[string]interface{}{ "annotations": map[string]interface{}{ "traefik.frontend.rule.type": "PathPrefix", "traefik.ingress.kubernetes.io/ssl-redirect": "true", }, }, } v.SetDefault("charts::values", values) assert.Equal(t, "leather", v.GetString("clothing::jacket")) assert.Equal(t, "01/02/03", v.GetString("emails::steve@hacker.com::created")) type config struct { Charts struct { Values map[string]interface{} } } expected := config{ Charts: struct { Values map[string]interface{} }{ Values: values, }, } var actual config assert.NoError(t, v.Unmarshal(&actual)) assert.Equal(t, expected, actual) } var yamlDeepNestedSlices = []byte(`TV: - title: "The expanse" seasons: - first_released: "December 14, 2015" episodes: - title: "Dulcinea" air_date: "December 14, 2015" - title: "The Big Empty" air_date: "December 15, 2015" - title: "Remember the Cant" air_date: "December 22, 2015" - first_released: "February 1, 2017" episodes: - title: "Safe" air_date: "February 1, 2017" - title: "Doors & Corners" air_date: "February 1, 2017" - title: "Static" air_date: "February 8, 2017" episodes: - ["Dulcinea", "The Big Empty", "Remember the Cant"] - ["Safe", "Doors & Corners", "Static"] `) func TestSliceIndexAccess(t *testing.T) { v.SetConfigType("yaml") r := strings.NewReader(string(yamlDeepNestedSlices)) err := v.unmarshalReader(r, v.config) require.NoError(t, err) assert.Equal(t, "The expanse", v.GetString("tv.0.title")) assert.Equal(t, "February 1, 2017", v.GetString("tv.0.seasons.1.first_released")) assert.Equal(t, "Static", v.GetString("tv.0.seasons.1.episodes.2.title")) assert.Equal(t, "December 15, 2015", v.GetString("tv.0.seasons.0.episodes.1.air_date")) // Test for index out of bounds assert.Equal(t, "", v.GetString("tv.0.seasons.2.first_released")) // Accessing multidimensional arrays assert.Equal(t, "Static", v.GetString("tv.0.episodes.1.2")) } func BenchmarkGetBool(b *testing.B) { key := "BenchmarkGetBool" v = New() v.Set(key, true) for i := 0; i < b.N; i++ { if !v.GetBool(key) { b.Fatal("GetBool returned false") } } } func BenchmarkGet(b *testing.B) { key := "BenchmarkGet" v = New() v.Set(key, true) for i := 0; i < b.N; i++ { if !v.Get(key).(bool) { b.Fatal("Get returned false") } } } // BenchmarkGetBoolFromMap is the "perfect result" for the above. func BenchmarkGetBoolFromMap(b *testing.B) { m := make(map[string]bool) key := "BenchmarkGetBool" m[key] = true for i := 0; i < b.N; i++ { if !m[key] { b.Fatal("Map value was false") } } } // Skip some tests on Windows that kept failing when Windows was added to the CI as a target. func skipWindows(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("Skip test on Windows") } } viper-1.10.1/watch.go000066400000000000000000000002731415636445600143740ustar00rootroot00000000000000//go:build !js // +build !js package viper import "github.com/fsnotify/fsnotify" type watcher = fsnotify.Watcher func newWatcher() (*watcher, error) { return fsnotify.NewWatcher() } viper-1.10.1/watch_wasm.go000066400000000000000000000006571415636445600154310ustar00rootroot00000000000000// +build js,wasm package viper import ( "errors" "github.com/fsnotify/fsnotify" ) type watcher struct { Events chan fsnotify.Event Errors chan error } func (*watcher) Close() error { return nil } func (*watcher) Add(name string) error { return nil } func (*watcher) Remove(name string) error { return nil } func newWatcher() (*watcher, error) { return &watcher{}, errors.New("fsnotify is not supported on WASM") }