Skip to content

Commit dcdec12

Browse files
committed
feat: EULA command
1 parent bf30ccf commit dcdec12

File tree

4 files changed

+105
-47
lines changed

4 files changed

+105
-47
lines changed

src/cmd/cli/main.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/spf13/cobra"
2020
"golang.org/x/mod/semver"
2121
"golang.org/x/term"
22+
"google.golang.org/protobuf/types/known/emptypb"
2223

2324
"github.com/AlecAivazis/survey/v2"
2425

@@ -605,6 +606,22 @@ var logoutCmd = &cobra.Command{
605606
},
606607
}
607608

609+
var eulaCmd = &cobra.Command{
610+
Use: "eula",
611+
Annotations: authNeededAnnotation,
612+
Args: cobra.NoArgs,
613+
Short: "Read and/or agree the Defang terms of service",
614+
RunE: func(cmd *cobra.Command, args []string) error {
615+
agreeToS, _ := cmd.Flags().GetBool("agree-tos")
616+
cli.Println("Read our latest terms of service at https://defang.io/terms-conditions.html")
617+
if agreeToS {
618+
_, err := client.SignEULA(cmd.Context(), &connect.Request[emptypb.Empty]{})
619+
return err
620+
}
621+
return nil
622+
},
623+
}
624+
608625
func main() {
609626
colorMode := ColorAuto
610627
rootCmd.PersistentFlags().Var(&colorMode, "color", `Colorize output; "auto", "always" or "never"`)
@@ -616,6 +633,10 @@ func main() {
616633
rootCmd.PersistentFlags().StringP("cwd", "C", "", "Change directory before running the command")
617634
//rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
618635

636+
// Eula command
637+
eulaCmd.Flags().Bool("agree-tos", false, "Agree to the Defang terms of service")
638+
rootCmd.AddCommand(eulaCmd)
639+
619640
// Token command
620641
tokenCmd.Flags().Duration("expires", 24*time.Hour, "Validity duration of the token")
621642
tokenCmd.Flags().String("scope", "", fmt.Sprintf("Scope of the token; one of %v (required)", scope.All()))
@@ -740,13 +761,16 @@ func main() {
740761
if code == connect.CodeUnauthenticated {
741762
printDefangHint("Please use the following command to log in:", "login")
742763
}
764+
if code == connect.CodeFailedPrecondition && strings.Contains(err.Error(), "EULA") {
765+
printDefangHint("Please use the following command to agree to the terms of service:", "eula --agree-tos")
766+
}
743767

744768
os.Exit(int(code))
745769
}
746770

747771
if hasTty && !pkg.GetenvBool("DEFANG_HIDE_UPDATE") {
748772
if ver, err := GetLatestVersion(ctx); err == nil && semver.Compare(GetCurrentVersion(), ver) < 0 {
749-
cli.Warn(" ! A newer version of the CLI is available at https://github.com/defang-io/defang/releases/latest")
773+
cli.Println("A newer version of the CLI is available at https://github.com/defang-io/defang/releases/latest")
750774
}
751775
}
752776
}

src/protos/io/defang/v1/defangv1connect/fabric.connect.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/protos/io/defang/v1/fabric.pb.go

Lines changed: 52 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/protos/io/defang/v1/fabric.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ service FabricController {
2929

3030
rpc GenerateFiles(GenerateFilesRequest) returns (GenerateFilesResponse);
3131

32+
rpc SignEULA(google.protobuf.Empty) returns (google.protobuf.Empty);
3233
rpc PutSecret(SecretValue) returns (google.protobuf.Empty);
3334
rpc ListSecrets(google.protobuf.Empty) returns (Secrets); // no values
3435
rpc CreateUploadURL(UploadURLRequest) returns (UploadURLResponse);

0 commit comments

Comments
 (0)