diff --git a/cli/cmd/commands.go b/cli/cmd/commands.go index 82b8f85..3afb4f0 100644 --- a/cli/cmd/commands.go +++ b/cli/cmd/commands.go @@ -168,7 +168,7 @@ func bindAwsInstallFlags(cmd *cobra.Command, a *controller.SetupArgs) { cmd.Flags().BoolVar(&a.UseEnv, "aws-env", false, "Use AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables for AWS authentication") cmd.Flags().StringVar(&a.Profile, "aws-profile", "", "Use the given profile for AWS authentication") cmd.Flags().BoolVar(&a.DryRun, "dry-run", false, "Don't start install/uninstall just show what credentials will be used") - cmd.Flags().StringVar(&a.GithubID, "github-id", "", "The GitHub user that owns the node") + cmd.Flags().StringVar(&a.GithubUser, "github-user", "", "The GitHub user that owns the node") } func showAwsDryRunInfo(a *controller.SetupArgs) { diff --git a/cli/controller/auth.go b/cli/controller/auth.go index 8087c82..25f9584 100644 --- a/cli/controller/auth.go +++ b/cli/controller/auth.go @@ -22,7 +22,7 @@ const ( func AuthToken(n *domain.Node) (string, error) { t, err := n.AuthToken() var terr *domain.TokenExpiredError - if errors.As(err, &terr) && n.GithubID != "" { + if errors.As(err, &terr) && n.GithubUser != "" { var err error t, err = githubAuth(n) if err != nil { diff --git a/cli/controller/examples/node_example.go b/cli/controller/examples/node_example.go index 2126695..d1fd1da 100644 --- a/cli/controller/examples/node_example.go +++ b/cli/controller/examples/node_example.go @@ -28,7 +28,7 @@ func NewUserAddCommand() *cobra.Command { Hidden: true, RunE: func(cmd *cobra.Command, args []string) error { node := cmd.Flag("node").Value.String() - user := cmd.Flag("github-username").Value.String() + user := cmd.Flag("github-user").Value.String() role := cmd.Flag("role").Value.String() n, err := findNode(node) if err != nil { @@ -59,7 +59,7 @@ func NewUserAddCommand() *cobra.Command { }, } cmd.Flags().StringP("node", "", domain.DefaultNodeName, "") - cmd.Flags().StringP("github-username", "", "", "") + cmd.Flags().StringP("github-user", "", "", "") cmd.Flags().StringP("role", "", "user", "") return cmd } diff --git a/cli/controller/setup.go b/cli/controller/setup.go index 5a8e920..2ff2e5a 100644 --- a/cli/controller/setup.go +++ b/cli/controller/setup.go @@ -40,7 +40,7 @@ type Setup struct { credentialsProvider int force bool yes bool - githubID string + githubUser string } type stackTemplateData struct { @@ -72,7 +72,7 @@ func NewSetup(a *SetupArgs) (*Setup, error) { credentialsProvider: a.credentialsProvider, force: a.Force, yes: a.Yes, - githubID: a.GithubID, + githubUser: a.GithubUser, }, nil } @@ -84,7 +84,7 @@ Available regions are: } ws := c.store.Workspace() bucket, key := getPath(c.aws.Region()) - n, err := ws.NewNode(c.nodeName, c.aws.AccountID(), c.aws.Region(), bucket, key, version, c.githubID) + n, err := ws.NewNode(c.nodeName, c.aws.AccountID(), c.aws.Region(), bucket, key, version, c.githubUser) if err != nil { return log.Wrap(err) } diff --git a/cli/controller/setup_args.go b/cli/controller/setup_args.go index 537fade..7272f72 100644 --- a/cli/controller/setup_args.go +++ b/cli/controller/setup_args.go @@ -28,7 +28,7 @@ type SetupArgs struct { credentialsProvider int Force bool Yes bool - GithubID string + GithubUser string } func DefaultNodeName() string { return domain.DefaultNodeName } diff --git a/domain/workspace.go b/domain/workspace.go index a75e126..9aa1289 100644 --- a/domain/workspace.go +++ b/domain/workspace.go @@ -27,9 +27,9 @@ const ( EnvSSMPathPrefix = "MANTIL_SSM_PATH_PREFIX" EnvKVTable = "MANTIL_KV_TABLE" - SSMPublicKey = "public_key" - SSMPrivateKey = "private_key" - SSMGithubIDKey = "github_id" + SSMPublicKey = "public_key" + SSMPrivateKey = "private_key" + SSMGithubUserKey = "github_user" NodeConfigKey = "config" @@ -70,8 +70,8 @@ type Node struct { Functions NodeFunctions `yaml:"functions"` Stages []*NodeStage `yaml:"stages,omitempty"` - GithubID string `yaml:"github_id,omitempty"` - JWT string `yaml:"jwt,omitempty"` + GithubUser string `yaml:"github_user,omitempty"` + JWT string `yaml:"jwt,omitempty"` workspace *Workspace } @@ -127,7 +127,7 @@ func (w *Workspace) Node(name string) *Node { return nil } -func (w *Workspace) NewNode(name, awsAccountID, awsRegion, functionsBucket, functionsPath, version string, githubID string) (*Node, error) { +func (w *Workspace) NewNode(name, awsAccountID, awsRegion, functionsBucket, functionsPath, version string, githubUser string) (*Node, error) { if w.nodeExists(name) { return nil, errors.WithStack(&NodeExistsError{name}) } @@ -146,8 +146,8 @@ func (w *Workspace) NewNode(name, awsAccountID, awsRegion, functionsBucket, func }, workspace: w, } - if githubID != "" { - a.GithubID = githubID + if githubUser != "" { + a.GithubUser = githubUser } else { publicKey, privateKey, err := token.KeyPair() if err != nil { @@ -284,7 +284,7 @@ func Factory(w *Workspace, p *Project, e *EnvironmentConfig) error { } func (n *Node) AuthToken() (string, error) { - if n.GithubID == "" { + if n.GithubUser == "" { claims := &AccessTokenClaims{ Role: Owner, Workspace: n.workspace.ID, diff --git a/node/api/node/auth.go b/node/api/node/auth.go index cf65b26..1a9726a 100644 --- a/node/api/node/auth.go +++ b/node/api/node/auth.go @@ -122,7 +122,7 @@ func (a *Auth) generateJWT() (string, error) { } func (a *Auth) userRole(ghUser *github.User) (domain.Role, error) { - if a.node.GithubID == *ghUser.Login { + if a.node.GithubUser == *ghUser.Login { return domain.Owner, nil } u, err := a.store.FindUser(*ghUser.Login) diff --git a/node/api/setup/setup.go b/node/api/setup/setup.go index 355424e..ef3ecd2 100644 --- a/node/api/setup/setup.go +++ b/node/api/setup/setup.go @@ -125,7 +125,7 @@ func (s *Setup) terraformCreate(req *dto.SetupRequest) (*dto.SetupResponse, erro AuthEnv: n.AuthEnv(), ResourceTags: n.ResourceTags(), } - if n.GithubID != "" { + if n.GithubUser != "" { publicKey, privateKey, err := token.KeyPair() if err != nil { return nil, err diff --git a/node/api/setup/setup_test.go b/node/api/setup/setup_test.go index ce93e71..008bb55 100644 --- a/node/api/setup/setup_test.go +++ b/node/api/setup/setup_test.go @@ -29,7 +29,7 @@ func TestTerraformRender(t *testing.T) { NamingTemplate: "mantil-%s", PublicKey: "public_key", PrivateKey: "private_key", - GithubID: "github_id", + GithubUser: "github_user", } tf, err := terraform.Setup(data) require.NoError(t, err) diff --git a/node/terraform/terraform.go b/node/terraform/terraform.go index 4ac460f..8c27e29 100644 --- a/node/terraform/terraform.go +++ b/node/terraform/terraform.go @@ -72,7 +72,7 @@ type SetupTemplateData struct { NamingTemplate string AuthEnv map[string]string ResourceTags map[string]string - GithubID string + GithubUser string PublicKey string PrivateKey string } diff --git a/node/terraform/terraform_test.go b/node/terraform/terraform_test.go index af420e3..ae50dbb 100644 --- a/node/terraform/terraform_test.go +++ b/node/terraform/terraform_test.go @@ -39,7 +39,7 @@ func TestRenderSetup(t *testing.T) { NamingTemplate: "prefix-%s-suffix", PublicKey: "public_key", PrivateKey: "private_key", - GithubID: "github_id", + GithubUser: "github_user", } tf, err := renderSetup(data) require.NoError(t, err)