-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement cloud flow for
plural up
(#530)
* Implement cloud flow for `plural up` This adds a `--cloud` flag to plural up to create a console-less management cluster and register it w/ a hosted console. There are definitely some other ux things we should smooth here, but for now it's good. * fix go.mod * fix pluralctl setup * fix some minor bugs * Use temp dir to clone bootstrap repo in * improve cloud flag * fix after rebase --------- Co-authored-by: Lukasz Zajaczkowski <[email protected]>
- Loading branch information
1 parent
8624d78
commit eabe8c0
Showing
28 changed files
with
340 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package up | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"encoding/base64" | ||
|
||
"github.com/pluralsh/gqlclient" | ||
"github.com/pluralsh/plural-cli/pkg/console" | ||
"github.com/pluralsh/plural-cli/pkg/crypto" | ||
"github.com/samber/lo" | ||
) | ||
|
||
func (p *Plural) backfillEncryption() error { | ||
instances, err := p.Plural.Client.GetConsoleInstances() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
conf := console.ReadConfig() | ||
|
||
if conf.Url == "" { | ||
return fmt.Errorf("You haven't configured your Plural Console client yet") | ||
} | ||
|
||
var id string | ||
for _, inst := range instances { | ||
if strings.Contains(conf.Url, inst.URL) { | ||
id = inst.ID | ||
} | ||
} | ||
if id == "" { | ||
return fmt.Errorf("Your configuration doesn't match to any existing Plural Console") | ||
} | ||
|
||
prov, err := crypto.Build() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
raw, err := prov.SymmetricKey() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
encoded := base64.StdEncoding.EncodeToString(raw) | ||
|
||
return p.Plural.Client.UpdateConsoleInstance(id, gqlclient.ConsoleInstanceUpdateAttributes{ | ||
Configuration: &gqlclient.ConsoleConfigurationUpdateAttributes{ | ||
EncryptionKey: lo.ToPtr(encoded), | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/pluralsh/gqlclient" | ||
) | ||
|
||
func (client *client) GetConsoleInstances() ([]*gqlclient.ConsoleInstanceFragment, error) { | ||
res := []*gqlclient.ConsoleInstanceFragment{} | ||
resp, err := client.pluralClient.GetConsoleInstances(client.ctx, 100) | ||
if err != nil { | ||
return res, err | ||
} | ||
|
||
for _, node := range resp.ConsoleInstances.Edges { | ||
res = append(res, node.Node) | ||
} | ||
|
||
return res, nil | ||
} | ||
|
||
func (client *client) UpdateConsoleInstance(id string, attrs gqlclient.ConsoleInstanceUpdateAttributes) error { | ||
_, err := client.pluralClient.UpdateConsoleInstance(client.ctx, id, attrs) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.