Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

fix hyperkube to run from goland. #1984

Merged
merged 2 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/service-catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package main
import (
"os"

"github.com/kubernetes-incubator/service-catalog/cmd/service-catalog/server"
"github.com/kubernetes-incubator/service-catalog/pkg/hyperkube"
)

Expand All @@ -31,8 +32,8 @@ func main() {
Long: "This is an all-in-one binary that can run any of the various Kubernetes service-catalog servers.",
}

hk.AddServer(NewAPIServer())
hk.AddServer(NewControllerManager())
hk.AddServer(server.NewAPIServer())
hk.AddServer(server.NewControllerManager())

hk.RunToExit(os.Args)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package main
package server

import (
"github.com/kubernetes-incubator/service-catalog/cmd/apiserver/app/server"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package main
package server

import (
"github.com/kubernetes-incubator/service-catalog/cmd/controller-manager/app"
Expand Down
4 changes: 4 additions & 0 deletions pkg/hyperkube/hyperkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (hk *HyperKube) Printf(format string, i ...interface{}) {
func (hk *HyperKube) Run(args []string, stopCh <-chan struct{}) error {
// If we are called directly, parse all flags up to the first real
// argument. That should be the server to run.
RunAgain:
command := args[0]
serverName := path.Base(command)
args = args[1:]
Expand Down Expand Up @@ -164,6 +165,9 @@ func (hk *HyperKube) Run(args []string, stopCh <-chan struct{}) error {

s, err := hk.FindServer(serverName)
if err != nil {
if len(args) > 0 {
goto RunAgain // the first args was popped off at start of Run, try again with new args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How/Why does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you read the helpful comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have to pop off args at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was how this code worked. I, clearly, did not write that part.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the existing code popped off the first item in the array because it represents the entrypoint (e.g. main.go or the name of the binary) and isn't really one of the arguments for the command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I get it, we're looking for apiserver or controller-manager specifically here. Seems like there's something weird still.

thanks @carolynvs

}
hk.Printf("Error: %v\n\n", err)
hk.Usage()
return err
Expand Down