From f0e0ba338ada2a7f4c83c8951e252e517a9591f9 Mon Sep 17 00:00:00 2001 From: Andrii Soldatenko Date: Mon, 4 Mar 2019 16:37:08 +0200 Subject: [PATCH] Switch wording from UUID to ID (#184) * Replace UUID to ID * fix deployment delete --- airflow/docker.go | 12 +-- auth/auth.go | 4 +- cmd/airflow.go | 2 +- cmd/serviceaccount.go | 47 ++++++------ cmd/workspace.go | 6 +- deployment/deployment.go | 18 ++--- houston/houston.go | 6 +- houston/queries.go | 121 +++++++++++++------------------ houston/types.go | 16 ++-- main.go | 9 +-- serviceaccount/serviceaccount.go | 20 ++--- workspace/user.go | 12 +-- workspace/workspace.go | 42 +++++------ 13 files changed, 145 insertions(+), 170 deletions(-) diff --git a/airflow/docker.go b/airflow/docker.go index e01463cb8..a27fb5c9f 100644 --- a/airflow/docker.go +++ b/airflow/docker.go @@ -40,7 +40,7 @@ var ( tab = printutil.Table{ Padding: []int{5, 30, 30, 50}, DynamicPadding: true, - Header: []string{"#", "LABEL", "DEPLOYMENT NAME", "WORKSPACE", "DEPLOYMENT UUID"}, + Header: []string{"#", "LABEL", "DEPLOYMENT NAME", "WORKSPACE", "DEPLOYMENT ID"}, } ) @@ -385,13 +385,13 @@ func PS(airflowHome string) error { // Deploy pushes a new docker image func Deploy(path, name, wsId string, prompt bool) error { if len(wsId) == 0 { - return errors.New("no workspace uuid provided") + return errors.New("no workspace id provided") } // Validate workspace wsReq := houston.Request{ Query: houston.WorkspacesGetRequest, - Variables: map[string]interface{}{"workspaceUuid": wsId}, + Variables: map[string]interface{}{"workspaceId": wsId}, } wsResp, err := wsReq.Do() @@ -400,15 +400,15 @@ func Deploy(path, name, wsId string, prompt bool) error { } if len(wsResp.Data.GetWorkspaces) == 0 { - return fmt.Errorf("no workspaces with uuid (%s) found", wsId) + return fmt.Errorf("no workspaces with id (%s) found", wsId) } w := wsResp.Data.GetWorkspaces[0] - // Get Deployments from workspace UUID + // Get Deployments from workspace ID deReq := houston.Request{ Query: houston.DeploymentsGetRequest, - Variables: map[string]interface{}{"workspaceUuid": w.Uuid}, + Variables: map[string]interface{}{"workspaceId": w.Id}, } deResp, err := deReq.Do() diff --git a/auth/auth.go b/auth/auth.go index c47d53b1a..6c42baf70 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -154,8 +154,8 @@ func Login(domain string, oAuthOnly bool) error { if len(workspaces) == 1 && len(c.Workspace) == 0 { w := workspaces[0] - c.SetContextKey("workspace", w.Uuid) - fmt.Printf(messages.CONFIG_SET_DEFAULT_WORKSPACE, w.Label, w.Uuid) + c.SetContextKey("workspace", w.Id) + fmt.Printf(messages.CONFIG_SET_DEFAULT_WORKSPACE, w.Label, w.Id) } if len(workspaces) != 1 && len(c.Workspace) == 0 { diff --git a/cmd/airflow.go b/cmd/airflow.go index ac0426df5..b42a4a56f 100644 --- a/cmd/airflow.go +++ b/cmd/airflow.go @@ -185,7 +185,7 @@ func airflowInit(cmd *cobra.Command, args []string) error { fmt.Sprintf("%s \nYou are not in an empty directory. Are you sure you want to initialize a project?", config.WorkingPath)) if !i { - fmt.Println("Cancelling project initialization...\n") + fmt.Println("Cancelling project initialization...") os.Exit(1) } } diff --git a/cmd/serviceaccount.go b/cmd/serviceaccount.go index 750c09439..ae38439ad 100644 --- a/cmd/serviceaccount.go +++ b/cmd/serviceaccount.go @@ -7,9 +7,8 @@ import ( ) var ( - workspaceUuid string - deploymentUuid string - userUuid string + deploymentId string + userId string systemSA bool category string label string @@ -30,7 +29,7 @@ var ( } saDeleteCmd = &cobra.Command{ - Use: "delete [SA-UUID]", + Use: "delete [SA-ID]", Aliases: []string{"de"}, Short: "Delete a service-account in the astronomer platform", Long: "Delete a service-account in the astronomer platform", @@ -40,8 +39,8 @@ var ( saGetCmd = &cobra.Command{ Use: "get", - Short: "Get a service-account by entity type and entity uuid", - Long: "Get a service-account by entity type and entity uuid", + Short: "Get a service-account by entity type and entity id", + Long: "Get a service-account by entity type and entity id", RunE: saGet, } ) @@ -52,24 +51,24 @@ func init() { // Service-account create saRootCmd.AddCommand(saCreateCmd) - saCreateCmd.Flags().StringVarP(&workspaceUuid, "workspace-uuid", "w", "", "[UUID]") - saCreateCmd.Flags().StringVarP(&deploymentUuid, "deployment-uuid", "d", "", "[UUID]") - saCreateCmd.Flags().StringVarP(&userUuid, "user-uuid", "u", "", "[UUID]") + saCreateCmd.Flags().StringVarP(&workspaceId, "workspace-id", "w", "", "[ID]") + saCreateCmd.Flags().StringVarP(&deploymentId, "deployment-id", "d", "", "[ID]") + saCreateCmd.Flags().StringVarP(&userId, "user-id", "u", "", "[ID]") saCreateCmd.Flags().BoolVarP(&systemSA, "system-sa", "s", false, "") saCreateCmd.Flags().StringVarP(&category, "category", "c", "default", "CATEGORY") saCreateCmd.Flags().StringVarP(&label, "label", "l", "", "LABEL") saRootCmd.AddCommand(saGetCmd) - saGetCmd.Flags().StringVarP(&workspaceUuid, "workspace-uuid", "w", "", "[UUID]") - saGetCmd.Flags().StringVarP(&deploymentUuid, "deployment-uuid", "d", "", "[UUID]") - saGetCmd.Flags().StringVarP(&userUuid, "user-uuid", "u", "", "[UUID]") + saGetCmd.Flags().StringVarP(&workspaceId, "workspace-id", "w", "", "[ID]") + saGetCmd.Flags().StringVarP(&deploymentId, "deployment-id", "d", "", "[ID]") + saGetCmd.Flags().StringVarP(&userId, "user-id", "u", "", "[ID]") saGetCmd.Flags().BoolVarP(&systemSA, "system-sa", "s", false, "") saRootCmd.AddCommand(saDeleteCmd) } func getValidEntity() (string, string, error) { - var uuid string + var id string var entityType string singleArgVerify := 0 @@ -78,21 +77,21 @@ func getValidEntity() (string, string, error) { singleArgVerify++ } - if len(workspaceUuid) > 0 { + if len(workspaceId) > 0 { entityType = "WORKSPACE" - uuid = workspaceUuid + id = workspaceId singleArgVerify++ } - if len(deploymentUuid) > 0 { + if len(deploymentId) > 0 { entityType = "DEPLOYMENT" - uuid = deploymentUuid + id = deploymentId singleArgVerify++ } - if len(userUuid) > 0 { + if len(userId) > 0 { entityType = "USER" - uuid = userUuid + id = userId singleArgVerify++ } @@ -100,12 +99,12 @@ func getValidEntity() (string, string, error) { return "", "", errors.New("must specify exactly one service-account type (system, workspace deployment, user") } - return entityType, uuid, nil + return entityType, id, nil } func saCreate(cmd *cobra.Command, args []string) error { // Validation - entityType, uuid, err := getValidEntity() + entityType, id, err := getValidEntity() if err != nil { return err } @@ -117,7 +116,7 @@ func saCreate(cmd *cobra.Command, args []string) error { // Silence Usage as we have now validated command input cmd.SilenceUsage = true - return sa.Create(uuid, label, category, entityType) + return sa.Create(id, label, category, entityType) } func saDelete(cmd *cobra.Command, args []string) error { @@ -128,7 +127,7 @@ func saDelete(cmd *cobra.Command, args []string) error { } func saGet(cmd *cobra.Command, args []string) error { - entityType, uuid, err := getValidEntity() + entityType, id, err := getValidEntity() if err != nil { return err } @@ -136,5 +135,5 @@ func saGet(cmd *cobra.Command, args []string) error { // Silence Usage as we have now validated command input cmd.SilenceUsage = true - return sa.Get(entityType, uuid) + return sa.Get(entityType, id) } diff --git a/cmd/workspace.go b/cmd/workspace.go index 5ed67b86a..7688caed8 100644 --- a/cmd/workspace.go +++ b/cmd/workspace.go @@ -187,11 +187,11 @@ func workspaceSwitch(cmd *cobra.Command, args []string) error { // Silence Usage as we have now validated command input cmd.SilenceUsage = true - uuid := "" + id := "" if len(args) == 1 { - uuid = args[0] + id = args[0] } - return workspace.Switch(uuid) + return workspace.Switch(id) } diff --git a/deployment/deployment.go b/deployment/deployment.go index a52ac957e..e99cea9d5 100644 --- a/deployment/deployment.go +++ b/deployment/deployment.go @@ -20,7 +20,7 @@ var ( func Create(label, ws string) error { req := houston.Request{ Query: houston.DeploymentCreateRequest, - Variables: map[string]interface{}{"label": label, "workspaceUuid": ws}, + Variables: map[string]interface{}{"label": label, "workspaceId": ws}, } r, err := req.Do() @@ -44,10 +44,10 @@ func Create(label, ws string) error { return nil } -func Delete(uuid string) error { +func Delete(id string) error { req := houston.Request{ Query: houston.DeploymentDeleteRequest, - Variables: map[string]interface{}{"deploymentUuid": uuid}, + Variables: map[string]interface{}{"deploymentId": id}, } _, err := req.Do() @@ -56,7 +56,7 @@ func Delete(uuid string) error { } // TODO - add back in tab print once houston returns all relevant information - // tab.AddRow([]string{d.Label, d.ReleaseName, d.Id, d.Workspace.Uuid}, false) + // tab.AddRow([]string{d.Label, d.ReleaseName, d.Id, d.Workspace.Id}, false) // tab.SuccessMsg = "\n Successfully deleted deployment" // tab.Print() fmt.Println("\n Successfully deleted deployment") @@ -67,7 +67,7 @@ func Delete(uuid string) error { // List all airflow deployments func List(ws string, all bool) error { var deployments []houston.Deployment - var r *houston.HoustonResponse + var r *houston.Response var err error req := houston.Request{ @@ -80,7 +80,7 @@ func List(ws string, all bool) error { return err } } else { - req.Variables = map[string]interface{}{"workspaceUuid": ws} + req.Variables = map[string]interface{}{"workspaceId": ws} r, err = req.Do() if err != nil { return err @@ -94,7 +94,7 @@ func List(ws string, all bool) error { // Build rows for _, d := range deployments { if all { - ws = d.Workspace.Uuid + ws = d.Workspace.Id } tab.AddRow([]string{d.Label, d.ReleaseName, "v" + d.Version, d.Id}, false) } @@ -105,10 +105,10 @@ func List(ws string, all bool) error { } // Update an airflow deployment -func Update(uuid string, args map[string]string) error { +func Update(id string, args map[string]string) error { req := houston.Request{ Query: houston.DeploymentUpdateRequest, - Variables: map[string]interface{}{"deploymentUuid": uuid, "payload": args}, + Variables: map[string]interface{}{"deploymentId": id, "payload": args}, } r, err := req.Do() diff --git a/houston/houston.go b/houston/houston.go index e4d92bd3b..7d3b91503 100644 --- a/houston/houston.go +++ b/houston/houston.go @@ -39,7 +39,7 @@ type Request struct { } // Do (request) is a wrapper to more easily pass variables to a client.Do request -func (r *Request) Do() (*HoustonResponse, error) { +func (r *Request) Do() (*Response, error) { api := NewHoustonClient(httputil.NewHTTPClient()) doOpts := httputil.DoOptions{ @@ -53,7 +53,7 @@ func (r *Request) Do() (*HoustonResponse, error) { } // Do executes a query against the Houston API, logging out any errors contained in the response object -func (c *Client) Do(doOpts httputil.DoOptions) (*HoustonResponse, error) { +func (c *Client) Do(doOpts httputil.DoOptions) (*Response, error) { cl, err := cluster.GetCurrentCluster() if err != nil { return nil, err @@ -81,7 +81,7 @@ func (c *Client) Do(doOpts httputil.DoOptions) (*HoustonResponse, error) { Raw: httpResponse, Body: string(body), } - decode := HoustonResponse{} + decode := Response{} err = json.NewDecoder(strings.NewReader(response.Body)).Decode(&decode) if err != nil { return nil, errors.Wrap(err, "Failed to JSON decode Houston response") diff --git a/houston/queries.go b/houston/queries.go index 93bb0c30a..dd1aacc2e 100644 --- a/houston/queries.go +++ b/houston/queries.go @@ -19,15 +19,15 @@ var ( $label: String! $type: String = "airflow" $version: String = "0.7.5" - $workspaceUuid: Uuid! + $workspaceId: Uuid! ) { createDeployment( label: $label type: $type version: $version - workspaceUuid: $workspaceUuid + workspaceUuid: $workspaceId ) { - uuid + id type label releaseName @@ -38,16 +38,16 @@ var ( }` DeploymentDeleteRequest = ` - mutation DeleteDeployment($deploymentUuid: Uuid!) { - deleteDeployment(deploymentUuid: $deploymentUuid) { - uuid + mutation DeleteDeployment($deploymentId: Uuid!) { + deleteDeployment(deploymentUuid: $deploymentId) { + id type label description releaseName version workspace { - uuid + id } createdAt updatedAt @@ -56,21 +56,21 @@ var ( DeploymentsGetRequest = ` query GetDeployment( - $deploymentUuid: Uuid - $workspaceUuid: Uuid + $deploymentId: Uuid + $workspaceId: Uuid $releaseName: String ) { deployments( - deploymentUuid: $deploymentUuid - workspaceUuid: $workspaceUuid + deploymentUuid: $deploymentId + workspaceUuid: $workspaceId releaseName: $releaseName ) { - uuid + id type label releaseName workspace { - uuid + id } deployInfo { latest @@ -83,16 +83,16 @@ var ( }` DeploymentUpdateRequest = ` - mutation UpdateDeplomyent($deploymentUuid: Uuid!, $payload: JSON!) { - updateDeployment(deploymentUuid: $deploymentUuid, payload: $payload) { - uuid + mutation UpdateDeployment($deploymentId: Uuid!, $payload: JSON!) { + updateDeployment(deploymentUuid: $deploymentId, payload: $payload) { + id type label description releaseName version workspace { - uuid + id } createdAt updatedAt @@ -101,18 +101,18 @@ var ( ServiceAccountCreateRequest = ` mutation CreateServiceAccount( - $entityUuid: Uuid! + $entityId: Uuid! $label: String! $category: String $entityType: EntityType! ) { createServiceAccount( - entityUuid: $entityUuid + entityUuid: $entityId label: $label category: $category entityType: $entityType ) { - uuid + id apiKey label category @@ -126,9 +126,9 @@ var ( }` ServiceAccountDeleteRequest = ` - mutation DeleteServiceAccount($serviceAccountUuid: Uuid!) { - deleteServiceAccount(serviceAccountUuid: $serviceAccountUuid) { - uuid + mutation DeleteServiceAccount($serviceAccountId: Uuid!) { + deleteServiceAccount(serviceAccountUuid: $serviceAccountId) { + id apiKey label category @@ -143,16 +143,16 @@ var ( ServiceAccountsGetRequest = ` query GetServiceAccount( - $serviceAccountUuid: Uuid - $entityUuid: Uuid + $serviceAccountId: Uuid + $entityId: Uuid $entityType: EntityType! ) { serviceAccounts( - serviceAccountUuid: $serviceAccountUuid + serviceAccountUuid: $serviceAccountId entityType: $entityType - entityUuid: $entityUuid + entityUuid: $entityId ) { - uuid + id apiKey label category @@ -169,7 +169,7 @@ var ( mutation createBasicToken($identity: String, $password: String!) { createToken(identity: $identity, password: $password) { user { - uuid + id fullName username status @@ -196,7 +196,7 @@ var ( inviteToken: $inviteToken ) { user { - uuid + id username status createdAt @@ -208,33 +208,14 @@ var ( } }` - UserGetAllRequest = ` - query GetUsers($userUuid: Uuid, $username: String, $email: String) { - users(userUuid: $userUuid, username: $username, email: $email) { - uuid - emails { - address - verified - primary - createdAt - updatedAt - } - fullName - username - status - createdAt - updatedAt - } - }` - WorkspacesGetRequest = ` - query GetWorkspaces($workspaceUuid: Uuid, $label: String, $userUuid: Uuid) { + query GetWorkspaces($workspaceId: Uuid, $label: String, $userId: Uuid) { workspaces( - workspaceUuid: $workspaceUuid + workspaceUuid: $workspaceId label: $label - userUuid: $userUuid + userUuid: $userId ) { - uuid + id label description active @@ -246,7 +227,7 @@ var ( WorkspaceCreateRequest = ` mutation CreateWorkspace($label: String!, $description: String = "N/A") { createWorkspace(label: $label, description: $description) { - uuid + id label description active @@ -256,9 +237,9 @@ var ( }` WorkspaceDeleteRequest = ` - mutation DeleteWorkspace($workspaceUuid: Uuid!) { - deleteWorkspace(workspaceUuid: $workspaceUuid) { - uuid + mutation DeleteWorkspace($workspaceId: Uuid!) { + deleteWorkspace(workspaceUuid: $workspaceId) { + id label description active @@ -268,9 +249,9 @@ var ( }` WorkspaceUpdateRequest = ` - mutation UpdateWorkspace($workspaceUuid: Uuid!, $payload: JSON!) { - updateWorkspace(workspaceUuid: $workspaceUuid, payload: $payload) { - uuid + mutation UpdateWorkspace($workspaceId: Uuid!, $payload: JSON!) { + updateWorkspace(workspaceUuid: $workspaceId, payload: $payload) { + id label description active @@ -281,14 +262,14 @@ var ( }` WorkspaceUserAddRequest = ` - mutation AddWorkspaceUser($workspaceUuid: Uuid!, $email: String!) { - workspaceAddUser(workspaceUuid: $workspaceUuid, email: $email) { - uuid + mutation AddWorkspaceUser($workspaceId: Uuid!, $email: String!) { + workspaceAddUser(workspaceUuid: $workspaceId, email: $email) { + id label description active users { - uuid + id username } createdAt @@ -298,21 +279,21 @@ var ( WorkspaceUserRemoveRequest = ` mutation RemoveWorkspaceUser( - $workspaceUuid: Uuid! - $userUuid: Uuid + $workspaceId: Uuid! + $userId: Uuid $email: String ) { workspaceRemoveUser( - workspaceUuid: $workspaceUuid - userUuid: $userUuid + workspaceUuid: $workspaceId + userUuid: $userId email: $email ) { - uuid + id label description active users { - uuid + id username } createdAt diff --git a/houston/types.go b/houston/types.go index c0dcf0cfb..b24a503ca 100644 --- a/houston/types.go +++ b/houston/types.go @@ -1,7 +1,7 @@ package houston -// HoustonResponse wraps all houston response structs used for json marashalling -type HoustonResponse struct { +// Response wraps all houston response structs used for json marashalling +type Response struct { Data struct { AddWorkspaceUser *Workspace `json:"workspaceAddUser,omitempty"` RemoveWorkspaceUser *Workspace `json:"workspaceRemoveUser,omitempty"` @@ -47,7 +47,7 @@ type Decoded struct { // Deployment defines structure of a houston response Deployment object type Deployment struct { - Id string `json:"uuid"` + Id string `json:"id"` Type string `json:"type"` Label string `json:"label"` ReleaseName string `json:"releaseName"` @@ -89,12 +89,12 @@ type Status struct { // ServiceACcount defines a structure of a ServiceAccountResponse object type ServiceAccount struct { - Uuid string `json:"uuid"` + Id string `json:"id"` ApiKey string `json:"apiKey"` Label string `json:"label"` Category string `json:"category"` EntityType string `json:"entityType"` - EntityUuid string `json:"entityUuid"` + EntityId string `json:"entityId"` LastUsedAt string `json:"lastUsedAt"` Active bool `json:"active"` } @@ -107,14 +107,14 @@ type Token struct { // TokenPayload contains components of a houston auth token type TokenPayload struct { - Uuid string `json:"uuid"` + Id string `json:"id"` Iat int `json:"iat"` Exp int `json:"exp"` } // User contains all components of an Astronomer user type User struct { - Uuid string `json:"uuid"` + Id string `json:"id"` Emails []Email `json:"emails"` Username string `json:"username"` Status string `json:"status"` @@ -125,7 +125,7 @@ type User struct { // Workspace contains all components of an Astronomer Workspace type Workspace struct { - Uuid string `json:"uuid"` + Id string `json:"id"` Label string `json:"label"` Description string `json:"description"` Active bool `json:"active"` diff --git a/main.go b/main.go index 13b29af9f..4b4e31f3e 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,12 @@ package main import ( - "os" - "github.com/astronomer/astro-cli/cmd" + "log" ) func main() { if err := cmd.RootCmd.Execute(); err != nil { - // if cmd.Debug { - // fmt.Printf("%+v", err) - // } - - os.Exit(1) + log.Fatal(err) } } diff --git a/serviceaccount/serviceaccount.go b/serviceaccount/serviceaccount.go index d7a051987..a4e949d8a 100644 --- a/serviceaccount/serviceaccount.go +++ b/serviceaccount/serviceaccount.go @@ -11,15 +11,15 @@ var ( tab = printutil.Table{ Padding: []int{40, 40, 50, 50}, DynamicPadding: true, - Header: []string{"NAME", "CATEGORY", "UUID", "APIKEY"}, + Header: []string{"NAME", "CATEGORY", "ID", "APIKEY"}, } ) -func Create(uuid, label, category, entityType string) error { +func Create(id, label, category, entityType string) error { req := houston.Request{ Query: houston.ServiceAccountCreateRequest, Variables: map[string]interface{}{ - "entityUuid": uuid, + "entityId": id, "label": label, "category": category, "entityType": entityType, @@ -33,17 +33,17 @@ func Create(uuid, label, category, entityType string) error { sa := resp.Data.CreateServiceAccount - tab.AddRow([]string{sa.Label, sa.Category, sa.Uuid, sa.ApiKey}, false) + tab.AddRow([]string{sa.Label, sa.Category, sa.Id, sa.ApiKey}, false) tab.SuccessMsg = "\n Service account successfully created." tab.Print() return nil } -func Delete(uuid string) error { +func Delete(id string) error { req := houston.Request{ Query: houston.ServiceAccountDeleteRequest, - Variables: map[string]interface{}{"serviceAccountUuid": uuid}, + Variables: map[string]interface{}{"serviceAccountId": id}, } resp, err := req.Do() @@ -53,16 +53,16 @@ func Delete(uuid string) error { sa := resp.Data.DeleteServiceAccount - msg := fmt.Sprintf("Service Account %s (%s) successfully deleted", sa.Label, sa.Uuid) + msg := fmt.Sprintf("Service Account %s (%s) successfully deleted", sa.Label, sa.Id) fmt.Println(msg) return nil } -func Get(entityType, uuid string) error { +func Get(entityType, id string) error { req := houston.Request{ Query: houston.ServiceAccountsGetRequest, - Variables: map[string]interface{}{"entityUuid": uuid, "entityType": entityType}, + Variables: map[string]interface{}{"entityId": id, "entityType": entityType}, } resp, err := req.Do() @@ -73,7 +73,7 @@ func Get(entityType, uuid string) error { sas := resp.Data.GetServiceAccounts for _, sa := range sas { - tab.AddRow([]string{sa.Label, sa.Category, sa.Uuid, sa.ApiKey}, false) + tab.AddRow([]string{sa.Label, sa.Category, sa.Id, sa.ApiKey}, false) } tab.Print() diff --git a/workspace/user.go b/workspace/user.go index 6e8185521..a3ced5c11 100644 --- a/workspace/user.go +++ b/workspace/user.go @@ -13,10 +13,10 @@ var ( ) // Add a user to a workspace -func Add(workspaceUuid, email string) error { +func Add(workspaceId, email string) error { req := houston.Request{ Query: houston.WorkspaceUserAddRequest, - Variables: map[string]interface{}{"workspaceUuid": workspaceUuid, "email": email}, + Variables: map[string]interface{}{"workspaceId": workspaceId, "email": email}, } r, err := req.Do() @@ -25,7 +25,7 @@ func Add(workspaceUuid, email string) error { } w := r.Data.AddWorkspaceUser - utab.AddRow([]string{w.Label, w.Uuid, email}, false) + utab.AddRow([]string{w.Label, w.Id, email}, false) utab.SuccessMsg = "Successfully added user to workspace" utab.Print() @@ -33,10 +33,10 @@ func Add(workspaceUuid, email string) error { } // Remove a user from a workspace -func Remove(workspaceUuid, email string) error { +func Remove(workspaceId, email string) error { req := houston.Request{ Query: houston.WorkspaceUserRemoveRequest, - Variables: map[string]interface{}{"workspaceUuid": workspaceUuid, "email": email}, + Variables: map[string]interface{}{"workspaceId": workspaceId, "email": email}, } r, err := req.Do() @@ -45,7 +45,7 @@ func Remove(workspaceUuid, email string) error { } w := r.Data.RemoveWorkspaceUser - utab.AddRow([]string{w.Label, w.Uuid, email}, false) + utab.AddRow([]string{w.Label, w.Id, email}, false) utab.SuccessMsg = "Successfully removed user from workspace" utab.Print() return nil diff --git a/workspace/workspace.go b/workspace/workspace.go index 111223b84..ccbc8bea9 100644 --- a/workspace/workspace.go +++ b/workspace/workspace.go @@ -16,7 +16,7 @@ var ( tab = printutil.Table{ Padding: []int{44, 50}, DynamicPadding: true, - Header: []string{"NAME", "UUID"}, + Header: []string{"NAME", "ID"}, ColorRowCode: [2]string{"\033[1;32m", "\033[0m"}, } ) @@ -35,7 +35,7 @@ func Create(label, desc string) error { w := r.Data.CreateWorkspace - tab.AddRow([]string{w.Label, w.Uuid}, false) + tab.AddRow([]string{w.Label, w.Id}, false) tab.SuccessMsg = "\n Successfully created workspace" tab.Print() @@ -59,11 +59,11 @@ func List() error { for _, w := range ws { name := w.Label - workspace := w.Uuid + workspace := w.Id var color bool - if c.Workspace == w.Uuid { + if c.Workspace == w.Id { color = true } else { color = false @@ -76,11 +76,11 @@ func List() error { return nil } -// Delete a workspace by uuid -func Delete(uuid string) error { +// Delete a workspace by id +func Delete(id string) error { req := houston.Request{ Query: houston.WorkspaceDeleteRequest, - Variables: map[string]interface{}{"workspaceUuid": uuid}, + Variables: map[string]interface{}{"workspaceId": id}, } _, err := req.Do() @@ -89,7 +89,7 @@ func Delete(uuid string) error { } // TODO remove tab print until houston properly returns attrs on delete - // tab.AddRow([]string{w.Label, w.Uuid}, false) + // tab.AddRow([]string{w.Label, w.Id}, false) // tab.SuccessMsg = "\n Successfully deleted workspace" // tab.Print() fmt.Println("\n Successfully deleted workspace") @@ -130,11 +130,11 @@ func getWorkspaceSelection() (string, error) { for _, w := range ws { name := w.Label - workspace := w.Uuid + workspace := w.Id var color bool - if c.Workspace == w.Uuid { + if c.Workspace == w.Id { color = true } else { color = false @@ -155,28 +155,28 @@ func getWorkspaceSelection() (string, error) { return "", errors.Wrapf(err, "cannot parse %s to int", in) } - return ws[i-1].Uuid, nil + return ws[i-1].Id, nil } // Switch switches workspaces -func Switch(uuid string) error { - if len(uuid) == 0 { - _uuid, err := getWorkspaceSelection() +func Switch(id string) error { + if len(id) == 0 { + _id, err := getWorkspaceSelection() if err != nil { return err } - uuid = _uuid + id = _id } // validate workspace req := houston.Request{ Query: houston.WorkspacesGetRequest, - Variables: map[string]interface{}{"workspaceUuid": uuid}, + Variables: map[string]interface{}{"workspaceId": id}, } _, err := req.Do() if err != nil { - return errors.Wrap(err, "workspace uuid is not valid") + return errors.Wrap(err, "workspace id is not valid") } c, err := config.GetCurrentContext() @@ -184,7 +184,7 @@ func Switch(uuid string) error { return err } - c.Workspace = uuid + c.Workspace = id err = c.SetContext() if err != nil { return err @@ -196,11 +196,11 @@ func Switch(uuid string) error { } // Update an astronomer workspace -func Update(uuid string, args map[string]string) error { +func Update(id string, args map[string]string) error { // validate workspace req := houston.Request{ Query: houston.WorkspaceUpdateRequest, - Variables: map[string]interface{}{"workspaceUuid": uuid, "payload": args}, + Variables: map[string]interface{}{"workspaceId": id, "payload": args}, } r, err := req.Do() @@ -210,7 +210,7 @@ func Update(uuid string, args map[string]string) error { w := r.Data.UpdateWorkspace - tab.AddRow([]string{w.Label, w.Uuid}, false) + tab.AddRow([]string{w.Label, w.Id}, false) tab.SuccessMsg = "\n Successfully updated workspace" tab.Print()