Skip to content

Commit

Permalink
Add ability to Login to cluster and Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
astoycos committed Mar 19, 2020
1 parent 6ef1f40 commit b78b373
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ An functioning openshift 4.X cluster is required for this CLI's usage
[Download a release](https://github.com/redhat-iot/iot-dev/releases), move the executable to your `$PATH`, and simply run the following command to get started

```
IoTCLI setup --user=<Openshift admin Username> --password=<Openshift admin Password>
IoTCLI setup
```
It will prompt the user for their Openshift cluster credentials

## Setting up IoT Cloud Native Messaging

The user can chose to utilize Enmasse or Kafka for the middleware messaging layer
Expand Down
26 changes: 22 additions & 4 deletions cmd/main-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
"compress/gzip"
"path/filepath"
"log"
//"os/exec"
"os/exec"
"golang.org/x/crypto/ssh/terminal"

)

Expand Down Expand Up @@ -120,9 +121,6 @@ func Untar(dst string, r io.Reader) error {
func setup() {
downloadPkg("oc.tar.gz", ocUrl)
downloadPkg("enmasse.tgz",enmasseUrl)

//Download Jq? For deleteing resources with locked finalizers


ocContent, err := os.Open("oc.tar.gz")
if err != nil {
Expand All @@ -144,6 +142,26 @@ func setup() {

os.Remove("oc.tar.gz")
os.Remove("enmasse.tgz")

//Login to OC
fmt.Print("Enter Openshift Username: ")
var user string
fmt.Scanln(&user)

fmt.Print("Enter Openshift Password: ")
password, err := terminal.ReadPassword(0)
if err != nil{
log.Fatal(err)
}

fmt.Println()

cmd := exec.Command("bash", "-c", "echo " + user + " " + string(password) + "| ./oc login")
cmd.Stdout = os.Stdout
err = cmd.Run()
if(err != nil){
log.Fatal(err)
}
}

// setupCmd represents the setup command
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v0.0.6
github.com/spf13/viper v1.6.2
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
)
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down

0 comments on commit b78b373

Please sign in to comment.