@@ -17,7 +17,7 @@ import (
1717 "github.com/pulumi/pulumi/sdk/v3/go/auto"
1818)
1919
20- func Create (projectName , backedURL string , public bool , targetHostID string ) (err error ) {
20+ func Create (projectName , backedURL , connectionDetailsOutput string , public bool , targetHostID string ) (err error ) {
2121 // Check which supported host
2222 host , err := supportMatrix .GetHost (targetHostID )
2323 if err != nil {
@@ -56,7 +56,7 @@ func Create(projectName, backedURL string, public bool, targetHostID string) (er
5656 return err
5757 }
5858 // Write host access info to disk
59- if err = manageResults (stackResult , host , public , "/tmp/qenvs" ); err != nil {
59+ if err = manageResults (stackResult , host , public , connectionDetailsOutput ); err != nil {
6060 return err
6161 }
6262 logging .Debug ("Environment has been created" )
@@ -125,32 +125,18 @@ func manageRequest(request *corporateEnvironmentRequest,
125125func manageResults (stackResult auto.UpResult ,
126126 host * supportMatrix.SupportedHost , public bool ,
127127 destinationFolder string ) error {
128+ // Currently support only one host on host operation
129+ // this should be change when create a environment with multiple hosts
130+ remoteHostID := host .ID
128131 if ! public {
129- if err := writeOutputs (stackResult , destinationFolder , map [string ]string {
130- fmt .Sprintf ("%s-%s" , compute .OutputPrivateKey , "bastion" ): "bastion_id_rsa" ,
131- fmt .Sprintf ("%s-%s" , compute .OutputHost , "bastion" ): "bastion_host" ,
132- fmt .Sprintf ("%s-%s" , compute .OutputUsername , "bastion" ): "bastion_username" ,
133- }); err != nil {
134- return err
135- }
132+ remoteHostID = supportMatrix .S_BASTION .ID
136133 }
137- switch host .Type {
138- case supportMatrix .RHEL :
139- if err := writeOutputs (stackResult , destinationFolder , map [string ]string {
140- fmt .Sprintf ("%s-%s" , compute .OutputPrivateKey , supportMatrix .OL_RHEL .ID ): "rhel_id_rsa" ,
141- fmt .Sprintf ("%s-%s" , compute .OutputHost , supportMatrix .OL_RHEL .ID ): "rhel_host" ,
142- fmt .Sprintf ("%s-%s" , compute .OutputUsername , supportMatrix .OL_RHEL .ID ): "rhel_username" ,
143- }); err != nil {
144- return err
145- }
146- case supportMatrix .MacM1 :
147- if err := writeOutputs (stackResult , destinationFolder , map [string ]string {
148- fmt .Sprintf ("%s-%s" , compute .OutputPrivateKey , supportMatrix .G_MAC_M1 .ID ): "macm1_id_rsa" ,
149- fmt .Sprintf ("%s-%s" , compute .OutputHost , supportMatrix .G_MAC_M1 .ID ): "macm1_host" ,
150- fmt .Sprintf ("%s-%s" , compute .OutputUsername , supportMatrix .G_MAC_M1 .ID ): "macm1_username" ,
151- }); err != nil {
152- return err
153- }
134+ if err := writeOutputs (stackResult , destinationFolder , map [string ]string {
135+ fmt .Sprintf ("%s-%s" , compute .OutputPrivateKey , remoteHostID ): "id_rsa" ,
136+ fmt .Sprintf ("%s-%s" , compute .OutputHost , remoteHostID ): "host" ,
137+ fmt .Sprintf ("%s-%s" , compute .OutputUsername , remoteHostID ): "username" ,
138+ }); err != nil {
139+ return err
154140 }
155141 return nil
156142}
0 commit comments