예제 #1
0
파일: common_test.go 프로젝트: haj/kompose
func GetClient(c *C) client.APIClient {
	client, err := lclient.Create(lclient.Options{})

	c.Assert(err, IsNil)

	return client
}
예제 #2
0
// NewDefaultClientFactory creates and returns the default client factory that uses
// github.com/docker/engine-api client.
func NewDefaultClientFactory(opts composeclient.Options) (ClientFactory, error) {
	client, err := composeclient.Create(opts)
	if err != nil {
		return nil, err
	}

	return &defaultClientFactory{
		client: client,
	}, nil
}
예제 #3
0
func NewClientFactory(opts composeClient.Options) (project.ClientFactory, error) {
	userOpts := opts
	systemOpts := opts

	userOpts.Host = config.DOCKER_HOST
	systemOpts.Host = config.DOCKER_SYSTEM_HOST

	userClient, err := composeClient.Create(userOpts)
	if err != nil {
		return nil, err
	}

	systemClient, err := composeClient.Create(systemOpts)
	if err != nil {
		return nil, err
	}

	return &ClientFactory{
		userClient:   userClient,
		systemClient: systemClient,
	}, nil
}
예제 #4
0
파일: main.go 프로젝트: coderjoe/os
func getPid(service string, project *project.Project) (int, error) {
	s, err := project.CreateService(service)
	if err != nil {
		return 0, err
	}

	containers, err := s.Containers(context.Background())
	if err != nil {
		return 0, err
	}

	if len(containers) == 0 {
		return 0, nil
	}

	client, err := composeClient.Create(composeClient.Options{
		Host: config.DOCKER_SYSTEM_HOST,
	})
	if err != nil {
		return 0, err
	}

	id, err := containers[0].ID()
	if err != nil {
		return 0, err
	}

	info, err := client.ContainerInspect(context.Background(), id)
	if err != nil || info.ID == "" {
		return 0, err
	}

	if info.State.Running {
		return info.State.Pid, nil
	}

	return 0, nil
}