Skip to content

Commit

Permalink
rename github-id to github-user
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Mar 7, 2022
1 parent 7a1a573 commit 5959b7b
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion cli/controller/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/controller/examples/node_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions cli/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Setup struct {
credentialsProvider int
force bool
yes bool
githubID string
githubUser string
}

type stackTemplateData struct {
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/controller/setup_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SetupArgs struct {
credentialsProvider int
Force bool
Yes bool
GithubID string
GithubUser string
}

func DefaultNodeName() string { return domain.DefaultNodeName }
Expand Down
18 changes: 9 additions & 9 deletions domain/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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})
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion node/api/node/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion node/api/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion node/api/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion node/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion node/terraform/terraform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5959b7b

Please sign in to comment.