2017-11-20 09:30:52 -05:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
composetypes "github.com/docker/cli/cli/compose/types"
|
2017-12-04 03:44:06 -05:00
|
|
|
apiv1beta1 "github.com/docker/cli/kubernetes/compose/v1beta1"
|
2017-11-20 09:30:52 -05:00
|
|
|
yaml "gopkg.in/yaml.v2"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
)
|
|
|
|
|
2018-01-29 16:18:43 -05:00
|
|
|
// LoadStack loads a stack from a Compose config, with a given name.
|
2018-02-21 12:31:52 -05:00
|
|
|
func LoadStack(name string, cfg composetypes.Config) (*apiv1beta1.Stack, error) {
|
|
|
|
res, err := yaml.Marshal(cfg)
|
2017-11-20 09:30:52 -05:00
|
|
|
if err != nil {
|
2018-01-29 16:18:43 -05:00
|
|
|
return nil, err
|
2017-11-20 09:30:52 -05:00
|
|
|
}
|
|
|
|
return &apiv1beta1.Stack{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
Name: name,
|
|
|
|
},
|
|
|
|
Spec: apiv1beta1.StackSpec{
|
2018-01-29 16:18:43 -05:00
|
|
|
ComposeFile: string(res),
|
2017-11-20 09:30:52 -05:00
|
|
|
},
|
2018-01-29 16:18:43 -05:00
|
|
|
}, nil
|
2017-11-20 09:30:52 -05:00
|
|
|
}
|