Skip to content

Commit

Permalink
team create: ask for domain name (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
passichenko authored Jun 6, 2024
1 parent 02acd1a commit 2e47c6d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
3 changes: 2 additions & 1 deletion cmd/lekko/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ func setupCmd() *cobra.Command {
ws.SetLekkoTeam(githubOrgName)
return nil
}
return t.Create(cmd.Context(), githubOrgName, ws)
// TODO: extract domain name from the email
return t.Create(cmd.Context(), githubOrgName, "", ws)
}, secrets.RequireLekkoToken()); err != nil {
return err
}
Expand Down
10 changes: 9 additions & 1 deletion cmd/lekko/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,16 @@ func createCmd() *cobra.Command {
return errors.Wrap(err, "prompt")
}
}
// TODO: extract domain name from the email
var domainName string
if err := survey.AskOne(&survey.Input{
Message: "Domain Name:",
}, &domainName); err != nil {
return errors.Wrap(err, "prompt")
}

if err := secrets.WithWriteSecrets(func(ws secrets.WriteSecrets) error {
return team.NewTeam(lekko.NewBFFClient(ws)).Create(cmd.Context(), name, ws)
return team.NewTeam(lekko.NewBFFClient(ws)).Create(cmd.Context(), name, domainName, ws)
}, secrets.RequireLekkoToken()); err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.22
replace github.com/bazelbuild/buildtools => github.com/lekkodev/buildtools v0.0.0-20240325231538-96eefd799042

require (
buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240315184309-655c9c725f17.1
buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.33.0-20240315184309-655c9c725f17.1
buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240528213244-5fdc18b47eea.1
buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.1-20240528213244-5fdc18b47eea.1
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/atotto/clipboard v0.1.4
github.com/bazelbuild/buildtools v0.0.0-20220907133145-b9bfff5d7f91
Expand All @@ -30,13 +30,13 @@ require (
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc
golang.org/x/mod v0.14.0
golang.org/x/oauth2 v0.7.0
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.34.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
)

require (
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.33.0-20230810202034-1c821065b9a0.1 // indirect
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.34.1-20230419180142-0694c10ef23c.1 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
Expand Down
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240315184309-655c9c725f17.1 h1:2FPSs2wO5hU/M4VTlXV0QHu2nbtDXX40CsQ0XDoNXYo=
buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240315184309-655c9c725f17.1/go.mod h1:x/lkB/GC8COHxF1wEjU4OSAjQFXg1xpL0zzXVAR5KYw=
buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.33.0-20240315184309-655c9c725f17.1 h1:b0lo9gDu2ZqbdpIkz4nXBYSxDnn1r8tTMFs37Qbnqm0=
buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.33.0-20240315184309-655c9c725f17.1/go.mod h1:T3BO2/XI9gH8mPfHZwuXSVQlic0L3VIR/+So4R8yJKM=
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.33.0-20230419180142-0694c10ef23c.1/go.mod h1:LvdTb/syE+Lh0Xi0P5VlhAFoRY5tWRBs/wPPqQYkcYo=
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.33.0-20230810202034-1c821065b9a0.1 h1:IfqRf2dZ+PJckQM64/lSyIKr4av5+QQcWMSDf38YHo0=
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.33.0-20230810202034-1c821065b9a0.1/go.mod h1:LvdTb/syE+Lh0Xi0P5VlhAFoRY5tWRBs/wPPqQYkcYo=
buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240528213244-5fdc18b47eea.1 h1:JqArhl+OClAdLQis1N2N6WmLv96CbOaNrQEYWL2ntlI=
buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240528213244-5fdc18b47eea.1/go.mod h1:gkMKhhTCMDLJVmimyqao6P3g7jB7wDe3r7u8hV2iShE=
buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.1-20240528213244-5fdc18b47eea.1 h1:3Y4c9bezl+IkrA6PAvSCbf7OwRlc4VqnoHgQE5PjAG8=
buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.1-20240528213244-5fdc18b47eea.1/go.mod h1:PdhIB2hERtKCdWDhfLDhGAHLrH3GcrvRhtcNaj+7IDA=
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.34.1-20230419180142-0694c10ef23c.1 h1:WdwZAhYeXf6OLcQd0kN0LkFscJLFGuv4PzmlqYUXbRQ=
buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.34.1-20230419180142-0694c10ef23c.1/go.mod h1:kGRYzY47/Dh+tG9nrThd4XpnYvJLxqJHKRwNptUsxnI=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
Expand Down Expand Up @@ -323,8 +322,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
5 changes: 3 additions & 2 deletions pkg/team/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ func roleToProto(role MemberRole) bffv1beta1.MembershipRole {
}
}

func (t *Team) Create(ctx context.Context, name string, wts WriteTeamStore) error {
func (t *Team) Create(ctx context.Context, name, domainName string, wts WriteTeamStore) error {
if _, err := t.lekkoBFFClient.CreateTeam(ctx, connect_go.NewRequest(&bffv1beta1.CreateTeamRequest{
Name: name,
Name: name,
DomainName: domainName,
})); err != nil {
return errors.Wrap(err, "create team")
}
Expand Down

0 comments on commit 2e47c6d

Please sign in to comment.