Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State Upload #2903

Merged
merged 78 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c72f65c
Added `state author upload <file>`
Naatan Mar 3, 2023
44009dc
Make payload editable by end user
Naatan Mar 3, 2023
b51186a
Client speaks correct protocol when doing multipart upload
Naatan Apr 5, 2023
dc41fa7
Update mono and inventory API client code
Naatan Apr 6, 2023
b17cfc8
Add editing
Naatan Apr 10, 2023
86f902c
Add ability to edit author and dependencies, as well as to specify th…
Naatan May 5, 2023
191d459
Fix compile failure due to merge conflict
Naatan May 19, 2023
8020ed3
Implement --edit flow
Naatan May 25, 2023
62777c6
Vars can return an error
Naatan May 25, 2023
dd5d1bc
Email is always required
Naatan May 29, 2023
71ef19d
Simplify variable handling
Naatan May 29, 2023
5513a05
Support uploading by meta file
Naatan May 29, 2023
50d817a
Move locale
Naatan May 29, 2023
6a0151e
Update locale
Naatan May 29, 2023
6683f95
Update formatting
Naatan May 29, 2023
2f736e4
Detect non-interactive error condition
Naatan May 29, 2023
ca173a4
WIP: search includes timestamp and namespace, and outputs json
Naatan May 29, 2023
0589d42
Add namespace and timestamp support to commands that need it
Naatan Jun 5, 2023
226948a
Update flag types to be user friendly
Naatan Jun 5, 2023
f155f74
Remove reliance on RequestBase
Naatan Jun 5, 2023
965caec
Drop commented out code
Naatan Jun 5, 2023
75cb261
Add comments explaining fields
Naatan Jun 5, 2023
85ea2b6
Rename Flag types to Value
Naatan Jun 5, 2023
e8d835b
Simplify conditional
Naatan Jun 5, 2023
a2b739b
Clarify comment
Naatan Jun 5, 2023
b2a1e54
Merge branch 'DX-1754' into DX-1887
Naatan Jun 6, 2023
7958a0c
Fix missing directive
Naatan Jun 7, 2023
688b9f7
Rename upload to publish
Naatan Jun 7, 2023
197718e
Merge pull request #2560 from ActiveState/DX-1887
Naatan Jun 8, 2023
9423757
Merge remote-tracking branch 'origin/DX-1828' into DX-1754
Naatan Jun 9, 2023
a5276c7
Allow specifying timestamp again
Naatan Jun 12, 2023
1d6398c
Merge branch 'DX-1754' into DX-1892
Naatan Jun 13, 2023
7a4befa
Merge pull request #2575 from ActiveState/DX-1892
Naatan Jun 13, 2023
47e6eef
Merge branch 'DX-1568' into DX-1754
Naatan Jun 14, 2023
6ebc81b
Stream file uploads.
mitchell-as Jun 20, 2023
aa7a606
Use error channel for async publish request.
mitchell-as Jun 21, 2023
695119c
Avoid passing error channels around.
mitchell-as Jun 21, 2023
9ce11d3
Move up to avoid dangling goroutine.
mitchell-as Jun 22, 2023
63be52f
Merge pull request #2594 from ActiveState/mitchell/dx-1906
mitchell-as Jun 22, 2023
a5c30c7
Use API directly for ts.CreateNewUser as it is much faster to test with
Naatan Jun 22, 2023
3ef642c
Add `state publish` tests
Naatan Jun 22, 2023
bb45dd7
Address issues raised by tests
Naatan Jun 22, 2023
6b87843
Disable env var meant for development only
Naatan Jun 22, 2023
cdd21ad
Remove pointless err var
Naatan Jun 23, 2023
c96ebf1
Construct regex at compile time
Naatan Jun 23, 2023
208e877
Reuse testing session as these tests shouldn't interact with each oth…
Naatan Jun 23, 2023
a51951e
Merge pull request #2600 from ActiveState/DX-1888
Naatan Jun 23, 2023
ef9a2b1
Made `state publish` meta file an optional flag instead of an optiona…
mitchell-as Jun 26, 2023
a2668a2
Updated publish integration tests.
mitchell-as Jun 27, 2023
1b24b10
Merge pull request #2607 from ActiveState/mitchell/dx-1937
mitchell-as Jun 27, 2023
a9de12b
Require .zip or .tar.gz for `state publish`
Naatan Jul 6, 2023
c8879a9
Fix conditional
Naatan Jul 6, 2023
e8111a8
Fix expect happening on test that doesn't expect this
Naatan Jul 6, 2023
655679a
Merge pull request #2618 from ActiveState/DX-1936
Naatan Jul 6, 2023
b06b31f
Merge branch 'version/0-40-0-RC1' into DX-1754
Naatan Jul 17, 2023
a84cf40
Fix build failure
Naatan Jul 17, 2023
07dc651
Merge branch 'version/0-41-0-RC1' into DX-1754
Naatan Jul 25, 2023
7fe5ea4
Update `state publish` to new namespace format
Naatan Jul 25, 2023
cb74079
Fix test failure
Naatan Jul 25, 2023
4dbdc7a
Drop overly specific regex suffix
Naatan Jul 25, 2023
21da0b3
Merge pull request #2656 from ActiveState/DX-2041
Naatan Jul 26, 2023
7428d6d
Fix searching not respecting namespace
Naatan Jul 28, 2023
df19bbf
Start work on edit test
Naatan Jul 28, 2023
67d4712
Fix runWithFiles hanging if the file pointer is nil
Naatan Jul 31, 2023
f597306
Fix looking at wrong param
Naatan Jul 31, 2023
597a496
Ensure file is optional
Naatan Jul 31, 2023
f4ea63d
Use Publish term instead of Upload
Naatan Jul 31, 2023
58a024f
Always send file upload type requests through the file uploader even …
Naatan Aug 1, 2023
8f1893f
Show namespace in search if input also used namespace
Naatan Aug 1, 2023
09c65ff
Fix error handling for graphql request
Naatan Aug 1, 2023
cfb422d
Make file required
Naatan Aug 1, 2023
fa42466
Implement editing tests
Naatan Aug 1, 2023
2bf6e9a
Comment out code that's not meant to be uncommented
Naatan Aug 1, 2023
346aa0e
Merge pull request #2676 from ActiveState/DX-1944
Naatan Aug 1, 2023
d5d0ef7
Merge branch 'version/0-41-0-RC1' into DX-1754
Naatan Aug 1, 2023
25a9834
Merge remote-tracking branch 'origin/DX-1754' into version/0-43-0-RC1
mitchell-as Nov 28, 2023
04a59b8
Fix build errors.
mitchell-as Nov 28, 2023
9b75556
Merge branch 'version/0-43-0-RC1' into mitchell/dx-2334
mitchell-as Dec 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions cmd/state/internal/cmdtree/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newBundleUninstallCommand(prime *primer.Values) *captain.Command {
{
Name: locale.T("bundle_arg_name"),
Description: locale.T("bundle_arg_name_description"),
Value: &params.Name,
Value: &params.Package,
Required: true,
},
},
Expand Down Expand Up @@ -118,7 +118,7 @@ func newBundlesSearchCommand(prime *primer.Values) *captain.Command {
{
Name: locale.T("bundle_arg_name"),
Description: locale.T("bundle_arg_name_description"),
Value: &params.Name,
Value: &params.Ingredient,
Required: true,
},
},
Expand Down
2 changes: 2 additions & 0 deletions cmd/state/internal/cmdtree/cmdtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func New(prime *primer.Values, args ...string) *CmdTree {
newSwitchCommand(prime),
newTestCommand(prime),
//newCommitCommand(prime), // re-enable in DX-2307
newPublish(prime),
)

