Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 5b7377e

Browse files
authored
Merge pull request #1848 from thedadams/hub-to-manager
Rename hub to manager
2 parents 9deaad1 + 4c11425 commit 5b7377e

File tree

23 files changed

+100
-105
lines changed

23 files changed

+100
-105
lines changed

integration/projectconfig/projectconfig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func TestCLIConfig(t *testing.T) {
146146
wantNamespace: "something",
147147
},
148148
{
149-
name: "User set hub reference",
149+
name: "User set manager reference",
150150
opt: project.Options{
151151
Project: "example.com/foo/bar",
152152
CLIConfig: &config.CLIConfig{

pkg/cli/completion_test.go

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
)
1919

2020
func TestAppsThenContainersCompletion(t *testing.T) {
21-
appNames := []string{"test-1", "acorn-1", "acorn-2", "hub", "test-2"}
22-
containerNames := []string{"test-1.container-1", "acorn-1.container-1", "acorn-2.container-1", "hub.container", "hub.other-container", "test-2.container-1"}
21+
appNames := []string{"test-1", "acorn-1", "acorn-2", "manager", "test-2"}
22+
containerNames := []string{"test-1.container-1", "acorn-1.container-1", "acorn-2.container-1", "manager.container", "manager.other-container", "test-2.container-1"}
2323
apps := make([]apiv1.App, 0, len(appNames))
2424
for _, name := range appNames {
2525
apps = append(apps, apiv1.App{ObjectMeta: metav1.ObjectMeta{Name: name}})
@@ -68,9 +68,9 @@ func TestAppsThenContainersCompletion(t *testing.T) {
6868
wantDirective: cobra.ShellCompDirectiveNoFileComp,
6969
},
7070
{
71-
name: "Complete hub, only hub returned",
72-
toComplete: "hub",
73-
wantNames: []string{"hub"},
71+
name: "Complete manager, only manager returned",
72+
toComplete: "manager",
73+
wantNames: []string{"manager"},
7474
wantDirective: cobra.ShellCompDirectiveNoFileComp,
7575
},
7676
{
@@ -80,27 +80,27 @@ func TestAppsThenContainersCompletion(t *testing.T) {
8080
wantDirective: cobra.ShellCompDirectiveNoFileComp,
8181
},
8282
{
83-
name: "Complete starting with hub.",
84-
toComplete: "hub.",
85-
wantNames: []string{"hub.container", "hub.other-container"},
83+
name: "Complete starting with manager.",
84+
toComplete: "manager.",
85+
wantNames: []string{"manager.container", "manager.other-container"},
8686
wantDirective: cobra.ShellCompDirectiveNoFileComp,
8787
},
8888
{
89-
name: "Complete starting with hub.c",
90-
toComplete: "hub.c",
91-
wantNames: []string{"hub.container"},
89+
name: "Complete starting with manager.c",
90+
toComplete: "manager.c",
91+
wantNames: []string{"manager.container"},
9292
wantDirective: cobra.ShellCompDirectiveNoFileComp,
9393
},
9494
{
95-
name: "Complete hub.container, only hub.container returned",
96-
toComplete: "hub.container",
97-
wantNames: []string{"hub.container"},
95+
name: "Complete manager.container, only manager.container returned",
96+
toComplete: "manager.container",
97+
wantNames: []string{"manager.container"},
9898
wantDirective: cobra.ShellCompDirectiveNoFileComp,
9999
},
100100
{
101-
name: "Complete hub.c, but hub.container already in args",
102-
args: []string{"hub.container"},
103-
toComplete: "hub.c",
101+
name: "Complete manager.c, but manager.container already in args",
102+
args: []string{"manager.container"},
103+
toComplete: "manager.c",
104104
wantNames: []string{},
105105
wantDirective: cobra.ShellCompDirectiveNoFileComp,
106106
},
@@ -129,7 +129,7 @@ func TestAppsThenContainersCompletion(t *testing.T) {
129129
}
130130

131131
func TestAppsCompletion(t *testing.T) {
132-
names := []string{"test-1", "acorn-1", "acorn-2", "hub", "test-2"}
132+
names := []string{"test-1", "acorn-1", "acorn-2", "manager", "test-2"}
133133
apps := make([]apiv1.App, 0, len(names))
134134
for _, name := range names {
135135
apps = append(apps, apiv1.App{ObjectMeta: metav1.ObjectMeta{Name: name}})
@@ -173,9 +173,9 @@ func TestAppsCompletion(t *testing.T) {
173173
wantDirective: cobra.ShellCompDirectiveNoFileComp,
174174
},
175175
{
176-
name: "Complete hub, only hub returned",
177-
toComplete: "hub",
178-
wantNames: []string{"hub"},
176+
name: "Complete manager, only manager returned",
177+
toComplete: "manager",
178+
wantNames: []string{"manager"},
179179
wantDirective: cobra.ShellCompDirectiveNoFileComp,
180180
},
181181
{
@@ -203,7 +203,7 @@ func TestAppsCompletion(t *testing.T) {
203203
}
204204

205205
func TestContainersCompletion(t *testing.T) {
206-
names := []string{"test-1.container-1", "acorn-1.container-1", "acorn-2.container-1", "hub.container", "hub.other-container", "test-2.container-1"}
206+
names := []string{"test-1.container-1", "acorn-1.container-1", "acorn-2.container-1", "manager.container", "manager.other-container", "test-2.container-1"}
207207
containers := make([]apiv1.ContainerReplica, 0, len(names))
208208
for _, name := range names {
209209
containers = append(containers, apiv1.ContainerReplica{ObjectMeta: metav1.ObjectMeta{Name: name}, Spec: apiv1.ContainerReplicaSpec{AppName: strings.Split(name, ".")[0]}})
@@ -246,21 +246,21 @@ func TestContainersCompletion(t *testing.T) {
246246
wantDirective: cobra.ShellCompDirectiveNoFileComp,
247247
},
248248
{
249-
name: "Complete starting with hub.",
250-
toComplete: "hub.",
251-
wantNames: []string{"hub.container", "hub.other-container"},
249+
name: "Complete starting with manager.",
250+
toComplete: "manager.",
251+
wantNames: []string{"manager.container", "manager.other-container"},
252252
wantDirective: cobra.ShellCompDirectiveNoFileComp,
253253
},
254254
{
255-
name: "Complete starting with hub.c",
256-
toComplete: "hub.c",
257-
wantNames: []string{"hub.container"},
255+
name: "Complete starting with manager.c",
256+
toComplete: "manager.c",
257+
wantNames: []string{"manager.container"},
258258
wantDirective: cobra.ShellCompDirectiveNoFileComp,
259259
},
260260
{
261-
name: "Complete hub.container, only hub.container returned",
262-
toComplete: "hub.container",
263-
wantNames: []string{"hub.container"},
261+
name: "Complete manager.container, only manager.container returned",
262+
toComplete: "manager.container",
263+
wantNames: []string{"manager.container"},
264264
wantDirective: cobra.ShellCompDirectiveNoFileComp,
265265
},
266266
{
@@ -423,7 +423,7 @@ func TestAcornContainerCompletion(t *testing.T) {
423423
"test-2": {
424424
"container-1": {},
425425
},
426-
"hub": {
426+
"manager": {
427427
"web": {},
428428
"db": {},
429429
"controller": {},
@@ -488,7 +488,7 @@ func TestOnlyAppsWithAcornContainer(t *testing.T) {
488488
"test-2": {
489489
"container-1": {},
490490
},
491-
"hub": {
491+
"manager": {
492492
"web": {},
493493
"db": {},
494494
"controller": {},
@@ -528,12 +528,12 @@ func TestOnlyAppsWithAcornContainer(t *testing.T) {
528528
}{
529529
{
530530
name: "Nothing to complete and no container, return apps",
531-
wantNames: []string{"hub", "test-1", "test-2"},
531+
wantNames: []string{"manager", "test-1", "test-2"},
532532
wantDirective: cobra.ShellCompDirectiveNoFileComp,
533533
},
534534
{
535535
name: "Nothing to complete and no container, return apps except those in args",
536-
args: []string{"hub", "test-2"},
536+
args: []string{"manager", "test-2"},
537537
wantNames: []string{"test-1"},
538538
wantDirective: cobra.ShellCompDirectiveNoFileComp,
539539
},
@@ -545,15 +545,15 @@ func TestOnlyAppsWithAcornContainer(t *testing.T) {
545545
},
546546
{
547547
name: "Something with '.' to complete and no container should be the k8s container completion",
548-
toComplete: "hub.",
549-
wantNames: []string{"hub.controller", "hub.db", "hub.web"},
548+
toComplete: "manager.",
549+
wantNames: []string{"manager.controller", "manager.db", "manager.web"},
550550
wantDirective: cobra.ShellCompDirectiveNoFileComp,
551551
},
552552
{
553553
name: "Something with '.' to complete and no container should be the k8s container completion except those in args",
554-
toComplete: "hub.",
555-
args: []string{"hub.db"},
556-
wantNames: []string{"hub.controller", "hub.web"},
554+
toComplete: "manager.",
555+
args: []string{"manager.db"},
556+
wantNames: []string{"manager.controller", "manager.web"},
557557
wantDirective: cobra.ShellCompDirectiveNoFileComp,
558558
},
559559
{

pkg/cli/credential_login.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/acorn-io/runtime/pkg/client"
1313
"github.com/acorn-io/runtime/pkg/config"
1414
"github.com/acorn-io/runtime/pkg/credentials"
15-
"github.com/acorn-io/runtime/pkg/hub"
15+
"github.com/acorn-io/runtime/pkg/manager"
1616
"github.com/pterm/pterm"
1717
"github.com/spf13/cobra"
1818
)
@@ -54,8 +54,8 @@ func (a *CredentialLogin) Run(cmd *cobra.Command, args []string) error {
5454

5555
var serverAddress string
5656
if len(args) == 0 && a.Password != "" {
57-
// HubServer slice length is guaranteed to be >=1 by the ReadCLIConfig method
58-
serverAddress = cfg.HubServers[0]
57+
// ManagerServer slice length is guaranteed to be >=1 by the ReadCLIConfig method
58+
serverAddress = cfg.AcornServers[0]
5959
} else if len(args) > 0 {
6060
serverAddress = args[0]
6161
}
@@ -92,13 +92,13 @@ func (a *CredentialLogin) Run(cmd *cobra.Command, args []string) error {
9292
})
9393
}
9494

95-
isHub, err := hub.IsHub(cfg, serverAddress)
95+
isManager, err := manager.IsManager(cfg, serverAddress)
9696
if err != nil {
9797
return err
9898
}
9999

100-
if isHub {
101-
user, pass, err := hub.Login(cmd.Context(), a.Password, serverAddress)
100+
if isManager {
101+
user, pass, err := manager.Login(cmd.Context(), a.Password, serverAddress)
102102
if err != nil {
103103
return err
104104
}
@@ -134,15 +134,15 @@ func (a *CredentialLogin) Run(cmd *cobra.Command, args []string) error {
134134
return err
135135
}
136136

137-
if isHub {
137+
if isManager {
138138
// reload config, could have changed
139139
cfg, err = config.ReadCLIConfig()
140140
if err != nil {
141141
return err
142142
}
143143

144144
var projectSet bool
145-
def, err := hub.DefaultProject(cmd.Context(), serverAddress, a.Username, a.Password)
145+
def, err := manager.DefaultProject(cmd.Context(), serverAddress, a.Username, a.Password)
146146
if err != nil {
147147
return err
148148
}

pkg/cli/credential_logout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func (a *CredentialLogout) Run(cmd *cobra.Command, args []string) error {
4141
}
4242

4343
var client client.Client
44-
if slices.Contains(cfg.HubServers, args[0]) {
45-
// force local storage for known hub addresses
44+
if slices.Contains(cfg.AcornServers, args[0]) {
45+
// force local storage for known manager addresses
4646
a.LocalStorage = true
4747
}
4848

pkg/cli/testdata/info/info_test-a.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
client:
33
cli:
4-
hubServers:
4+
acornServers:
55
- acorn.io
66
version:
77
tag: v0.0.0-dev

pkg/cli/testdata/info/info_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
client:
33
cli:
4-
hubServers:
4+
acornServers:
55
- acorn.io
66
version:
77
tag: v0.0.0-dev

pkg/cli/testdata/info/info_test_empty.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
client:
33
cli:
4-
hubServers:
4+
acornServers:
55
- acorn.io
66
version:
77
tag: v0.0.0-dev

pkg/cli/testdata/info/info_test_json.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"tag": "v0.0.0-dev"
55
},
66
"cli": {
7-
"hubServers": [
7+
"acornServers": [
88
"acorn.io"
99
]
1010
}

pkg/cli/testdata/info/info_test_yaml.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
client:
33
cli:
4-
5-
hubServers:
4+
acornServers:
65
- acorn.io
76
version:
87
tag: v0.0.0-dev

pkg/config/cliconfig.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type CLIConfig struct {
4747
Auths map[string]AuthConfig `json:"auths,omitempty"`
4848
CredentialsStore string `json:"credsStore,omitempty"`
4949
CredentialHelpers map[string]string `json:"credHelpers,omitempty"`
50-
HubServers []string `json:"hubServers,omitempty"`
50+
AcornServers []string `json:"acornServers,omitempty"`
5151
Kubeconfigs map[string]string `json:"-"`
5252
ProjectAliases map[string]string `json:"projectAliases,omitempty"`
5353
CurrentProject string `json:"currentProject,omitempty"`
@@ -136,8 +136,8 @@ func ReadCLIConfig() (*CLIConfig, error) {
136136

137137
result.filename = filename
138138

139-
if len(result.HubServers) == 0 {
140-
result.HubServers = []string{system.DefaultHubAddress}
139+
if len(result.AcornServers) == 0 {
140+
result.AcornServers = []string{system.DefaultHubAddress}
141141
}
142142

143143
result.Kubeconfigs = map[string]string{}
@@ -201,15 +201,15 @@ func RemoveServer(cfg *CLIConfig, serverAddress string) error {
201201
modified = true
202202
}
203203

204-
var newHubServers []string
205-
for _, server := range cfg.HubServers {
204+
var newAcornServer []string
205+
for _, server := range cfg.AcornServers {
206206
if server != serverAddress {
207-
newHubServers = append(newHubServers, server)
207+
newAcornServer = append(newAcornServer, server)
208208
}
209209
}
210210

211-
if len(newHubServers) != len(cfg.HubServers) {
212-
cfg.HubServers = newHubServers
211+
if len(newAcornServer) != len(cfg.AcornServers) {
212+
cfg.AcornServers = newAcornServer
213213
modified = true
214214
}
215215

0 commit comments

Comments
 (0)