@@ -11,8 +11,7 @@ import (
1111 "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
1212 "github.com/redhat-developer/mapt/pkg/manager"
1313 mc "github.com/redhat-developer/mapt/pkg/manager/context"
14- cr "github.com/redhat-developer/mapt/pkg/provider/api/compute-request"
15- spotTypes "github.com/redhat-developer/mapt/pkg/provider/api/spot"
14+ kindApi "github.com/redhat-developer/mapt/pkg/provider/api/k8s/kind"
1615 "github.com/redhat-developer/mapt/pkg/provider/aws"
1716 awsConstants "github.com/redhat-developer/mapt/pkg/provider/aws/constants"
1817 "github.com/redhat-developer/mapt/pkg/provider/aws/modules/allocation"
@@ -23,24 +22,13 @@ import (
2322 amiSVC "github.com/redhat-developer/mapt/pkg/provider/aws/services/ec2/ami"
2423 "github.com/redhat-developer/mapt/pkg/provider/aws/services/ec2/keypair"
2524 securityGroup "github.com/redhat-developer/mapt/pkg/provider/aws/services/ec2/security-group"
26- kindCloudConfig "github.com/redhat-developer/mapt/pkg/provider/util/cloud-config/kind"
2725 "github.com/redhat-developer/mapt/pkg/provider/util/command"
2826 "github.com/redhat-developer/mapt/pkg/provider/util/output"
2927 "github.com/redhat-developer/mapt/pkg/util"
3028 "github.com/redhat-developer/mapt/pkg/util/logging"
3129 resourcesUtil "github.com/redhat-developer/mapt/pkg/util/resources"
3230)
3331
34- type KindArgs struct {
35- Prefix string
36- ComputeRequest * cr.ComputeRequestArgs
37- Version string
38- Arch string
39- Spot * spotTypes.SpotArgs
40- Timeout string
41- ExtraPortMappings []kindCloudConfig.PortMapping
42- }
43-
4432type kindRequest struct {
4533 mCtx * mc.Context
4634 prefix * string
@@ -49,7 +37,7 @@ type kindRequest struct {
4937 spot bool
5038 timeout * string
5139 allocationData * allocation.AllocationResult
52- extraPortMappings []kindCloudConfig .PortMapping
40+ extraPortMappings []kindApi .PortMapping
5341}
5442
5543func (r * kindRequest ) validate () error {
@@ -61,18 +49,10 @@ func (r *kindRequest) validate() error {
6149 return v .Struct (r )
6250}
6351
64- type KindResultsMetadata struct {
65- Username string `json:"username"`
66- PrivateKey string `json:"private_key"`
67- Host string `json:"host"`
68- Kubeconfig string `json:"kubeconfig"`
69- SpotPrice * float64 `json:"spot_price,omitempty"`
70- }
71-
7252// Create orchestrate 3 stacks:
7353// If spot is enable it will run best spot option to get the best option to spin the machine
7454// Then it will run the stack for windows dedicated host
75- func Create (mCtxArgs * mc.ContextArgs , args * KindArgs ) (kr * KindResultsMetadata , err error ) {
55+ func Create (mCtxArgs * mc.ContextArgs , args * kindApi. KindArgs ) (kr * kindApi. KindResults , err error ) {
7656 mCtx , err := mc .Init (mCtxArgs , aws .Provider ())
7757 if err != nil {
7858 return nil , err
@@ -116,7 +96,7 @@ func Destroy(mCtxArgs *mc.ContextArgs) (err error) {
11696 return nil
11797}
11898
119- func (r * kindRequest ) createHost () (* KindResultsMetadata , error ) {
99+ func (r * kindRequest ) createHost () (* kindApi. KindResults , error ) {
120100 cs := manager.Stack {
121101 StackName : r .mCtx .StackNameByProject (stackName ),
122102 ProjectName : r .mCtx .ProjectName (),
@@ -196,7 +176,7 @@ func (r *kindRequest) deploy(ctx *pulumi.Context) error {
196176 return err
197177 }
198178 // Build LB target groups including both default and extra ports
199- lbTargetGroups := []int {22 , portAPI , portHTTP , portHTTPS }
179+ lbTargetGroups := []int {22 , kindApi . PortAPI , kindApi . PortHTTP , kindApi . PortHTTPS }
200180 lbTargetGroups = append (lbTargetGroups , extraHostPorts ... )
201181
202182 cr := compute.ComputeRequest {
@@ -253,7 +233,7 @@ func (r *kindRequest) deploy(ctx *pulumi.Context) error {
253233}
254234
255235// Write exported values in context to files o a selected target folder
256- func (r * kindRequest ) manageResults (stackResult auto.UpResult , prefix * string ) (* KindResultsMetadata , error ) {
236+ func (r * kindRequest ) manageResults (stackResult auto.UpResult , prefix * string ) (* kindApi. KindResults , error ) {
257237 username , err := getResultOutput (outputUsername , stackResult , prefix )
258238 if err != nil {
259239 return nil , err
@@ -271,7 +251,7 @@ func (r *kindRequest) manageResults(stackResult auto.UpResult, prefix *string) (
271251 return nil , err
272252 }
273253
274- metadataResults := & KindResultsMetadata {
254+ metadataResults := & kindApi. KindResults {
275255 Username : username ,
276256 PrivateKey : privateKey ,
277257 Host : host ,
@@ -315,9 +295,9 @@ func securityGroups(ctx *pulumi.Context, mCtx *mc.Context, prefix *string,
315295 // Build ingress rules including both default and extra ports
316296 ingressRules := []securityGroup.IngressRules {
317297 securityGroup .SSH_TCP ,
318- {Description : "HTTPS" , FromPort : portHTTPS , ToPort : portHTTPS , Protocol : "tcp" },
319- {Description : "HTTP" , FromPort : portHTTP , ToPort : portHTTP , Protocol : "tcp" },
320- {Description : "API" , FromPort : portAPI , ToPort : portAPI , Protocol : "tcp" },
298+ {Description : "HTTPS" , FromPort : kindApi . PortHTTPS , ToPort : kindApi . PortHTTPS , Protocol : "tcp" },
299+ {Description : "HTTP" , FromPort : kindApi . PortHTTP , ToPort : kindApi . PortHTTP , Protocol : "tcp" },
300+ {Description : "API" , FromPort : kindApi . PortAPI , ToPort : kindApi . PortAPI , Protocol : "tcp" },
321301 }
322302
323303 // Add extra ports to ingress rules
@@ -348,16 +328,16 @@ func securityGroups(ctx *pulumi.Context, mCtx *mc.Context, prefix *string,
348328 return pulumi .StringArray (sgs [:]), nil
349329}
350330
351- func userData (arch , k8sVersion * string , parsedPortMappings []kindCloudConfig .PortMapping , lbEIP * pulumi.StringOutput ) (pulumi.StringPtrInput , error ) {
331+ func userData (arch , k8sVersion * string , parsedPortMappings []kindApi .PortMapping , lbEIP * pulumi.StringOutput ) (pulumi.StringPtrInput , error ) {
352332 ccB64 := lbEIP .ApplyT (
353333 func (publicIP string ) (string , error ) {
354- ccB64 , err := kindCloudConfig .CloudConfig (
355- & kindCloudConfig .DataValues {
334+ ccB64 , err := kindApi .CloudConfig (
335+ & kindApi .DataValues {
356336 Arch : util .If (* arch == "x86_64" ,
357- kindCloudConfig .X86_64 ,
358- kindCloudConfig .Arm64 ),
359- KindVersion : KindK8sVersions [* k8sVersion ].kindVersion ,
360- KindImage : KindK8sVersions [* k8sVersion ].KindImage ,
337+ kindApi .X86_64 ,
338+ kindApi .Arm64 ),
339+ KindVersion : kindApi . KindK8sVersions [* k8sVersion ].KindVersion ,
340+ KindImage : kindApi . KindK8sVersions [* k8sVersion ].KindImage ,
361341 Username : amiUserDefault ,
362342 PublicIP : publicIP ,
363343 ExtraPortMappings : parsedPortMappings })
0 commit comments