Commit bc723207 authored by Addshore's avatar Addshore 🏄
Browse files

Merge branch 'main' into addshore-github-dev

parents 3bbc5391 f9c8b2f8
......@@ -6,3 +6,6 @@
/_release
/vendor
internal/mwdd/files/files.go
coverage.txt
coverage.html
coverage.xml
......@@ -65,9 +65,14 @@ test:
needs: []
cache: {}
image: docker-registry.wikimedia.org/golang:1.13-3
artifacts:
reports:
cobertura: coverage.xml
script:
- go get -u golang.org/x/lint/golint
- make test
- go get github.com/boumenot/gocover-cobertura
- gocover-cobertura < coverage.txt > coverage.xml
integration:
stage: integration
......
......@@ -4,6 +4,14 @@
...
## [v0.1.0-dev-addshore.20210916.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210916.1)
* `mw dev hosts`: command added to interact with your `/etc/hosts` file if needed
* `mw dev * exec`: commands can now have environment variables passed to them. e.g. `mw dev mediawiki exec -- FOO=bar env`
* `mw dev`: ports are now checked for availibility before listening begins
* `mw dev adminer`: Updated from `adminer:4.8.0` to `adminer:4` (enabling minor update)
* Fix typos
## [v0.1.0-dev-addshore.20210910.1](https://github.com/addshore/mwcli/releases/tag/v0.1.0-dev-addshore.20210910.1)
* `mw dev mediawiki phpunit`: Command has been removed, please use `mw dev mediawiki exec`
......
......@@ -54,7 +54,7 @@ clean:
test: get-dev generate unit lint
unit:
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -cover -ldflags "$(shell ./bin/govvv -flags)" $(GO_PACKAGES)
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -covermode=count -coverprofile "coverage.txt" -ldflags "$(shell ./bin/govvv -flags)" $(GO_PACKAGES)
lint:
@echo > .lint-gofmt.diff
......
......@@ -18,13 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package cmd
import (
"errors"
"fmt"
"os"
"strconv"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/exec"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/mwdd"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/util/ports"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
)
......@@ -38,18 +37,9 @@ var mwddCmd = &cobra.Command{
mwdd.EnsureReady()
if mwdd.Env().Missing("PORT") {
prompt := promptui.Prompt{
Label: "What port would you like to use for your development environment?",
// TODO suggest a port that is definitely available for listening on
Default: "8080",
Validate: func(input string) error {
// TODO check the port can be listened on?
// https://coolaj86.com/articles/how-to-test-if-a-port-is-available-in-go/
_, err := strconv.ParseFloat(input, 64)
if err != nil {
return errors.New("Invalid number")
}
return nil
},
Label: "What port would you like to use for your development environment?",
Default: ports.FreeUpFrom("8080"),
Validate: ports.IsValidAndFree,
}
value, err := prompt.Run()
if err == nil {
......
/*Package cmd is used for command line.
Copyright © 2020 Addshore
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd
import (
"fmt"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/mwdd"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/util/hosts"
"github.com/spf13/cobra"
)
var mwddHostsCmd = &cobra.Command{
Use: "hosts",
Short: "Interact with your system hosts file",
RunE: nil,
}
var mwddHostsAddCmd = &cobra.Command{
Use: "add",
Short: "Adds development environment hosts into your system hosts file (might need sudo)",
Run: func(cmd *cobra.Command, args []string) {
save := hosts.AddHosts(
append(
[]string{
// TODO generate these by reading the yml files?
"proxy.mwdd.localhost",
"adminer.mwdd.localhost",
"graphite.mwdd.localhost",
"phpmyadmin.mwdd.localhost",
"default.mediawiki.mwdd.localhost",
},
mwdd.DefaultForUser().UsedHosts()...,
),
)
if save.Success {
fmt.Println("Hosts file updated!")
} else {
fmt.Println("Could not save your hosts file.")
fmt.Println("You can return with sudo.")
fmt.Println("Or edit the hosts fiel yourself.")
fmt.Println("Temporary file: " + save.TmpFile)
fmt.Println("")
fmt.Println(save.Content)
}
},
}
var mwddHostsRemoveCmd = &cobra.Command{
Use: "remove",
Short: "Removes development environment hosts from your system hosts file (might need sudo)",
Run: func(cmd *cobra.Command, args []string) {
save := hosts.RemoveHostsWithSuffix("mwdd.localhost")
if save.Success {
fmt.Println("Hosts file updated!")
} else {
fmt.Println("Could not save your hosts file.")
fmt.Println("You can return with sudo.")
fmt.Println("Or edit the hosts fiel yourself.")
fmt.Println("Temporary file: " + save.TmpFile)
fmt.Println("")
fmt.Println(save.Content)
}
},
}
func init() {
mwddCmd.AddCommand(mwddHostsCmd)
mwddHostsCmd.AddCommand(mwddHostsAddCmd)
mwddHostsCmd.AddCommand(mwddHostsRemoveCmd)
}
......@@ -277,6 +277,10 @@ var mwddMediawikiInstallCmd = &cobra.Command{
mwdd.DefaultForUser().Exec("mediawiki", []string{"chown", "-R", "nobody", "/var/www/html/w/data"}, exec.HandlerOptions{}, "root")
mwdd.DefaultForUser().Exec("mediawiki", []string{"chown", "-R", "nobody", "/var/log/mediawiki"}, exec.HandlerOptions{}, "root")
// Record the wiki domain that we are trying to create
var domain string = DbName + ".mediawiki.mwdd.localhost"
mwdd.DefaultForUser().RecordHostUsageBySite(domain)
// Copy current local settings "somewhere safe", incase someone needs to restore it
currentTime := time.Now()
currentTimeString := currentTime.Format("20060102150405")
......@@ -293,7 +297,7 @@ var mwddMediawikiInstallCmd = &cobra.Command{
"/var/www/html/w/LocalSettings.php.mwdd.tmp",
}, exec.HandlerOptions{}, "root")
var serverLink string = "http://" + DbName + ".mediawiki.mwdd.localhost:" + mwdd.DefaultForUser().Env().Get("PORT")
var serverLink string = "http://" + domain + ":" + mwdd.DefaultForUser().Env().Get("PORT")
const adminUser string = "admin"
const adminPass string = "mwddpassword"
......@@ -359,15 +363,18 @@ var mwddMediawikiInstallCmd = &cobra.Command{
fmt.Println("")
fmt.Println("***************************************")
fmt.Println("Installation successfull 🎉")
fmt.Println("Installation successful 🎉")
fmt.Println("User: " + adminUser)
fmt.Println("Pass: " + adminPass)
fmt.Println("Link: " + serverLink)
fmt.Println("")
fmt.Println("If you want to access the wiki from your command line you may need to add it to your hosts file.")
fmt.Println("You can do this with the `hosts add` command that is part of this development environment.")
fmt.Println("***************************************")
// TODO remove once https://phabricator.wikimedia.org/T287654 is solved
if DbType == "sqlite" {
fmt.Println("WARNING: The sqlite development environemtn currently suffers an issue, https://phabricator.wikimedia.org/T287654")
fmt.Println("WARNING: The sqlite development environment currently suffers an issue, https://phabricator.wikimedia.org/T287654")
}
},
}
......@@ -396,8 +403,6 @@ var mwddMediawikiCreateCmd = &cobra.Command{
}
// TODO mediawiki should come from some default definition set?
mwdd.DefaultForUser().UpDetached([]string{"mediawiki", "mediawiki-web"}, options)
// TODO add functionality for writing to the hosts file...
//mwdd.DefaultForUser().EnsureHostsFile()
},
}
......@@ -443,7 +448,8 @@ var mwddMediawikiExecCmd = &cobra.Command{
Example: ` exec bash # Run bash as your system user
exec --user root -- bash # Run bash as root
exec -- composer phpunit:unit # Run a composer command (php unit tests)
exec -- composer composer phpunit tests/phpunit/unit/includes/XmlTest.php # Run a single test
exec -- composer phpunit tests/phpunit/unit/includes/XmlTest.php # Run a single test
exec -- MW_DB=other composer phpunit tests/phpunit/unit/includes/XmlTest.php # Run a single test for another database
exec -- php maintenance/update.php --quick # Run a MediaWiki maintenance script`,
Short: "Executes a command in the MediaWiki container",
Run: func(cmd *cobra.Command, args []string) {
......
/*Package cmd is used for command line.
Copyright © 2020 Addshore
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"os"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/config"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/updater"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
)
var updateCmd = &cobra.Command{
Use: "update",
Short: "Checks for and performs updates",
Run: func(cmd *cobra.Command, args []string) {
c := config.LoadFromDisk()
fmt.Println("You are on the " + c.UpdateChannel + " channel.")
canUpdate, toUpdateToOrMessage := updater.CanUpdate(Version, GitSummary, Verbosity >= 2)
if !canUpdate {
fmt.Println(toUpdateToOrMessage)
os.Exit(0)
}
fmt.Println("New update found: " + toUpdateToOrMessage)
updatePrompt := promptui.Prompt{
Label: " Do you want to update?",
IsConfirm: true,
}
_, err := updatePrompt.Run()
if err == nil {
// Note: technically there is a small race condition here, and we might update to a newer version if it was release between stages
updateSuccess, updateMessage := updater.Update(Version, GitSummary, Verbosity >= 2)
fmt.Println(updateMessage)
if !updateSuccess {
os.Exit(1)
}
}
},
}
func init() {
rootCmd.AddCommand(updateCmd)
updateCmd.PersistentFlags().IntVarP(&Verbosity, "verbosity", "v", 1, "verbosity level (1-2)")
}
......@@ -18,17 +18,13 @@ package cmd
import (
"fmt"
"os"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/config"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/updater"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "Output the version infomation",
Short: "Output the version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf(`GitCommit: %s
GitBranch: %s
......@@ -40,41 +36,6 @@ Version: %s
},
}
var updateCmd = &cobra.Command{
Use: "update",
Short: "Checks for and performs updates",
Run: func(cmd *cobra.Command, args []string) {
c := config.LoadFromDisk()
fmt.Println("You are on the " + c.UpdateChannel + " channel.")
canUpdate, toUpdateToOrMessage := updater.CanUpdate(Version, GitSummary, Verbosity >= 2)
if !canUpdate {
fmt.Println(toUpdateToOrMessage)
os.Exit(0)
}
fmt.Println("New update found: " + toUpdateToOrMessage)
updatePrompt := promptui.Prompt{
Label: " Do you want to update?",
IsConfirm: true,
}
_, err := updatePrompt.Run()
if err == nil {
// Note: technically there is a small race condition here, and we might update to a newer version if it was release between stages
updateSuccess, updateMessage := updater.Update(Version, GitSummary, Verbosity >= 2)
fmt.Println(updateMessage)
if !updateSuccess {
os.Exit(1)
}
}
},
}
func init() {
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(updateCmd)
updateCmd.PersistentFlags().IntVarP(&Verbosity, "verbosity", "v", 1, "verbosity level (1-2)")
}
......@@ -4,6 +4,9 @@ require (
bou.ke/staticfiles v0.0.0-20210106104248-dd04075d4104
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/ahmetb/govvv v0.3.0
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
github.com/alecthomas/colour v0.1.0 // indirect
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 // indirect
github.com/blang/semver v3.5.1+incompatible
github.com/briandowns/spinner v1.11.1
github.com/containerd/containerd v1.4.4 // indirect
......@@ -14,14 +17,17 @@ require (
github.com/gorilla/mux v1.8.0 // indirect
github.com/joho/godotenv v1.3.0
github.com/manifoldco/promptui v0.7.0
github.com/mitchellh/gox v1.0.1 // indirect
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1 // indirect
github.com/txn2/txeh v1.3.0
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect
gotest.tools/v3 v3.0.3 // indirect
)
......
......@@ -9,6 +9,12 @@ github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpz
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ahmetb/govvv v0.3.0 h1:YGLGwEyiUwHFy5eh/RUhdupbuaCGBYn5T5GWXp+WJB0=
github.com/ahmetb/govvv v0.3.0/go.mod h1:4WRFpdWtc/YtKgPFwa1dr5+9hiRY5uKAL08bOlxOR6s=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
......@@ -30,12 +36,15 @@ github.com/containerd/containerd v1.4.4 h1:rtRG4N6Ct7GNssATwgpvMGfnjnwfjnu/Zs9W3
github.com/containerd/containerd v1.4.4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
......@@ -44,7 +53,6 @@ github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BU
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v20.10.6+incompatible h1:oXI3Vas8TI8Eu/EjH4srKHJBVqraSzJybhxY7Om9faQ=
github.com/docker/docker v20.10.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.8+incompatible h1:RVqD337BgQicVCzYrrlhLDWhq6OAD2PJDUg2LsEUvKM=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
......@@ -85,8 +93,6 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
......@@ -123,10 +129,6 @@ github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4=
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk=
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc=
......@@ -162,7 +164,10 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/rhysd/go-github-selfupdate v1.2.3 h1:iaa+J202f+Nc+A8zi75uccC8Wg3omaM7HDeimXA22Ag=
github.com/rhysd/go-github-selfupdate v1.2.3/go.mod h1:mp/N8zj6jFfBQy/XMYoWsmfzxazpPAODuqarmPDe2Rg=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
......@@ -172,19 +177,29 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw=
github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/txn2/txeh v1.3.0 h1:vnbv63htVMZCaQgLqVBxKvj2+HHHFUzNW7I183zjg3E=
github.com/txn2/txeh v1.3.0/go.mod h1:O7M6gUTPeMF+vsa4c4Ipx3JDkOYrruB1Wry8QRsMcw8=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
......@@ -194,6 +209,7 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
......@@ -209,6 +225,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288 h1:JIqe8uIcRBHXDQVvZtHwp80ai3Lw3IJAeJEs55Dc1W0=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
......@@ -222,6 +240,7 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/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-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/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 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
......@@ -256,6 +275,8 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
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/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
......@@ -265,6 +286,10 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
......
......@@ -20,7 +20,7 @@ package cmd
import (
"fmt"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/env"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/util/dotenv"
"github.com/spf13/cobra"
)
......@@ -43,7 +43,7 @@ func EnvDelete(directory func() string) *cobra.Command {
Short: "Deletes an environment variable",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
env.DotFileForDirectory(directory()).Delete(args[0])
dotenv.FileForDirectory(directory()).Delete(args[0])
},
}
}
......@@ -55,7 +55,7 @@ func EnvSet(directory func() string) *cobra.Command {
Short: "Set an environment variable",
Args: cobra.MinimumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {
env.DotFileForDirectory(directory()).Set(args[0], args[1])
dotenv.FileForDirectory(directory()).Set(args[0], args[1])
},
}
}
......@@ -67,7 +67,7 @@ func EnvGet(directory func() string) *cobra.Command {
Short: "Get an environment variable",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(env.DotFileForDirectory(directory()).Get(args[0]))
fmt.Println(dotenv.FileForDirectory(directory()).Get(args[0]))
},
}
}
......@@ -78,7 +78,7 @@ func EnvList(directory func() string) *cobra.Command {
Use: "list",
Short: "List all environment variables",
Run: func(cmd *cobra.Command, args []string) {
for name, value := range env.DotFileForDirectory(directory()).List() {
for name, value := range dotenv.FileForDirectory(directory()).List() {
fmt.Println(name + "=" + value)
}
},
......@@ -91,7 +91,7 @@ func EnvWhere(directory func() string) *cobra.Command {
Use: "where",
Short: "Output the location of the .env file",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(env.DotFileForDirectory(directory()).Path())
fmt.Println(dotenv.FileForDirectory(directory()).Path())
},
}
}
/*Package docker is used to interact with docker development environment services
Copyright © 2020 Addshore
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package docker
import (
"os"
osexec "os/exec"
"path/filepath"
"gerrit.wikimedia.org/r/mediawiki/tools/cli/internal/exec"
)
/*ComposeCommand ...*/
func ComposeCommand(command string, arg ...string) *osexec.Cmd {
projectDir, _ := os.Getwd()
context := exec.ComposeCommandContext{
ProjectDirectory: projectDir,
ProjectName: "mw-" + filepath.Base(projectDir),