diff --git a/cmd/state/internal/cmdtree/publish.go b/cmd/state/internal/cmdtree/publish.go index 526ee908b6..24c52193a1 100644 --- a/cmd/state/internal/cmdtree/publish.go +++ b/cmd/state/internal/cmdtree/publish.go @@ -46,7 +46,7 @@ func newPublish(prime *primer.Values) *captain.Command { Name: "namespace", Description: locale.Tl( "author_upload_namespace_description", - "The namespace of the ingredient. Defaults to /shared. Must start with '/'.", + "The namespace of the ingredient. Defaults to org/. Must start with 'org/'.", ), Value: ¶ms.Namespace, }, diff --git a/internal/runners/publish/publish.go b/internal/runners/publish/publish.go index 695248617d..9390134d53 100644 --- a/internal/runners/publish/publish.go +++ b/internal/runners/publish/publish.go @@ -22,7 +22,7 @@ import ( auth "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" - "github.com/machinebox/graphql" + "github.com/ActiveState/graphql" "github.com/skratchdot/open-golang/open" "gopkg.in/yaml.v3" ) @@ -107,7 +107,7 @@ func (r *Runner) Run(params *Params) error { if params.Namespace != "" { reqVars.Namespace = params.Namespace } else if reqVars.Namespace == "" && r.project != nil && r.project.Owner() != "" { - reqVars.Namespace = model.NewSharedNamespace(r.project.Owner()).String() + reqVars.Namespace = model.NewOrgNamespace(r.project.Owner()).String() } // Name diff --git a/internal/testhelpers/e2e/session.go b/internal/testhelpers/e2e/session.go index 9fbea59904..1b0b6ac870 100644 --- a/internal/testhelpers/e2e/session.go +++ b/internal/testhelpers/e2e/session.go @@ -53,7 +53,7 @@ type Session struct { createdProjects []*project.Namespaced // users created during session users []string - t *testing.T + T *testing.T Exe string SvcExe string ExecutorExe string @@ -120,24 +120,24 @@ func (s *Session) CopyExeToDir(from, to string) string { var err error to, err = filepath.Abs(filepath.Join(to, filepath.Base(from))) if err != nil { - s.t.Fatal(err) + s.T.Fatal(err) } if fileutils.TargetExists(to) { return to } err = fileutils.CopyFile(from, to) - require.NoError(s.t, err, "Could not copy %s to %s", from, to) + require.NoError(s.T, err, "Could not copy %s to %s", from, to) // Ensure modTime is the same as source exe stat, err := os.Stat(from) - require.NoError(s.t, err) + require.NoError(s.T, err) t := stat.ModTime() - require.NoError(s.t, os.Chtimes(to, t, t)) + require.NoError(s.T, os.Chtimes(to, t, t)) permissions, _ := permbits.Stat(to) permissions.SetUserExecute(true) - require.NoError(s.t, permbits.Chmod(to, permissions)) + require.NoError(s.T, permbits.Chmod(to, permissions)) return to } @@ -201,7 +201,7 @@ func new(t *testing.T, retainDirs, updatePath bool, extraEnv ...string) *Session // add session environment variables env = append(env, extraEnv...) - session := &Session{Dirs: dirs, Env: env, retainDirs: retainDirs, t: t} + session := &Session{Dirs: dirs, Env: env, retainDirs: retainDirs, T: t} // Mock installation directory exe, svcExe, execExe := executablePaths(t) @@ -210,7 +210,7 @@ func new(t *testing.T, retainDirs, updatePath bool, extraEnv ...string) *Session session.ExecutorExe = session.copyExeToBinDir(execExe) err = fileutils.Touch(filepath.Join(dirs.Base, installation.InstallDirMarker)) - require.NoError(session.t, err) + require.NoError(session.T, err) return session } @@ -281,7 +281,7 @@ func (s *Session) SpawnCmdWithOpts(exe string, opts ...SpawnOptions) *termtest.C } console, err := termtest.New(pOpts.Options) - require.NoError(s.t, err) + require.NoError(s.T, err) if !pOpts.BackgroundProcess { s.cp = console } @@ -295,7 +295,7 @@ func (s *Session) SpawnCmdWithOpts(exe string, opts ...SpawnOptions) *termtest.C // provided contents and saves the output to an as.y file within the named // directory. func (s *Session) PrepareActiveStateYAML(contents string) { - require.NoError(s.t, fileutils.WriteFile(filepath.Join(s.Dirs.Work, "activestate.yaml"), []byte(contents))) + require.NoError(s.T, fileutils.WriteFile(filepath.Join(s.Dirs.Work, "activestate.yaml"), []byte(contents))) } // PrepareFile writes a file to path with contents, expecting no error @@ -305,12 +305,12 @@ func (s *Session) PrepareFile(path, contents string) { contents = strings.TrimSpace(contents) err := os.MkdirAll(filepath.Dir(path), 0770) - require.NoError(s.t, err, errMsg) + require.NoError(s.T, err, errMsg) bs := append([]byte(contents), '\n') err = ioutil.WriteFile(path, bs, 0660) - require.NoError(s.t, err, errMsg) + require.NoError(s.T, err, errMsg) } func (s *Session) LoginUser(userName string) { @@ -345,7 +345,7 @@ func (s *Session) AddUserToCleanup(username string) { func (s *Session) CreateNewUser() *mono_models.UserEditable { uid, err := uuid.NewRandom() - require.NoError(s.t, err) + require.NoError(s.T, err) username := fmt.Sprintf("user-%s", uid.String()[0:8]) userMeta := &mono_models.UserEditable{ @@ -359,7 +359,7 @@ func (s *Session) CreateNewUser() *mono_models.UserEditable { params.SetUser(userMeta) _, err = mono.New().Users.AddUser(params) - require.NoError(s.t, err) + require.NoError(s.T, err) p := s.Spawn("auth", "--username", username, "--password", userMeta.Password) p.ExpectExitCode(0) @@ -392,7 +392,7 @@ func observeSendFn(s *Session) func(string, int, error) { return } - s.t.Fatalf("Could not send data to terminal\nerror: %v", err) + s.T.Fatalf("Could not send data to terminal\nerror: %v", err) } } @@ -428,7 +428,7 @@ func (s *Session) DebugMessage(prefix string) string { "Z": sectionEnd, }, nil) if err != nil { - s.t.Fatalf("Parsing template failed: %s", err) + s.T.Fatalf("Parsing template failed: %s", err) } return v @@ -447,7 +447,7 @@ func observeExpectFn(s *Session) expect.ExpectObserver { sep = ", " } - s.t.Fatal(s.DebugMessage(fmt.Sprintf(` + s.T.Fatal(s.DebugMessage(fmt.Sprintf(` Could not meet expectation: '%s' Error: %s`, value, err))) } @@ -462,7 +462,7 @@ func (s *Session) Close() error { } cfg, err := config.NewCustom(s.Dirs.Config, singlethread.New(), true) - require.NoError(s.t, err, "Could not read e2e session configuration: %s", errs.JoinMessage(err)) + require.NoError(s.T, err, "Could not read e2e session configuration: %s", errs.JoinMessage(err)) if !s.retainDirs { defer s.Dirs.Close() @@ -473,7 +473,7 @@ func (s *Session) Close() error { } if os.Getenv("PLATFORM_API_TOKEN") == "" { - s.t.Log("PLATFORM_API_TOKEN env var not set, not running suite tear down") + s.T.Log("PLATFORM_API_TOKEN env var not set, not running suite tear down") return nil } @@ -503,7 +503,7 @@ func (s *Session) Close() error { if runtime.GOOS == "linux" { projects, err := getProjects(org, auth) if err != nil { - s.t.Errorf("Could not fetch projects: %v", errs.JoinMessage(err)) + s.T.Errorf("Could not fetch projects: %v", errs.JoinMessage(err)) } for _, proj := range projects { if strfmt.IsUUID(proj.Name) { @@ -516,14 +516,14 @@ func (s *Session) Close() error { for _, proj := range s.createdProjects { err := model.DeleteProject(proj.Owner, proj.Project, auth) if err != nil { - s.t.Errorf("Could not delete project %s: %v", proj.Project, errs.JoinMessage(err)) + s.T.Errorf("Could not delete project %s: %v", proj.Project, errs.JoinMessage(err)) } } for _, user := range s.users { - err := cleanUser(s.t, user, auth) + err := cleanUser(s.T, user, auth) if err != nil { - s.t.Errorf("Could not delete user %s: %v", user, errs.JoinMessage(err)) + s.T.Errorf("Could not delete user %s: %v", user, errs.JoinMessage(err)) } } @@ -619,7 +619,7 @@ func (s *Session) DetectLogErrors() { rx := regexp.MustCompile(`(?:\[ERR:|Panic:)`) for _, path := range s.LogFiles() { if contents := string(fileutils.ReadFileUnsafe(path)); rx.MatchString(contents) { - s.t.Errorf("Found error and/or panic in log file %s, contents:\n%s", path, contents) + s.T.Errorf("Found error and/or panic in log file %s, contents:\n%s", path, contents) } } } diff --git a/pkg/platform/model/vcs.go b/pkg/platform/model/vcs.go index 53c72e43b7..c4dd98d2b1 100644 --- a/pkg/platform/model/vcs.go +++ b/pkg/platform/model/vcs.go @@ -82,10 +82,8 @@ const ( // NamespaceCamelFlagsMatch is the namespace used for passing camel flags NamespaceCamelFlagsMatch = `^camel-flags$` - // NamespaceSharedMatch is the namespace used for shared requirements (usually runtime libraries) - NamespaceSharedMatch = `^shared$` - - NamespaceOrgSharedMatch = `^\w+\/shared(?$|\/\w+$)` + // NamespaceOrgMatch is the namespace used for org specific requirements + NamespaceOrgMatch = `^org\/` ) type TrackingType string @@ -129,13 +127,13 @@ type NamespaceType struct { } var ( - NamespacePackage = NamespaceType{"package", "language", NamespacePackageMatch} // these values should match the namespace prefix - NamespaceBundle = NamespaceType{"bundle", "bundles", NamespaceBundlesMatch} - NamespaceLanguage = NamespaceType{"language", "", NamespaceLanguageMatch} - NamespacePlatform = NamespaceType{"platform", "", NamespacePlatformMatch} - NamespaceOrgShared = NamespaceType{"org-shared", "", NamespaceOrgSharedMatch} - NamespaceRaw = NamespaceType{"raw", "", ""} - NamespaceBlank = NamespaceType{"", "", ""} + NamespacePackage = NamespaceType{"package", "language", NamespacePackageMatch} // these values should match the namespace prefix + NamespaceBundle = NamespaceType{"bundle", "bundles", NamespaceBundlesMatch} + NamespaceLanguage = NamespaceType{"language", "", NamespaceLanguageMatch} + NamespacePlatform = NamespaceType{"platform", "", NamespacePlatformMatch} + NamespaceOrg = NamespaceType{"org", "org", NamespaceOrgMatch} + NamespaceRaw = NamespaceType{"raw", "", ""} + NamespaceBlank = NamespaceType{"", "", ""} ) func (t NamespaceType) String() string { @@ -203,10 +201,10 @@ func NewNamespacePlatform() Namespace { return Namespace{NamespacePlatform, "platform"} } -func NewSharedNamespace(orgName string) Namespace { +func NewOrgNamespace(orgName string) Namespace { return Namespace{ - nsType: NamespaceOrgShared, - value: fmt.Sprintf("%s/shared", orgName), + nsType: NamespaceOrg, + value: fmt.Sprintf("org/%s", orgName), } } diff --git a/pkg/platform/runtime/setup/buildlog/buildlog_test.go b/pkg/platform/runtime/setup/buildlog/buildlog_test.go index 11a963338d..7743722ebf 100644 --- a/pkg/platform/runtime/setup/buildlog/buildlog_test.go +++ b/pkg/platform/runtime/setup/buildlog/buildlog_test.go @@ -197,7 +197,7 @@ func TestBuildLog(t *testing.T) { cm := &connectionMock{} tt.ConnectionMock(t, cm) - bl, err := NewWithCustomConnections(artifactMap, cm, em, recipeArtifact.ArtifactID, fileutils.TempFilePathUnsafe()) + bl, err := NewWithCustomConnections(artifactMap, cm, em, recipeArtifact.ArtifactID, fileutils.TempFilePathUnsafe("", "")) require.NoError(t, err) var downloads []artifact.ArtifactID diff --git a/test/integration/publish_int_test.go b/test/integration/publish_int_test.go index f8970b6ba9..62cb9ea294 100644 --- a/test/integration/publish_int_test.go +++ b/test/integration/publish_int_test.go @@ -69,8 +69,8 @@ func (suite *PublishIntegrationTestSuite) TestPublish() { "New ingredient with file arg and flags", input{ []string{tempFile, - "--name", "im-a-name", - "--namespace", "{{.Username}}/shared", + "--name", "im-a-name-test1", + "--namespace", "org/{{.Username}}", "--version", "2.3.4", "--description", "im-a-description", "--author", "author-name ", @@ -82,8 +82,8 @@ func (suite *PublishIntegrationTestSuite) TestPublish() { expect{ []string{ `Upload following ingredient?`, - `name: im-a-name`, - `namespace: {{.Username}}/shared`, + `name: im-a-name-test1`, + `namespace: org/{{.Username}}`, `version: 2.3.4`, `description: im-a-description`, `name: author-name`, @@ -112,8 +112,8 @@ func (suite *PublishIntegrationTestSuite) TestPublish() { input{ []string{"--meta", "{{.MetaFile}}", tempFile}, ptr.To(` -name: im-a-name -namespace: {{.Username}}/shared +name: im-a-name-test2 +namespace: org/{{.Username}} version: 2.3.4 description: im-a-description authors: @@ -126,8 +126,8 @@ authors: expect{ []string{ `Upload following ingredient?`, - `name: im-a-name`, - `namespace: {{.Username}}/shared`, + `name: im-a-name-test2`, + `namespace: org/{{.Username}}`, `version: 2.3.4`, `description: im-a-description`, `name: author-name`, @@ -143,7 +143,7 @@ authors: []string{"--meta", "{{.MetaFile}}", tempFile, "--name", "im-a-name-from-flag", "--author", "author-name-from-flag "}, ptr.To(` name: im-a-name -namespace: {{.Username}}/shared +namespace: org/{{.Username}} version: 2.3.4 description: im-a-description authors: @@ -157,7 +157,7 @@ authors: []string{ `Upload following ingredient?`, `name: im-a-name-from-flag`, - `namespace: {{.Username}}/shared`, + `namespace: org/{{.Username}}`, `version: 2.3.4`, `description: im-a-description`, `name: author-name-from-flag`, @@ -173,8 +173,8 @@ authors: []string{tempFile, "--editor"}, nil, ptr.To(` -name: im-a-name -namespace: {{.Username}}/shared +name: im-a-name-test3 +namespace: org/{{.Username}} version: 2.3.4 description: im-a-description authors: @@ -186,8 +186,8 @@ authors: expect{ []string{ `Upload following ingredient?`, - `name: im-a-name`, - `namespace: {{.Username}}/shared`, + `name: im-a-name-test3`, + `namespace: org/{{.Username}}`, `version: 2.3.4`, `description: im-a-description`, `name: author-name`, @@ -200,7 +200,7 @@ authors: { "Cancel upload", input{ - []string{tempFile, "--name", "bogus", "--namespace", "{{.Username}}/shared"}, + []string{tempFile, "--name", "bogus", "--namespace", "org/{{.Username}}"}, nil, nil, false, @@ -215,6 +215,8 @@ authors: } for _, tt := range tests { suite.Run(tt.name, func() { + ts.T = suite.T() // This differs per subtest + templateVars := map[string]interface{}{ "Username": user.Username, "Email": user.Email,