return &CmdTree{
Expand All @@ -230,6 +231,7 @@ var (
VCSGroup = captain.NewCommandGroup(locale.Tl("group_vcs", "Version Control"), 5)
AutomationGroup = captain.NewCommandGroup(locale.Tl("group_automation", "Automation"), 4)
UtilsGroup = captain.NewCommandGroup(locale.Tl("group_utils", "Utilities"), 3)
AuthorGroup = captain.NewCommandGroup(locale.Tl("group_author", "Author"), 6)
)

func newGlobalOptions() *globalOptions {
Expand Down
22 changes: 19 additions & 3 deletions cmd/state/internal/cmdtree/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ func newInstallCommand(prime *primer.Values) *captain.Command {
locale.Tl("package_install_title", "Installing Package"),
locale.T("package_install_cmd_description"),
prime,
[]*captain.Flag{},
[]*captain.Flag{
{
Name: "ts",
Description: locale.T("package_flag_ts_description"),
Value: &params.Timestamp,
},
},
[]*captain.Argument{
{
Name: locale.T("package_arg_nameversion"),
Expand Down Expand Up @@ -88,7 +94,7 @@ func newUninstallCommand(prime *primer.Values) *captain.Command {
{
Name: locale.T("package_arg_name"),
Description: locale.T("package_arg_name_description"),
Value: &params.Name,
Value: &params.Package,
Required: true,
},
},
Expand Down Expand Up @@ -145,12 +151,17 @@ func newSearchCommand(prime *primer.Values) *captain.Command {
Description: locale.T("package_search_flag_exact-term_description"),
Value: &params.ExactTerm,
},
{
Name: "ts",
Description: locale.T("package_search_flag_ts_description"),
Value: &params.Timestamp,
},
},
[]*captain.Argument{
{
Name: locale.T("package_arg_name"),
Description: locale.T("package_arg_name_description"),
Value: &params.Name,
Value: &params.Ingredient,
Required: true,
},
},
Expand All @@ -176,6 +187,11 @@ func newInfoCommand(prime *primer.Values) *captain.Command {
Description: locale.T("package_info_flag_language_description"),
Value: &params.Language,
},
{
Name: "ts",
Description: locale.T("package_flag_ts_description"),
Value: &params.Timestamp,
},
},
[]*captain.Argument{
{
Expand Down
97 changes: 97 additions & 0 deletions cmd/state/internal/cmdtree/publish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package cmdtree

import (
"github.com/ActiveState/cli/internal/captain"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runners/publish"
)

func newPublish(prime *primer.Values) *captain.Command {
runner := publish.New(prime)
params := publish.Params{}
c := captain.NewCommand(
"publish",
locale.Tl("add_title", "Publish Ingredient"),
locale.Tl("add_description", "Publish an Ingredient for private consumption."),
prime,
[]*captain.Flag{
{
Name: "edit",
Description: locale.Tl("author_upload_edit_description", "Create a revision for an existing ingredient, matched by their name and namespace."),
Value: &params.Edit,
},
{
Name: "editor",
Description: locale.Tl("author_upload_editor_description", "Edit the ingredient information in your editor before uploading."),
Value: &params.Editor,
},
{
Name: "name",
Description: locale.Tl(
"author_upload_name_description",
"The name of the ingredient. Defaults to basename of filepath.",
),
Value: &params.Name,
},
{
Name: "version",
Description: locale.Tl(
"author_upload_version_description",
"Version of the ingredient (preferably semver).",
),
Value: &params.Version,
},
{
Name: "namespace",
Description: locale.Tl(
"author_upload_namespace_description",
"The namespace of the ingredient. Defaults to org/<orgname>. Must start with 'org/<orgname>'.",
),
Value: &params.Namespace,
},
{
Name: "description",
Description: locale.Tl(
"author_upload_description_description",
"A short description summarizing what this ingredient is for.",
),
Value: &params.Description,
},
{
Name: "author",
Description: locale.Tl(
"author_upload_author_description",
"Ingredient author, in the format of \"[<name>] <email>\". Can be set multiple times.",
),
Value: &params.Authors,
},
{
Name: "depend",
Description: locale.Tl(
"author_upload_depend_description",
"Ingredient that this ingredient depends on, format as <namespace>/<name>[@<version>]. Can be set multiple times.",
),
Value: &params.Depends,
},
{
Name: "meta",
Description: locale.Tl("author_upload_metafile_description", "A yaml file expressing the ingredient meta information. Use --editor to review the file format."),
Value: &params.MetaFilepath,
},
},
[]*captain.Argument{
{
Name: locale.Tl("filepath", "filepath"),
Description: locale.Tl("author_upload_filepath_description", "A tar.gz or zip archive containing the source files of the ingredient."),
Value: &params.Filepath,
Required: true,
},
},
func(_ *captain.Command, _ []string) error {
return runner.Run(&params)
})
c.SetGroup(AuthorGroup)
c.SetUnstable(true)
return c
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions internal/assets/contents/usage.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Examples:
{{- end }}

{{- childCommands .Cmd}}
{{- if gt (len .Cmd.Arguments) 0}}

Arguments:
{{- range .Cmd.Arguments }}
<{{ .Name }}> {{ if .Required }} {{ else }}(optional){{ end }} {{ .Description }}
{{- end }}
{{- end }}

{{- if .Cobra.HasAvailableFlags}}

Flags:
Expand All @@ -31,13 +39,7 @@ Flags:
Global Flags:
{{.Cobra.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}
{{- end}}
{{- if gt (len .Cmd.Arguments) 0}}

Arguments:
{{- range .Cmd.Arguments }}
<{{ .Name }}> {{ if .Required }} {{ else }}(optional){{ end }} {{ .Description }}
{{- end }}
{{- end}}
{{- if .Cobra.HasHelpSubCommands}}

Additional help topics:
Expand Down
13 changes: 7 additions & 6 deletions internal/captain/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import (
"strings"

"github.com/ActiveState/cli/internal/errs"
"github.com/spf13/pflag"
)

type FlagMarshaler interface {
String() string
Set(string) error
Type() string
}
type FlagMarshaler pflag.Value

// Flag is used to define flags in our Command struct
type Flag struct {
Expand All @@ -38,6 +35,10 @@ func (c *Command) setFlags(flags []*Flag) error {
switch v := flag.Value.(type) {
case nil:
return errs.New("flag value must not be nil (%v)", flag)
case *[]string:
flagSetter().StringSliceVarP(
v, flag.Name, flag.Shorthand, *v, flag.Description,
)
case *string:
flagSetter().StringVarP(
v, flag.Name, flag.Shorthand, *v, flag.Description,
Expand All @@ -56,7 +57,7 @@ func (c *Command) setFlags(flags []*Flag) error {
)
default:
return errs.New(
fmt.Sprintf("Unknown type: %s (%v)"+reflect.TypeOf(v).Name(), v),
fmt.Sprintf("Unknown type for flag %s: %s (%v)", flag.Name, reflect.TypeOf(v).Name(), v),
)
}

Expand Down
40 changes: 0 additions & 40 deletions internal/captain/nameversion.go

This file was deleted.

Loading
Loading