Skip to content

Commit

Permalink
allow token to come from env
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherjesse committed Jan 30, 2023
1 parent c1a1bcb commit dd516e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion pkg/cli/affix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func newAffixCommand() *cobra.Command {
}

cmd.Flags().StringVarP(&sToken, "token", "t", "", "replicate cog token")
cmd.MarkFlagRequired("token")
cmd.Flags().StringVarP(&sRegistry, "registry", "r", "r8.im", "registry host")
cmd.Flags().StringVarP(&baseRef, "base", "b", "", "base image reference - include tag: r8.im/username/modelname@sha256:hexdigest")
cmd.MarkFlagRequired("base")
Expand All @@ -42,6 +41,9 @@ func newAffixCommand() *cobra.Command {
}

func affixCommmand(cmd *cobra.Command, args []string) error {
if sToken == "" {
sToken = os.Getenv("COG_TOKEN")
}

u, err := auth.VerifyCogToken(sRegistry, sToken)
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions pkg/cli/layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/replicate/r8/pkg/images"
)

// var (
// sToken string
// )

func newLayerCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "layers [image]",
Expand All @@ -26,12 +22,14 @@ func newLayerCommand() *cobra.Command {
}

cmd.Flags().StringVarP(&sToken, "token", "t", "", "replicate cog token")
cmd.MarkFlagRequired("token")

return cmd
}

func layersCommmand(cmd *cobra.Command, args []string) error {
if sToken == "" {
sToken = os.Getenv("COG_TOKEN")
}

if len(args) == 0 {
return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/cli/remix.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ func newRemixCommand() *cobra.Command {
}

cmd.Flags().StringVarP(&sToken, "token", "t", "", "replicate cog token")
cmd.MarkFlagRequired("token")

return cmd
}

func remixCommmand(cmd *cobra.Command, args []string) error {
if sToken == "" {
sToken = os.Getenv("COG_TOKEN")
}

u, err := auth.VerifyCogToken(sRegistry, sToken)
if err != nil {
Expand Down

0 comments on commit dd516e2

Please sign in to comment.