mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Fix oc to odo project translation (#6949)
* Fix oc to odo project translation Signed-off-by: Parthvi <parthvi.vala@gmail.com> * Attempt at fixing regression Signed-off-by: Parthvi <parthvi.vala@gmail.com> * Add unit test for filteredInformation Signed-off-by: Parthvi <parthvi.vala@gmail.com> * Use oc command instead of odo Signed-off-by: Parthvi <parthvi.vala@gmail.com> Co-authored-by: Armel Soro <asoro@redhat.com> --------- Signed-off-by: Parthvi <parthvi.vala@gmail.com> Co-authored-by: Parthvi Vala <pvala@localhost.localdomain> Co-authored-by: Armel Soro <asoro@redhat.com>
This commit is contained in:
@@ -35,7 +35,7 @@ func (o KubernetesClient) Login(server, username, password, token, caAuth string
|
||||
|
||||
a := login.LoginOptions{
|
||||
Server: server,
|
||||
CommandName: "odo",
|
||||
CommandName: "oc",
|
||||
CAFile: caAuth,
|
||||
InsecureTLS: skipTLS,
|
||||
Username: username,
|
||||
@@ -143,9 +143,8 @@ func filteredInformation(s []byte) []byte {
|
||||
|
||||
// List of strings to correctly filter
|
||||
s = bytes.Replace(s, []byte("oc new-project"), []byte("odo create project"), -1)
|
||||
s = bytes.Replace(s, []byte("<projectname>"), []byte("<project-name>"), -1)
|
||||
s = bytes.Replace(s, []byte("project <project-name>"), []byte("project set <project-name>"), -1)
|
||||
s = bytes.Replace(s, []byte("odo projects"), []byte("odo list project"), -1)
|
||||
s = bytes.Replace(s, []byte("oc project "), []byte("odo set project "), -1)
|
||||
s = bytes.Replace(s, []byte("oc projects"), []byte("odo list project"), -1)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
78
pkg/auth/login_test.go
Normal file
78
pkg/auth/login_test.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_filteredInformation(t *testing.T) {
|
||||
type args struct {
|
||||
s []byte
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []byte
|
||||
}{
|
||||
{
|
||||
name: "login with no projects",
|
||||
args: args{
|
||||
s: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
|
||||
|
||||
You don't have any projects. You can try to create a new project, by running
|
||||
|
||||
oc new-project <projectname>`),
|
||||
},
|
||||
want: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
|
||||
|
||||
You don't have any projects. You can try to create a new project, by running
|
||||
|
||||
odo create project <projectname>`),
|
||||
},
|
||||
{
|
||||
name: "login with only 1 project",
|
||||
args: args{
|
||||
s: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
|
||||
|
||||
You have one project on this server: "test1"
|
||||
|
||||
Using project "test1".`),
|
||||
},
|
||||
want: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
|
||||
|
||||
You have one project on this server: "test1"
|
||||
|
||||
Using project "test1".`),
|
||||
},
|
||||
{
|
||||
name: "login with more than one project",
|
||||
args: args{
|
||||
s: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
|
||||
|
||||
You have access to the following projects and can switch between them with 'oc project <projectname>':
|
||||
|
||||
test1
|
||||
test2
|
||||
* test3
|
||||
|
||||
Using project "test3".`),
|
||||
},
|
||||
want: []byte(`Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
|
||||
|
||||
You have access to the following projects and can switch between them with 'odo set project <projectname>':
|
||||
|
||||
test1
|
||||
test2
|
||||
* test3
|
||||
|
||||
Using project "test3".`),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := filteredInformation(tt.args.s); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("filteredInformation() = %v\nwant = %v", string(got), string(tt.want))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user