configstore: move configstore types inside configstore package

Since they're not types common to all the services but belongs to the
configstore.

Next step will be to make them local to the configstore and not directly used by
other services since these types are also stored.
This commit is contained in:
Simone Gotti 2019-07-31 15:17:54 +02:00
parent d0c5621201
commit fd26e617b3
66 changed files with 312 additions and 309 deletions

View File

@ -17,8 +17,8 @@ package cmd
import ( import (
"context" "context"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -58,13 +58,13 @@ func orgCreate(cmd *cobra.Command, args []string) error {
gwclient := api.NewClient(gatewayURL, token) gwclient := api.NewClient(gatewayURL, token)
// TODO(sgotti) make this a custom pflag Value? // TODO(sgotti) make this a custom pflag Value?
if !types.IsValidVisibility(types.Visibility(orgCreateOpts.visibility)) { if !cstypes.IsValidVisibility(cstypes.Visibility(orgCreateOpts.visibility)) {
return errors.Errorf("invalid visibility %q", orgCreateOpts.visibility) return errors.Errorf("invalid visibility %q", orgCreateOpts.visibility)
} }
req := &api.CreateOrgRequest{ req := &api.CreateOrgRequest{
Name: orgCreateOpts.name, Name: orgCreateOpts.name,
Visibility: types.Visibility(orgCreateOpts.visibility), Visibility: cstypes.Visibility(orgCreateOpts.visibility),
} }
log.Infof("creating org") log.Infof("creating org")

View File

@ -17,8 +17,8 @@ package cmd
import ( import (
"context" "context"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -63,7 +63,7 @@ func orgMemberAdd(cmd *cobra.Command, args []string) error {
gwclient := api.NewClient(gatewayURL, token) gwclient := api.NewClient(gatewayURL, token)
log.Infof("adding/updating member %q to organization %q with role %q", orgMemberAddOpts.username, orgMemberAddOpts.orgname, orgMemberAddOpts.role) log.Infof("adding/updating member %q to organization %q with role %q", orgMemberAddOpts.username, orgMemberAddOpts.orgname, orgMemberAddOpts.role)
_, _, err := gwclient.AddOrgMember(context.TODO(), orgMemberAddOpts.orgname, orgMemberAddOpts.username, types.MemberRole(orgMemberAddOpts.role)) _, _, err := gwclient.AddOrgMember(context.TODO(), orgMemberAddOpts.orgname, orgMemberAddOpts.username, cstypes.MemberRole(orgMemberAddOpts.role))
if err != nil { if err != nil {
return errors.Errorf("failed to add/update organization member: %w", err) return errors.Errorf("failed to add/update organization member: %w", err)
} }

View File

@ -17,8 +17,8 @@ package cmd
import ( import (
"context" "context"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -75,14 +75,14 @@ func projectCreate(cmd *cobra.Command, args []string) error {
gwclient := api.NewClient(gatewayURL, token) gwclient := api.NewClient(gatewayURL, token)
// TODO(sgotti) make this a custom pflag Value? // TODO(sgotti) make this a custom pflag Value?
if !types.IsValidVisibility(types.Visibility(projectCreateOpts.visibility)) { if !cstypes.IsValidVisibility(cstypes.Visibility(projectCreateOpts.visibility)) {
return errors.Errorf("invalid visibility %q", projectCreateOpts.visibility) return errors.Errorf("invalid visibility %q", projectCreateOpts.visibility)
} }
req := &api.CreateProjectRequest{ req := &api.CreateProjectRequest{
Name: projectCreateOpts.name, Name: projectCreateOpts.name,
ParentRef: projectCreateOpts.parentPath, ParentRef: projectCreateOpts.parentPath,
Visibility: types.Visibility(projectCreateOpts.visibility), Visibility: cstypes.Visibility(projectCreateOpts.visibility),
RepoPath: projectCreateOpts.repoPath, RepoPath: projectCreateOpts.repoPath,
RemoteSourceName: projectCreateOpts.remoteSourceName, RemoteSourceName: projectCreateOpts.remoteSourceName,
SkipSSHHostKeyCheck: projectCreateOpts.skipSSHHostKeyCheck, SkipSSHHostKeyCheck: projectCreateOpts.skipSSHHostKeyCheck,

View File

@ -17,8 +17,8 @@ package cmd
import ( import (
"context" "context"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -63,14 +63,14 @@ func projectGroupCreate(cmd *cobra.Command, args []string) error {
gwclient := api.NewClient(gatewayURL, token) gwclient := api.NewClient(gatewayURL, token)
// TODO(sgotti) make this a custom pflag Value? // TODO(sgotti) make this a custom pflag Value?
if !types.IsValidVisibility(types.Visibility(projectCreateOpts.visibility)) { if !cstypes.IsValidVisibility(cstypes.Visibility(projectCreateOpts.visibility)) {
return errors.Errorf("invalid visibility %q", projectCreateOpts.visibility) return errors.Errorf("invalid visibility %q", projectCreateOpts.visibility)
} }
req := &api.CreateProjectGroupRequest{ req := &api.CreateProjectGroupRequest{
Name: projectGroupCreateOpts.name, Name: projectGroupCreateOpts.name,
ParentRef: projectGroupCreateOpts.parentPath, ParentRef: projectGroupCreateOpts.parentPath,
Visibility: types.Visibility(projectCreateOpts.visibility), Visibility: cstypes.Visibility(projectCreateOpts.visibility),
} }
log.Infof("creating project group") log.Infof("creating project group")

View File

@ -19,8 +19,8 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -96,7 +96,7 @@ func secretCreate(cmd *cobra.Command, ownertype string, args []string) error {
} }
req := &api.CreateSecretRequest{ req := &api.CreateSecretRequest{
Name: secretCreateOpts.name, Name: secretCreateOpts.name,
Type: types.SecretTypeInternal, Type: cstypes.SecretTypeInternal,
Data: secretData, Data: secretData,
} }

View File

@ -19,8 +19,8 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -98,7 +98,7 @@ func secretUpdate(cmd *cobra.Command, ownertype string, args []string) error {
} }
req := &api.UpdateSecretRequest{ req := &api.UpdateSecretRequest{
Name: secretUpdateOpts.name, Name: secretUpdateOpts.name,
Type: types.SecretTypeInternal, Type: cstypes.SecretTypeInternal,
Data: secretData, Data: secretData,
} }

View File

@ -20,8 +20,8 @@ import (
"os" "os"
"agola.io/agola/internal/config" "agola.io/agola/internal/config"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -117,12 +117,12 @@ func variableCreate(cmd *cobra.Command, ownertype string, args []string) error {
if err := yaml.Unmarshal(data, &values); err != nil { if err := yaml.Unmarshal(data, &values); err != nil {
log.Fatalf("failed to unmarshal values: %v", err) log.Fatalf("failed to unmarshal values: %v", err)
} }
rvalues := []types.VariableValue{} rvalues := []cstypes.VariableValue{}
for _, value := range values { for _, value := range values {
rvalues = append(rvalues, types.VariableValue{ rvalues = append(rvalues, cstypes.VariableValue{
SecretName: value.SecretName, SecretName: value.SecretName,
SecretVar: value.SecretVar, SecretVar: value.SecretVar,
When: (*types.When)(value.When), When: (*cstypes.When)(value.When),
}) })
} }
req := &api.CreateVariableRequest{ req := &api.CreateVariableRequest{

View File

@ -19,8 +19,8 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -89,12 +89,12 @@ func variableUpdate(cmd *cobra.Command, ownertype string, args []string) error {
if err := yaml.Unmarshal(data, &values); err != nil { if err := yaml.Unmarshal(data, &values); err != nil {
log.Fatalf("failed to unmarshall values: %v", err) log.Fatalf("failed to unmarshall values: %v", err)
} }
rvalues := []types.VariableValue{} rvalues := []cstypes.VariableValue{}
for _, value := range values { for _, value := range values {
rvalues = append(rvalues, types.VariableValue{ rvalues = append(rvalues, cstypes.VariableValue{
SecretName: value.SecretName, SecretName: value.SecretName,
SecretVar: value.SecretVar, SecretVar: value.SecretVar,
When: (*types.When)(value.When), When: (*cstypes.When)(value.When),
}) })
} }
req := &api.UpdateVariableRequest{ req := &api.UpdateVariableRequest{

View File

@ -18,8 +18,8 @@ import (
"context" "context"
"agola.io/agola/internal/gitsources/github" "agola.io/agola/internal/gitsources/github"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/api" "agola.io/agola/internal/services/gateway/api"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -84,7 +84,7 @@ func remoteSourceCreate(cmd *cobra.Command, args []string) error {
gwclient := api.NewClient(gatewayURL, token) gwclient := api.NewClient(gatewayURL, token)
// for github remote source type, set defaults for github.com // for github remote source type, set defaults for github.com
if remoteSourceCreateOpts.rsType == string(types.RemoteSourceTypeGithub) { if remoteSourceCreateOpts.rsType == string(cstypes.RemoteSourceTypeGithub) {
remoteSourceCreateOpts.apiURL = github.GitHubAPIURL remoteSourceCreateOpts.apiURL = github.GitHubAPIURL
remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey
} }

View File

@ -21,7 +21,7 @@ import (
"strings" "strings"
"agola.io/agola/internal/common" "agola.io/agola/internal/common"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
@ -445,7 +445,7 @@ func (val *Value) UnmarshalJSON(b []byte) error {
return nil return nil
} }
type When types.When type When cstypes.When
type when struct { type when struct {
Branch interface{} `json:"branch"` Branch interface{} `json:"branch"`
@ -485,8 +485,8 @@ func (w *When) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func parseWhenConditions(wi interface{}) (*types.WhenConditions, error) { func parseWhenConditions(wi interface{}) (*cstypes.WhenConditions, error) {
w := &types.WhenConditions{} w := &cstypes.WhenConditions{}
var err error var err error
include := []string{} include := []string{}
@ -534,12 +534,12 @@ func parseWhenConditions(wi interface{}) (*types.WhenConditions, error) {
return w, nil return w, nil
} }
func parseWhenConditionSlice(conds []string) ([]types.WhenCondition, error) { func parseWhenConditionSlice(conds []string) ([]cstypes.WhenCondition, error) {
if len(conds) == 0 { if len(conds) == 0 {
return nil, nil return nil, nil
} }
wcs := []types.WhenCondition{} wcs := []cstypes.WhenCondition{}
for _, cond := range conds { for _, cond := range conds {
wc, err := parseWhenCondition(cond) wc, err := parseWhenCondition(cond)
if err != nil { if err != nil {
@ -551,7 +551,7 @@ func parseWhenConditionSlice(conds []string) ([]types.WhenCondition, error) {
return wcs, nil return wcs, nil
} }
func parseWhenCondition(s string) (*types.WhenCondition, error) { func parseWhenCondition(s string) (*cstypes.WhenCondition, error) {
isRegExp := false isRegExp := false
if len(s) > 2 { if len(s) > 2 {
for _, d := range regExpDelimiters { for _, d := range regExpDelimiters {
@ -563,15 +563,15 @@ func parseWhenCondition(s string) (*types.WhenCondition, error) {
} }
} }
wc := &types.WhenCondition{Match: s} wc := &cstypes.WhenCondition{Match: s}
if isRegExp { if isRegExp {
if _, err := regexp.Compile(s); err != nil { if _, err := regexp.Compile(s); err != nil {
return nil, errors.Errorf("wrong regular expression: %w", err) return nil, errors.Errorf("wrong regular expression: %w", err)
} }
wc.Type = types.WhenConditionTypeRegExp wc.Type = cstypes.WhenConditionTypeRegExp
} else { } else {
wc.Type = types.WhenConditionTypeSimple wc.Type = cstypes.WhenConditionTypeSimple
} }
return wc, nil return wc, nil
} }

View File

@ -18,7 +18,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"

View File

@ -19,8 +19,8 @@ import (
"strings" "strings"
"agola.io/agola/internal/config" "agola.io/agola/internal/config"
cstypes "agola.io/agola/internal/services/configstore/types"
rstypes "agola.io/agola/internal/services/runservice/types" rstypes "agola.io/agola/internal/services/runservice/types"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -48,11 +48,11 @@ func genRuntime(c *config.Config, ce *config.Runtime, variables map[string]strin
} }
} }
func whenFromConfigWhen(cw *config.When) *types.When { func whenFromConfigWhen(cw *config.When) *cstypes.When {
if cw == nil { if cw == nil {
return nil return nil
} }
return &types.When{ return &cstypes.When{
Branch: cw.Branch, Branch: cw.Branch,
Tag: cw.Tag, Tag: cw.Tag,
Ref: cw.Ref, Ref: cw.Ref,
@ -194,7 +194,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string
rcts := map[string]*rstypes.RunConfigTask{} rcts := map[string]*rstypes.RunConfigTask{}
for _, ct := range cr.Tasks { for _, ct := range cr.Tasks {
include := types.MatchWhen(whenFromConfigWhen(ct.When), branch, tag, ref) include := cstypes.MatchWhen(whenFromConfigWhen(ct.When), branch, tag, ref)
steps := make(rstypes.Steps, len(ct.Steps)) steps := make(rstypes.Steps, len(ct.Steps))
for i, cpts := range ct.Steps { for i, cpts := range ct.Steps {

View File

@ -20,8 +20,8 @@ import (
"testing" "testing"
"agola.io/agola/internal/config" "agola.io/agola/internal/config"
cstypes "agola.io/agola/internal/services/configstore/types"
rstypes "agola.io/agola/internal/services/runservice/types" rstypes "agola.io/agola/internal/services/runservice/types"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
@ -706,11 +706,11 @@ func TestGenRunConfig(t *testing.T) {
IgnoreFailure: false, IgnoreFailure: false,
Approval: false, Approval: false,
When: &config.When{ When: &config.When{
Branch: &types.WhenConditions{Include: []types.WhenCondition{{Match: "master"}}}, Branch: &cstypes.WhenConditions{Include: []cstypes.WhenCondition{{Match: "master"}}},
Tag: &types.WhenConditions{Include: []types.WhenCondition{{Match: "v1.x"}, {Match: "v2.x"}}}, Tag: &cstypes.WhenConditions{Include: []cstypes.WhenCondition{{Match: "v1.x"}, {Match: "v2.x"}}},
Ref: &types.WhenConditions{ Ref: &cstypes.WhenConditions{
Include: []types.WhenCondition{{Match: "master"}}, Include: []cstypes.WhenCondition{{Match: "master"}},
Exclude: []types.WhenCondition{{Match: "branch01", Type: types.WhenConditionTypeRegExp}, {Match: "branch02"}}, Exclude: []cstypes.WhenCondition{{Match: "branch01", Type: cstypes.WhenConditionTypeRegExp}, {Match: "branch02"}},
}, },
}, },
}, },

View File

@ -19,12 +19,12 @@ import (
"agola.io/agola/internal/gitsources/gitea" "agola.io/agola/internal/gitsources/gitea"
"agola.io/agola/internal/gitsources/github" "agola.io/agola/internal/gitsources/github"
"agola.io/agola/internal/gitsources/gitlab" "agola.io/agola/internal/gitsources/gitlab"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
func newGitea(rs *types.RemoteSource, accessToken string) (*gitea.Client, error) { func newGitea(rs *cstypes.RemoteSource, accessToken string) (*gitea.Client, error) {
return gitea.New(gitea.Opts{ return gitea.New(gitea.Opts{
APIURL: rs.APIURL, APIURL: rs.APIURL,
SkipVerify: rs.SkipVerify, SkipVerify: rs.SkipVerify,
@ -34,7 +34,7 @@ func newGitea(rs *types.RemoteSource, accessToken string) (*gitea.Client, error)
}) })
} }
func newGitlab(rs *types.RemoteSource, accessToken string) (*gitlab.Client, error) { func newGitlab(rs *cstypes.RemoteSource, accessToken string) (*gitlab.Client, error) {
return gitlab.New(gitlab.Opts{ return gitlab.New(gitlab.Opts{
APIURL: rs.APIURL, APIURL: rs.APIURL,
SkipVerify: rs.SkipVerify, SkipVerify: rs.SkipVerify,
@ -44,7 +44,7 @@ func newGitlab(rs *types.RemoteSource, accessToken string) (*gitlab.Client, erro
}) })
} }
func newGithub(rs *types.RemoteSource, accessToken string) (*github.Client, error) { func newGithub(rs *cstypes.RemoteSource, accessToken string) (*github.Client, error) {
return github.New(github.Opts{ return github.New(github.Opts{
APIURL: rs.APIURL, APIURL: rs.APIURL,
SkipVerify: rs.SkipVerify, SkipVerify: rs.SkipVerify,
@ -54,18 +54,18 @@ func newGithub(rs *types.RemoteSource, accessToken string) (*github.Client, erro
}) })
} }
func GetAccessToken(rs *types.RemoteSource, userAccessToken, oauth2AccessToken string) (string, error) { func GetAccessToken(rs *cstypes.RemoteSource, userAccessToken, oauth2AccessToken string) (string, error) {
switch rs.AuthType { switch rs.AuthType {
case types.RemoteSourceAuthTypePassword: case cstypes.RemoteSourceAuthTypePassword:
return userAccessToken, nil return userAccessToken, nil
case types.RemoteSourceAuthTypeOauth2: case cstypes.RemoteSourceAuthTypeOauth2:
return oauth2AccessToken, nil return oauth2AccessToken, nil
default: default:
return "", errors.Errorf("invalid remote source auth type %q", rs.AuthType) return "", errors.Errorf("invalid remote source auth type %q", rs.AuthType)
} }
} }
func GetGitSource(rs *types.RemoteSource, la *types.LinkedAccount) (gitsource.GitSource, error) { func GetGitSource(rs *cstypes.RemoteSource, la *cstypes.LinkedAccount) (gitsource.GitSource, error) {
var accessToken string var accessToken string
if la != nil { if la != nil {
var err error var err error
@ -78,11 +78,11 @@ func GetGitSource(rs *types.RemoteSource, la *types.LinkedAccount) (gitsource.Gi
var gitSource gitsource.GitSource var gitSource gitsource.GitSource
var err error var err error
switch rs.Type { switch rs.Type {
case types.RemoteSourceTypeGitea: case cstypes.RemoteSourceTypeGitea:
gitSource, err = newGitea(rs, accessToken) gitSource, err = newGitea(rs, accessToken)
case types.RemoteSourceTypeGitlab: case cstypes.RemoteSourceTypeGitlab:
gitSource, err = newGitlab(rs, accessToken) gitSource, err = newGitlab(rs, accessToken)
case types.RemoteSourceTypeGithub: case cstypes.RemoteSourceTypeGithub:
gitSource, err = newGithub(rs, accessToken) gitSource, err = newGithub(rs, accessToken)
default: default:
return nil, errors.Errorf("remote source %s isn't a valid git source", rs.Name) return nil, errors.Errorf("remote source %s isn't a valid git source", rs.Name)
@ -91,13 +91,13 @@ func GetGitSource(rs *types.RemoteSource, la *types.LinkedAccount) (gitsource.Gi
return gitSource, err return gitSource, err
} }
func GetUserSource(rs *types.RemoteSource, accessToken string) (gitsource.UserSource, error) { func GetUserSource(rs *cstypes.RemoteSource, accessToken string) (gitsource.UserSource, error) {
var userSource gitsource.UserSource var userSource gitsource.UserSource
var err error var err error
switch rs.AuthType { switch rs.AuthType {
case types.RemoteSourceAuthTypeOauth2: case cstypes.RemoteSourceAuthTypeOauth2:
userSource, err = GetOauth2Source(rs, accessToken) userSource, err = GetOauth2Source(rs, accessToken)
case types.RemoteSourceAuthTypePassword: case cstypes.RemoteSourceAuthTypePassword:
userSource, err = GetPasswordSource(rs, accessToken) userSource, err = GetPasswordSource(rs, accessToken)
default: default:
return nil, errors.Errorf("unknown remote source auth type") return nil, errors.Errorf("unknown remote source auth type")
@ -106,15 +106,15 @@ func GetUserSource(rs *types.RemoteSource, accessToken string) (gitsource.UserSo
return userSource, err return userSource, err
} }
func GetOauth2Source(rs *types.RemoteSource, accessToken string) (gitsource.Oauth2Source, error) { func GetOauth2Source(rs *cstypes.RemoteSource, accessToken string) (gitsource.Oauth2Source, error) {
var oauth2Source gitsource.Oauth2Source var oauth2Source gitsource.Oauth2Source
var err error var err error
switch rs.Type { switch rs.Type {
case types.RemoteSourceTypeGitea: case cstypes.RemoteSourceTypeGitea:
oauth2Source, err = newGitea(rs, accessToken) oauth2Source, err = newGitea(rs, accessToken)
case types.RemoteSourceTypeGitlab: case cstypes.RemoteSourceTypeGitlab:
oauth2Source, err = newGitlab(rs, accessToken) oauth2Source, err = newGitlab(rs, accessToken)
case types.RemoteSourceTypeGithub: case cstypes.RemoteSourceTypeGithub:
oauth2Source, err = newGithub(rs, accessToken) oauth2Source, err = newGithub(rs, accessToken)
default: default:
return nil, errors.Errorf("remote source %s isn't a valid oauth2 source", rs.Name) return nil, errors.Errorf("remote source %s isn't a valid oauth2 source", rs.Name)
@ -123,11 +123,11 @@ func GetOauth2Source(rs *types.RemoteSource, accessToken string) (gitsource.Oaut
return oauth2Source, err return oauth2Source, err
} }
func GetPasswordSource(rs *types.RemoteSource, accessToken string) (gitsource.PasswordSource, error) { func GetPasswordSource(rs *cstypes.RemoteSource, accessToken string) (gitsource.PasswordSource, error) {
var passwordSource gitsource.PasswordSource var passwordSource gitsource.PasswordSource
var err error var err error
switch rs.Type { switch rs.Type {
case types.RemoteSourceTypeGitea: case cstypes.RemoteSourceTypeGitea:
passwordSource, err = newGitea(rs, accessToken) passwordSource, err = newGitea(rs, accessToken)
default: default:
return nil, errors.Errorf("remote source %s isn't a valid oauth2 source", rs.Name) return nil, errors.Errorf("remote source %s isn't a valid oauth2 source", rs.Name)

View File

@ -16,7 +16,7 @@ package common
import ( import (
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
) )
@ -43,7 +43,7 @@ func FilterOverriddenVariables(variables []*csapi.Variable) []*csapi.Variable {
return filteredVariables return filteredVariables
} }
func GetVarValueMatchingSecret(varval types.VariableValue, varParentPath string, secrets []*csapi.Secret) *csapi.Secret { func GetVarValueMatchingSecret(varval cstypes.VariableValue, varParentPath string, secrets []*csapi.Secret) *csapi.Secret {
// get the secret value referenced by the variable, it must be a secret at the same level or a lower level // get the secret value referenced by the variable, it must be a secret at the same level or a lower level
var secret *csapi.Secret var secret *csapi.Secret
for _, s := range secrets { for _, s := range secrets {

View File

@ -18,7 +18,7 @@ import (
"testing" "testing"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
) )
@ -39,37 +39,37 @@ func TestFilterOverriddenVariables(t *testing.T) {
// variables must be in depth (from leaves to root) order as returned by the // variables must be in depth (from leaves to root) order as returned by the
// configstore apis // configstore apis
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var04", Name: "var04",
}, },
ParentPath: "org/org01/projectgroup02/projectgroup03/project02", ParentPath: "org/org01/projectgroup02/projectgroup03/project02",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var03", Name: "var03",
}, },
ParentPath: "org/org01/projectgroup01/project01", ParentPath: "org/org01/projectgroup01/project01",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var02", Name: "var02",
}, },
ParentPath: "org/org01/projectgroup01/project01", ParentPath: "org/org01/projectgroup01/project01",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var02", Name: "var02",
}, },
ParentPath: "org/org01/projectgroup01", ParentPath: "org/org01/projectgroup01",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var01", Name: "var01",
}, },
ParentPath: "org/org01/projectgroup01", ParentPath: "org/org01/projectgroup01",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var01", Name: "var01",
}, },
ParentPath: "org/org01", ParentPath: "org/org01",
@ -77,25 +77,25 @@ func TestFilterOverriddenVariables(t *testing.T) {
}, },
out: []*csapi.Variable{ out: []*csapi.Variable{
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var04", Name: "var04",
}, },
ParentPath: "org/org01/projectgroup02/projectgroup03/project02", ParentPath: "org/org01/projectgroup02/projectgroup03/project02",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var03", Name: "var03",
}, },
ParentPath: "org/org01/projectgroup01/project01", ParentPath: "org/org01/projectgroup01/project01",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var02", Name: "var02",
}, },
ParentPath: "org/org01/projectgroup01/project01", ParentPath: "org/org01/projectgroup01/project01",
}, },
&csapi.Variable{ &csapi.Variable{
Variable: &types.Variable{ Variable: &cstypes.Variable{
Name: "var01", Name: "var01",
}, },
ParentPath: "org/org01/projectgroup01", ParentPath: "org/org01/projectgroup01",
@ -118,14 +118,14 @@ func TestFilterOverriddenVariables(t *testing.T) {
func TestGetVarValueMatchingSecret(t *testing.T) { func TestGetVarValueMatchingSecret(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
varValue types.VariableValue varValue cstypes.VariableValue
varParentPath string varParentPath string
secrets []*csapi.Secret secrets []*csapi.Secret
out *csapi.Secret out *csapi.Secret
}{ }{
{ {
name: "test empty secrets", name: "test empty secrets",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
@ -135,14 +135,14 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
}, },
{ {
name: "test secret with different name", name: "test secret with different name",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
varParentPath: "org/org01/projectgroup01/projectgroup02", varParentPath: "org/org01/projectgroup01/projectgroup02",
secrets: []*csapi.Secret{ secrets: []*csapi.Secret{
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret02", Name: "secret02",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02", ParentPath: "org/org01/projectgroup01/projectgroup02",
@ -152,14 +152,14 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
}, },
{ {
name: "test secret with tree", name: "test secret with tree",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
varParentPath: "org/org01/projectgroup01/projectgroup02", varParentPath: "org/org01/projectgroup01/projectgroup02",
secrets: []*csapi.Secret{ secrets: []*csapi.Secret{
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret02", Name: "secret02",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup03", ParentPath: "org/org01/projectgroup01/projectgroup03",
@ -169,14 +169,14 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
}, },
{ {
name: "test secret in child of variable parent", name: "test secret in child of variable parent",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
varParentPath: "org/org01/projectgroup01/projectgroup02", varParentPath: "org/org01/projectgroup01/projectgroup02",
secrets: []*csapi.Secret{ secrets: []*csapi.Secret{
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02/project01", ParentPath: "org/org01/projectgroup01/projectgroup02/project01",
@ -186,27 +186,27 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
}, },
{ {
name: "test secret in same parent and also child of variable parent", name: "test secret in same parent and also child of variable parent",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
varParentPath: "org/org01/projectgroup01/projectgroup02", varParentPath: "org/org01/projectgroup01/projectgroup02",
secrets: []*csapi.Secret{ secrets: []*csapi.Secret{
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02/project01", ParentPath: "org/org01/projectgroup01/projectgroup02/project01",
}, },
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02", ParentPath: "org/org01/projectgroup01/projectgroup02",
}, },
}, },
out: &csapi.Secret{ out: &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02", ParentPath: "org/org01/projectgroup01/projectgroup02",
@ -214,21 +214,21 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
}, },
{ {
name: "test secret in parent", name: "test secret in parent",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
varParentPath: "org/org01/projectgroup01/projectgroup02", varParentPath: "org/org01/projectgroup01/projectgroup02",
secrets: []*csapi.Secret{ secrets: []*csapi.Secret{
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01", ParentPath: "org/org01/projectgroup01",
}, },
}, },
out: &csapi.Secret{ out: &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01", ParentPath: "org/org01/projectgroup01",
@ -236,7 +236,7 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
}, },
{ {
name: "test multiple secrets in same branch and also child of variable parent", name: "test multiple secrets in same branch and also child of variable parent",
varValue: types.VariableValue{ varValue: cstypes.VariableValue{
SecretName: "secret01", SecretName: "secret01",
SecretVar: "secretvar01", SecretVar: "secretvar01",
}, },
@ -245,26 +245,26 @@ func TestGetVarValueMatchingSecret(t *testing.T) {
// secrets must be in depth (from leaves to root) order as returned by the // secrets must be in depth (from leaves to root) order as returned by the
// configstore apis // configstore apis
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02/project01", ParentPath: "org/org01/projectgroup01/projectgroup02/project01",
}, },
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02", ParentPath: "org/org01/projectgroup01/projectgroup02",
}, },
&csapi.Secret{ &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01", ParentPath: "org/org01/projectgroup01",
}, },
}, },
out: &csapi.Secret{ out: &csapi.Secret{
Secret: &types.Secret{ Secret: &cstypes.Secret{
Name: "secret01", Name: "secret01",
}, },
ParentPath: "org/org01/projectgroup01/projectgroup02", ParentPath: "org/org01/projectgroup01/projectgroup02",

View File

@ -23,7 +23,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -21,7 +21,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -21,7 +21,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -20,7 +20,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -20,7 +20,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -22,7 +22,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -20,7 +20,7 @@ import (
"agola.io/agola/internal/datamanager" "agola.io/agola/internal/datamanager"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -19,7 +19,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"

View File

@ -26,7 +26,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )

View File

@ -22,7 +22,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/action" "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"

View File

@ -24,7 +24,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/action" "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"

View File

@ -24,7 +24,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/action" "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"

View File

@ -22,7 +22,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/action" "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"

View File

@ -21,7 +21,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/action" "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"

View File

@ -23,7 +23,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
action "agola.io/agola/internal/services/configstore/action" action "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"

View File

@ -21,7 +21,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/action" "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"

View File

@ -32,7 +32,7 @@ import (
"agola.io/agola/internal/services/configstore/api" "agola.io/agola/internal/services/configstore/api"
"agola.io/agola/internal/services/configstore/common" "agola.io/agola/internal/services/configstore/common"
"agola.io/agola/internal/services/configstore/readdb" "agola.io/agola/internal/services/configstore/readdb"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"

View File

@ -30,7 +30,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/config" "agola.io/agola/internal/services/config"
action "agola.io/agola/internal/services/configstore/action" action "agola.io/agola/internal/services/configstore/action"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/testutil" "agola.io/agola/internal/testutil"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"

View File

@ -20,7 +20,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/common" "agola.io/agola/internal/services/configstore/common"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -22,7 +22,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/common" "agola.io/agola/internal/services/configstore/common"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -22,7 +22,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/common" "agola.io/agola/internal/services/configstore/common"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -30,7 +30,7 @@ import (
"agola.io/agola/internal/objectstorage" "agola.io/agola/internal/objectstorage"
ostypes "agola.io/agola/internal/objectstorage/types" ostypes "agola.io/agola/internal/objectstorage/types"
"agola.io/agola/internal/sequence" "agola.io/agola/internal/sequence"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -21,7 +21,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/common" "agola.io/agola/internal/services/configstore/common"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -18,7 +18,7 @@ import (
"path" "path"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )

View File

@ -19,7 +19,7 @@ import (
"encoding/json" "encoding/json"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -20,7 +20,7 @@ import (
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/configstore/common" "agola.io/agola/internal/services/configstore/common"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -19,7 +19,7 @@ import (
"encoding/json" "encoding/json"
"agola.io/agola/internal/db" "agola.io/agola/internal/db"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"agola.io/agola/internal/services/common" "agola.io/agola/internal/services/common"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
@ -68,7 +68,7 @@ func (h *ActionHandler) IsOrgOwner(ctx context.Context, orgID string) (bool, err
if userOrg.Organization.ID != orgID { if userOrg.Organization.ID != orgID {
continue continue
} }
if userOrg.Role == types.MemberRoleOwner { if userOrg.Role == cstypes.MemberRoleOwner {
return true, nil return true, nil
} }
} }
@ -76,7 +76,7 @@ func (h *ActionHandler) IsOrgOwner(ctx context.Context, orgID string) (bool, err
return false, nil return false, nil
} }
func (h *ActionHandler) IsProjectOwner(ctx context.Context, ownerType types.ConfigType, ownerID string) (bool, error) { func (h *ActionHandler) IsProjectOwner(ctx context.Context, ownerType cstypes.ConfigType, ownerID string) (bool, error) {
isAdmin := h.IsUserAdmin(ctx) isAdmin := h.IsUserAdmin(ctx)
if isAdmin { if isAdmin {
return true, nil return true, nil
@ -87,13 +87,13 @@ func (h *ActionHandler) IsProjectOwner(ctx context.Context, ownerType types.Conf
return false, nil return false, nil
} }
if ownerType == types.ConfigTypeUser { if ownerType == cstypes.ConfigTypeUser {
if userID == ownerID { if userID == ownerID {
return true, nil return true, nil
} }
} }
if ownerType == types.ConfigTypeOrg { if ownerType == cstypes.ConfigTypeOrg {
userOrgs, resp, err := h.configstoreClient.GetUserOrgs(ctx, userID) userOrgs, resp, err := h.configstoreClient.GetUserOrgs(ctx, userID)
if err != nil { if err != nil {
return false, errors.Errorf("failed to get user orgs: %w", ErrFromRemote(resp, err)) return false, errors.Errorf("failed to get user orgs: %w", ErrFromRemote(resp, err))
@ -103,7 +103,7 @@ func (h *ActionHandler) IsProjectOwner(ctx context.Context, ownerType types.Conf
if userOrg.Organization.ID != ownerID { if userOrg.Organization.ID != ownerID {
continue continue
} }
if userOrg.Role == types.MemberRoleOwner { if userOrg.Role == cstypes.MemberRoleOwner {
return true, nil return true, nil
} }
} }
@ -112,7 +112,7 @@ func (h *ActionHandler) IsProjectOwner(ctx context.Context, ownerType types.Conf
return false, nil return false, nil
} }
func (h *ActionHandler) IsProjectMember(ctx context.Context, ownerType types.ConfigType, ownerID string) (bool, error) { func (h *ActionHandler) IsProjectMember(ctx context.Context, ownerType cstypes.ConfigType, ownerID string) (bool, error) {
isAdmin := h.IsUserAdmin(ctx) isAdmin := h.IsUserAdmin(ctx)
if isAdmin { if isAdmin {
return true, nil return true, nil
@ -123,13 +123,13 @@ func (h *ActionHandler) IsProjectMember(ctx context.Context, ownerType types.Con
return false, nil return false, nil
} }
if ownerType == types.ConfigTypeUser { if ownerType == cstypes.ConfigTypeUser {
if userID == ownerID { if userID == ownerID {
return true, nil return true, nil
} }
} }
if ownerType == types.ConfigTypeOrg { if ownerType == cstypes.ConfigTypeOrg {
userOrgs, resp, err := h.configstoreClient.GetUserOrgs(ctx, userID) userOrgs, resp, err := h.configstoreClient.GetUserOrgs(ctx, userID)
if err != nil { if err != nil {
return false, errors.Errorf("failed to get user orgs: %w", ErrFromRemote(resp, err)) return false, errors.Errorf("failed to get user orgs: %w", ErrFromRemote(resp, err))
@ -146,18 +146,18 @@ func (h *ActionHandler) IsProjectMember(ctx context.Context, ownerType types.Con
return false, nil return false, nil
} }
func (h *ActionHandler) IsVariableOwner(ctx context.Context, parentType types.ConfigType, parentRef string) (bool, error) { func (h *ActionHandler) IsVariableOwner(ctx context.Context, parentType cstypes.ConfigType, parentRef string) (bool, error) {
var ownerType types.ConfigType var ownerType cstypes.ConfigType
var ownerID string var ownerID string
switch parentType { switch parentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
pg, resp, err := h.configstoreClient.GetProjectGroup(ctx, parentRef) pg, resp, err := h.configstoreClient.GetProjectGroup(ctx, parentRef)
if err != nil { if err != nil {
return false, errors.Errorf("failed to get project group %q: %w", parentRef, ErrFromRemote(resp, err)) return false, errors.Errorf("failed to get project group %q: %w", parentRef, ErrFromRemote(resp, err))
} }
ownerType = pg.OwnerType ownerType = pg.OwnerType
ownerID = pg.OwnerID ownerID = pg.OwnerID
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
p, resp, err := h.configstoreClient.GetProject(ctx, parentRef) p, resp, err := h.configstoreClient.GetProject(ctx, parentRef)
if err != nil { if err != nil {
return false, errors.Errorf("failed to get project %q: %w", parentRef, ErrFromRemote(resp, err)) return false, errors.Errorf("failed to get project %q: %w", parentRef, ErrFromRemote(resp, err))
@ -175,8 +175,8 @@ func (h *ActionHandler) CanGetRun(ctx context.Context, runGroup string) (bool, e
return false, err return false, err
} }
var visibility types.Visibility var visibility cstypes.Visibility
var ownerType types.ConfigType var ownerType cstypes.ConfigType
var ownerID string var ownerID string
switch groupType { switch groupType {
case common.GroupTypeProject: case common.GroupTypeProject:
@ -189,12 +189,12 @@ func (h *ActionHandler) CanGetRun(ctx context.Context, runGroup string) (bool, e
visibility = p.GlobalVisibility visibility = p.GlobalVisibility
case common.GroupTypeUser: case common.GroupTypeUser:
// user direct runs // user direct runs
ownerType = types.ConfigTypeUser ownerType = cstypes.ConfigTypeUser
ownerID = groupID ownerID = groupID
visibility = types.VisibilityPrivate visibility = cstypes.VisibilityPrivate
} }
if visibility == types.VisibilityPublic { if visibility == cstypes.VisibilityPublic {
return true, nil return true, nil
} }
isProjectMember, err := h.IsProjectMember(ctx, ownerType, ownerID) isProjectMember, err := h.IsProjectMember(ctx, ownerType, ownerID)
@ -213,7 +213,7 @@ func (h *ActionHandler) CanDoRunActions(ctx context.Context, runGroup string) (b
return false, err return false, err
} }
var ownerType types.ConfigType var ownerType cstypes.ConfigType
var ownerID string var ownerID string
switch groupType { switch groupType {
case common.GroupTypeProject: case common.GroupTypeProject:
@ -225,7 +225,7 @@ func (h *ActionHandler) CanDoRunActions(ctx context.Context, runGroup string) (b
ownerID = p.OwnerID ownerID = p.OwnerID
case common.GroupTypeUser: case common.GroupTypeUser:
// user direct runs // user direct runs
ownerType = types.ConfigTypeUser ownerType = cstypes.ConfigTypeUser
ownerID = groupID ownerID = groupID
} }

View File

@ -17,13 +17,13 @@ package action
import ( import (
"context" "context"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
func (h *ActionHandler) GetOrg(ctx context.Context, orgRef string) (*types.Organization, error) { func (h *ActionHandler) GetOrg(ctx context.Context, orgRef string) (*cstypes.Organization, error) {
org, resp, err := h.configstoreClient.GetOrg(ctx, orgRef) org, resp, err := h.configstoreClient.GetOrg(ctx, orgRef)
if err != nil { if err != nil {
return nil, ErrFromRemote(resp, err) return nil, ErrFromRemote(resp, err)
@ -37,7 +37,7 @@ type GetOrgsRequest struct {
Asc bool Asc bool
} }
func (h *ActionHandler) GetOrgs(ctx context.Context, req *GetOrgsRequest) ([]*types.Organization, error) { func (h *ActionHandler) GetOrgs(ctx context.Context, req *GetOrgsRequest) ([]*cstypes.Organization, error) {
orgs, resp, err := h.configstoreClient.GetOrgs(ctx, req.Start, req.Limit, req.Asc) orgs, resp, err := h.configstoreClient.GetOrgs(ctx, req.Start, req.Limit, req.Asc)
if err != nil { if err != nil {
return nil, ErrFromRemote(resp, err) return nil, ErrFromRemote(resp, err)
@ -46,13 +46,13 @@ func (h *ActionHandler) GetOrgs(ctx context.Context, req *GetOrgsRequest) ([]*ty
} }
type OrgMembersResponse struct { type OrgMembersResponse struct {
Organization *types.Organization Organization *cstypes.Organization
Members []*OrgMemberResponse Members []*OrgMemberResponse
} }
type OrgMemberResponse struct { type OrgMemberResponse struct {
User *types.User User *cstypes.User
Role types.MemberRole Role cstypes.MemberRole
} }
func (h *ActionHandler) GetOrgMembers(ctx context.Context, orgRef string) (*OrgMembersResponse, error) { func (h *ActionHandler) GetOrgMembers(ctx context.Context, orgRef string) (*OrgMembersResponse, error) {
@ -81,12 +81,12 @@ func (h *ActionHandler) GetOrgMembers(ctx context.Context, orgRef string) (*OrgM
type CreateOrgRequest struct { type CreateOrgRequest struct {
Name string Name string
Visibility types.Visibility Visibility cstypes.Visibility
CreatorUserID string CreatorUserID string
} }
func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*types.Organization, error) { func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*cstypes.Organization, error) {
if !h.IsUserLoggedOrAdmin(ctx) { if !h.IsUserLoggedOrAdmin(ctx) {
return nil, errors.Errorf("user not logged in") return nil, errors.Errorf("user not logged in")
} }
@ -98,7 +98,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*
return nil, util.NewErrBadRequest(errors.Errorf("invalid organization name %q", req.Name)) return nil, util.NewErrBadRequest(errors.Errorf("invalid organization name %q", req.Name))
} }
org := &types.Organization{ org := &cstypes.Organization{
Name: req.Name, Name: req.Name,
Visibility: req.Visibility, Visibility: req.Visibility,
} }
@ -138,12 +138,12 @@ func (h *ActionHandler) DeleteOrg(ctx context.Context, orgRef string) error {
} }
type AddOrgMemberResponse struct { type AddOrgMemberResponse struct {
OrganizationMember *types.OrganizationMember OrganizationMember *cstypes.OrganizationMember
Org *types.Organization Org *cstypes.Organization
User *types.User User *cstypes.User
} }
func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string, role types.MemberRole) (*AddOrgMemberResponse, error) { func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string, role cstypes.MemberRole) (*AddOrgMemberResponse, error) {
org, resp, err := h.configstoreClient.GetOrg(ctx, orgRef) org, resp, err := h.configstoreClient.GetOrg(ctx, orgRef)
if err != nil { if err != nil {
return nil, ErrFromRemote(resp, err) return nil, ErrFromRemote(resp, err)

View File

@ -23,6 +23,7 @@ import (
gitsource "agola.io/agola/internal/gitsources" gitsource "agola.io/agola/internal/gitsources"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
@ -39,7 +40,7 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csa
if err != nil { if err != nil {
return nil, errors.Errorf("failed to determine ownership: %w", err) return nil, errors.Errorf("failed to determine ownership: %w", err)
} }
if project.GlobalVisibility == types.VisibilityPublic { if project.GlobalVisibility == cstypes.VisibilityPublic {
return project, nil return project, nil
} }
if !isProjectMember { if !isProjectMember {
@ -52,7 +53,7 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csa
type CreateProjectRequest struct { type CreateProjectRequest struct {
Name string Name string
ParentRef string ParentRef string
Visibility types.Visibility Visibility cstypes.Visibility
RemoteSourceName string RemoteSourceName string
RepoPath string RepoPath string
SkipSSHHostKeyCheck bool SkipSSHHostKeyCheck bool
@ -108,7 +109,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
if err != nil { if err != nil {
return nil, errors.Errorf("failed to get remote source %q: %w", req.RemoteSourceName, ErrFromRemote(resp, err)) return nil, errors.Errorf("failed to get remote source %q: %w", req.RemoteSourceName, ErrFromRemote(resp, err))
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v
@ -135,14 +136,14 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
return nil, errors.Errorf("failed to generate ssh key pair: %w", err) return nil, errors.Errorf("failed to generate ssh key pair: %w", err)
} }
p := &types.Project{ p := &cstypes.Project{
Name: req.Name, Name: req.Name,
Parent: types.Parent{ Parent: cstypes.Parent{
Type: types.ConfigTypeProjectGroup, Type: cstypes.ConfigTypeProjectGroup,
ID: parentRef, ID: parentRef,
}, },
Visibility: req.Visibility, Visibility: req.Visibility,
RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeRemoteSource, RemoteRepositoryConfigType: cstypes.RemoteRepositoryConfigTypeRemoteSource,
RemoteSourceID: rs.ID, RemoteSourceID: rs.ID,
LinkedAccountID: la.ID, LinkedAccountID: la.ID,
RepositoryID: repo.ID, RepositoryID: repo.ID,
@ -180,7 +181,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
type UpdateProjectRequest struct { type UpdateProjectRequest struct {
Name string Name string
Visibility types.Visibility Visibility cstypes.Visibility
} }
func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, req *UpdateProjectRequest) (*csapi.Project, error) { func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, req *UpdateProjectRequest) (*csapi.Project, error) {
@ -235,7 +236,7 @@ func (h *ActionHandler) ProjectUpdateRepoLinkedAccount(ctx context.Context, proj
if err != nil { if err != nil {
return nil, errors.Errorf("failed to get remote source %q: %w", p.RemoteSourceID, ErrFromRemote(resp, err)) return nil, errors.Errorf("failed to get remote source %q: %w", p.RemoteSourceID, ErrFromRemote(resp, err))
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v
@ -269,7 +270,7 @@ func (h *ActionHandler) ProjectUpdateRepoLinkedAccount(ctx context.Context, proj
return rp, nil return rp, nil
} }
func (h *ActionHandler) setupGitSourceRepo(ctx context.Context, rs *types.RemoteSource, user *types.User, la *types.LinkedAccount, project *csapi.Project) error { func (h *ActionHandler) setupGitSourceRepo(ctx context.Context, rs *cstypes.RemoteSource, user *cstypes.User, la *cstypes.LinkedAccount, project *csapi.Project) error {
gitsource, err := h.GetGitSource(ctx, rs, user.Name, la) gitsource, err := h.GetGitSource(ctx, rs, user.Name, la)
if err != nil { if err != nil {
return errors.Errorf("failed to create gitsource client: %w", err) return errors.Errorf("failed to create gitsource client: %w", err)
@ -305,7 +306,7 @@ func (h *ActionHandler) setupGitSourceRepo(ctx context.Context, rs *types.Remote
return nil return nil
} }
func (h *ActionHandler) cleanupGitSourceRepo(ctx context.Context, rs *types.RemoteSource, user *types.User, la *types.LinkedAccount, project *csapi.Project) error { func (h *ActionHandler) cleanupGitSourceRepo(ctx context.Context, rs *cstypes.RemoteSource, user *cstypes.User, la *cstypes.LinkedAccount, project *csapi.Project) error {
gitsource, err := h.GetGitSource(ctx, rs, user.Name, la) gitsource, err := h.GetGitSource(ctx, rs, user.Name, la)
if err != nil { if err != nil {
return errors.Errorf("failed to create gitsource client: %w", err) return errors.Errorf("failed to create gitsource client: %w", err)
@ -436,7 +437,7 @@ func (h *ActionHandler) ProjectCreateRun(ctx context.Context, projectRef, branch
if err != nil { if err != nil {
return errors.Errorf("failed to get remote source %q: %w", p.RemoteSourceID, ErrFromRemote(resp, err)) return errors.Errorf("failed to get remote source %q: %w", p.RemoteSourceID, ErrFromRemote(resp, err))
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v
@ -571,7 +572,7 @@ func (h *ActionHandler) ProjectCreateRun(ctx context.Context, projectRef, branch
return h.CreateRuns(ctx, req) return h.CreateRuns(ctx, req)
} }
func (h *ActionHandler) getRemoteRepoAccessData(ctx context.Context, linkedAccountID string) (*types.User, *types.RemoteSource, *types.LinkedAccount, error) { func (h *ActionHandler) getRemoteRepoAccessData(ctx context.Context, linkedAccountID string) (*cstypes.User, *cstypes.RemoteSource, *cstypes.LinkedAccount, error) {
user, resp, err := h.configstoreClient.GetUserByLinkedAccount(ctx, linkedAccountID) user, resp, err := h.configstoreClient.GetUserByLinkedAccount(ctx, linkedAccountID)
if err != nil { if err != nil {
return nil, nil, nil, errors.Errorf("failed to get user with linked account id %q: %w", linkedAccountID, ErrFromRemote(resp, err)) return nil, nil, nil, errors.Errorf("failed to get user with linked account id %q: %w", linkedAccountID, ErrFromRemote(resp, err))

View File

@ -19,7 +19,7 @@ import (
"path" "path"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -53,7 +53,7 @@ type CreateProjectGroupRequest struct {
CurrentUserID string CurrentUserID string
Name string Name string
ParentRef string ParentRef string
Visibility types.Visibility Visibility cstypes.Visibility
} }
func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProjectGroupRequest) (*csapi.ProjectGroup, error) { func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProjectGroupRequest) (*csapi.ProjectGroup, error) {
@ -85,10 +85,10 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje
parentRef = path.Join("user", user.Name) parentRef = path.Join("user", user.Name)
} }
p := &types.ProjectGroup{ p := &cstypes.ProjectGroup{
Name: req.Name, Name: req.Name,
Parent: types.Parent{ Parent: cstypes.Parent{
Type: types.ConfigTypeProjectGroup, Type: cstypes.ConfigTypeProjectGroup,
ID: parentRef, ID: parentRef,
}, },
Visibility: req.Visibility, Visibility: req.Visibility,
@ -106,7 +106,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje
type UpdateProjectGroupRequest struct { type UpdateProjectGroupRequest struct {
Name string Name string
Visibility types.Visibility Visibility cstypes.Visibility
} }
func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef string, req *UpdateProjectGroupRequest) (*csapi.ProjectGroup, error) { func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef string, req *UpdateProjectGroupRequest) (*csapi.ProjectGroup, error) {

View File

@ -17,13 +17,13 @@ package action
import ( import (
"context" "context"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
func (h *ActionHandler) GetRemoteSource(ctx context.Context, rsRef string) (*types.RemoteSource, error) { func (h *ActionHandler) GetRemoteSource(ctx context.Context, rsRef string) (*cstypes.RemoteSource, error) {
rs, resp, err := h.configstoreClient.GetRemoteSource(ctx, rsRef) rs, resp, err := h.configstoreClient.GetRemoteSource(ctx, rsRef)
if err != nil { if err != nil {
return nil, ErrFromRemote(resp, err) return nil, ErrFromRemote(resp, err)
@ -37,7 +37,7 @@ type GetRemoteSourcesRequest struct {
Asc bool Asc bool
} }
func (h *ActionHandler) GetRemoteSources(ctx context.Context, req *GetRemoteSourcesRequest) ([]*types.RemoteSource, error) { func (h *ActionHandler) GetRemoteSources(ctx context.Context, req *GetRemoteSourcesRequest) ([]*cstypes.RemoteSource, error) {
remoteSources, resp, err := h.configstoreClient.GetRemoteSources(ctx, req.Start, req.Limit, req.Asc) remoteSources, resp, err := h.configstoreClient.GetRemoteSources(ctx, req.Start, req.Limit, req.Asc)
if err != nil { if err != nil {
return nil, ErrFromRemote(resp, err) return nil, ErrFromRemote(resp, err)
@ -59,7 +59,7 @@ type CreateRemoteSourceRequest struct {
LoginEnabled *bool LoginEnabled *bool
} }
func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemoteSourceRequest) (*types.RemoteSource, error) { func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemoteSourceRequest) (*cstypes.RemoteSource, error) {
if !h.IsUserAdmin(ctx) { if !h.IsUserAdmin(ctx) {
return nil, errors.Errorf("user not admin") return nil, errors.Errorf("user not admin")
} }
@ -82,11 +82,11 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemot
} }
// validate if the remote source type supports the required auth type // validate if the remote source type supports the required auth type
if !types.SourceSupportsAuthType(types.RemoteSourceType(req.Type), types.RemoteSourceAuthType(req.AuthType)) { if !cstypes.SourceSupportsAuthType(cstypes.RemoteSourceType(req.Type), cstypes.RemoteSourceAuthType(req.AuthType)) {
return nil, util.NewErrBadRequest(errors.Errorf("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType)) return nil, util.NewErrBadRequest(errors.Errorf("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType))
} }
if req.AuthType == string(types.RemoteSourceAuthTypeOauth2) { if req.AuthType == string(cstypes.RemoteSourceAuthTypeOauth2) {
if req.Oauth2ClientID == "" { if req.Oauth2ClientID == "" {
return nil, util.NewErrBadRequest(errors.Errorf("remotesource oauth2 clientid required")) return nil, util.NewErrBadRequest(errors.Errorf("remotesource oauth2 clientid required"))
} }
@ -95,10 +95,10 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemot
} }
} }
rs := &types.RemoteSource{ rs := &cstypes.RemoteSource{
Name: req.Name, Name: req.Name,
Type: types.RemoteSourceType(req.Type), Type: cstypes.RemoteSourceType(req.Type),
AuthType: types.RemoteSourceAuthType(req.AuthType), AuthType: cstypes.RemoteSourceAuthType(req.AuthType),
APIURL: req.APIURL, APIURL: req.APIURL,
SkipVerify: req.SkipVerify, SkipVerify: req.SkipVerify,
Oauth2ClientID: req.Oauth2ClientID, Oauth2ClientID: req.Oauth2ClientID,
@ -133,7 +133,7 @@ type UpdateRemoteSourceRequest struct {
LoginEnabled *bool LoginEnabled *bool
} }
func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, req *UpdateRemoteSourceRequest) (*types.RemoteSource, error) { func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, req *UpdateRemoteSourceRequest) (*cstypes.RemoteSource, error) {
if !h.IsUserAdmin(ctx) { if !h.IsUserAdmin(ctx) {
return nil, errors.Errorf("user not admin") return nil, errors.Errorf("user not admin")
} }

View File

@ -24,6 +24,7 @@ import (
gitsource "agola.io/agola/internal/gitsources" gitsource "agola.io/agola/internal/gitsources"
"agola.io/agola/internal/runconfig" "agola.io/agola/internal/runconfig"
"agola.io/agola/internal/services/common" "agola.io/agola/internal/services/common"
cstypes "agola.io/agola/internal/services/configstore/types"
rsapi "agola.io/agola/internal/services/runservice/api" rsapi "agola.io/agola/internal/services/runservice/api"
rstypes "agola.io/agola/internal/services/runservice/types" rstypes "agola.io/agola/internal/services/runservice/types"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/types"
@ -293,8 +294,8 @@ type CreateRunRequest struct {
RefType types.RunRefType RefType types.RunRefType
RunCreationTrigger types.RunCreationTriggerType RunCreationTrigger types.RunCreationTriggerType
Project *types.Project Project *cstypes.Project
User *types.User User *cstypes.User
RepoPath string RepoPath string
GitSource gitsource.GitSource GitSource gitsource.GitSource
CommitSHA string CommitSHA string
@ -537,9 +538,9 @@ func (h *ActionHandler) genRunVariables(ctx context.Context, req *CreateRunReque
} }
for _, pvar := range pvars { for _, pvar := range pvars {
// find the value match // find the value match
var varval types.VariableValue var varval cstypes.VariableValue
for _, varval = range pvar.Values { for _, varval = range pvar.Values {
match := types.MatchWhen(varval.When, req.Branch, req.Tag, req.Ref) match := cstypes.MatchWhen(varval.When, req.Branch, req.Tag, req.Ref)
if !match { if !match {
continue continue
} }

View File

@ -19,14 +19,14 @@ import (
"net/http" "net/http"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
type GetSecretsRequest struct { type GetSecretsRequest struct {
ParentType types.ConfigType ParentType cstypes.ConfigType
ParentRef string ParentRef string
Tree bool Tree bool
@ -37,9 +37,9 @@ func (h *ActionHandler) GetSecrets(ctx context.Context, req *GetSecretsRequest)
var resp *http.Response var resp *http.Response
var err error var err error
switch req.ParentType { switch req.ParentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
cssecrets, resp, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, req.Tree) cssecrets, resp, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, req.Tree)
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
cssecrets, resp, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, req.Tree) cssecrets, resp, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, req.Tree)
} }
if err != nil { if err != nil {
@ -52,10 +52,10 @@ func (h *ActionHandler) GetSecrets(ctx context.Context, req *GetSecretsRequest)
type CreateSecretRequest struct { type CreateSecretRequest struct {
Name string Name string
ParentType types.ConfigType ParentType cstypes.ConfigType
ParentRef string ParentRef string
Type types.SecretType Type cstypes.SecretType
// internal secret // internal secret
Data map[string]string Data map[string]string
@ -78,7 +78,7 @@ func (h *ActionHandler) CreateSecret(ctx context.Context, req *CreateSecretReque
return nil, util.NewErrBadRequest(errors.Errorf("invalid secret name %q", req.Name)) return nil, util.NewErrBadRequest(errors.Errorf("invalid secret name %q", req.Name))
} }
s := &types.Secret{ s := &cstypes.Secret{
Name: req.Name, Name: req.Name,
Type: req.Type, Type: req.Type,
Data: req.Data, Data: req.Data,
@ -87,10 +87,10 @@ func (h *ActionHandler) CreateSecret(ctx context.Context, req *CreateSecretReque
var resp *http.Response var resp *http.Response
var rs *csapi.Secret var rs *csapi.Secret
switch req.ParentType { switch req.ParentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
h.log.Infof("creating project group secret") h.log.Infof("creating project group secret")
rs, resp, err = h.configstoreClient.CreateProjectGroupSecret(ctx, req.ParentRef, s) rs, resp, err = h.configstoreClient.CreateProjectGroupSecret(ctx, req.ParentRef, s)
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
h.log.Infof("creating project secret") h.log.Infof("creating project secret")
rs, resp, err = h.configstoreClient.CreateProjectSecret(ctx, req.ParentRef, s) rs, resp, err = h.configstoreClient.CreateProjectSecret(ctx, req.ParentRef, s)
} }
@ -107,10 +107,10 @@ type UpdateSecretRequest struct {
Name string Name string
ParentType types.ConfigType ParentType cstypes.ConfigType
ParentRef string ParentRef string
Type types.SecretType Type cstypes.SecretType
// internal secret // internal secret
Data map[string]string Data map[string]string
@ -133,7 +133,7 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, req *UpdateSecretReque
return nil, util.NewErrBadRequest(errors.Errorf("invalid secret name %q", req.Name)) return nil, util.NewErrBadRequest(errors.Errorf("invalid secret name %q", req.Name))
} }
s := &types.Secret{ s := &cstypes.Secret{
Name: req.Name, Name: req.Name,
Type: req.Type, Type: req.Type,
Data: req.Data, Data: req.Data,
@ -142,10 +142,10 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, req *UpdateSecretReque
var resp *http.Response var resp *http.Response
var rs *csapi.Secret var rs *csapi.Secret
switch req.ParentType { switch req.ParentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
h.log.Infof("updating project group secret") h.log.Infof("updating project group secret")
rs, resp, err = h.configstoreClient.UpdateProjectGroupSecret(ctx, req.ParentRef, req.SecretName, s) rs, resp, err = h.configstoreClient.UpdateProjectGroupSecret(ctx, req.ParentRef, req.SecretName, s)
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
h.log.Infof("updating project secret") h.log.Infof("updating project secret")
rs, resp, err = h.configstoreClient.UpdateProjectSecret(ctx, req.ParentRef, req.SecretName, s) rs, resp, err = h.configstoreClient.UpdateProjectSecret(ctx, req.ParentRef, req.SecretName, s)
} }
@ -157,7 +157,7 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, req *UpdateSecretReque
return rs, nil return rs, nil
} }
func (h *ActionHandler) DeleteSecret(ctx context.Context, parentType types.ConfigType, parentRef, name string) error { func (h *ActionHandler) DeleteSecret(ctx context.Context, parentType cstypes.ConfigType, parentRef, name string) error {
isVariableOwner, err := h.IsVariableOwner(ctx, parentType, parentRef) isVariableOwner, err := h.IsVariableOwner(ctx, parentType, parentRef)
if err != nil { if err != nil {
return errors.Errorf("failed to determine ownership: %w", err) return errors.Errorf("failed to determine ownership: %w", err)
@ -168,10 +168,10 @@ func (h *ActionHandler) DeleteSecret(ctx context.Context, parentType types.Confi
var resp *http.Response var resp *http.Response
switch parentType { switch parentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
h.log.Infof("deleting project group secret") h.log.Infof("deleting project group secret")
resp, err = h.configstoreClient.DeleteProjectGroupSecret(ctx, parentRef, name) resp, err = h.configstoreClient.DeleteProjectGroupSecret(ctx, parentRef, name)
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
h.log.Infof("deleting project secret") h.log.Infof("deleting project secret")
resp, err = h.configstoreClient.DeleteProjectSecret(ctx, parentRef, name) resp, err = h.configstoreClient.DeleteProjectSecret(ctx, parentRef, name)
} }

View File

@ -25,6 +25,7 @@ import (
"agola.io/agola/internal/gitsources/agolagit" "agola.io/agola/internal/gitsources/agolagit"
"agola.io/agola/internal/services/common" "agola.io/agola/internal/services/common"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/types" "agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
@ -43,7 +44,7 @@ func isAccessTokenExpired(expiresAt time.Time) bool {
return expiresAt.Add(-expireTimeRange).Before(time.Now()) return expiresAt.Add(-expireTimeRange).Before(time.Now())
} }
func (h *ActionHandler) GetUser(ctx context.Context, userRef string) (*types.User, error) { func (h *ActionHandler) GetUser(ctx context.Context, userRef string) (*cstypes.User, error) {
if !h.IsUserLoggedOrAdmin(ctx) { if !h.IsUserLoggedOrAdmin(ctx) {
return nil, errors.Errorf("user not logged in") return nil, errors.Errorf("user not logged in")
} }
@ -61,7 +62,7 @@ type GetUsersRequest struct {
Asc bool Asc bool
} }
func (h *ActionHandler) GetUsers(ctx context.Context, req *GetUsersRequest) ([]*types.User, error) { func (h *ActionHandler) GetUsers(ctx context.Context, req *GetUsersRequest) ([]*cstypes.User, error) {
if !h.IsUserAdmin(ctx) { if !h.IsUserAdmin(ctx) {
return nil, errors.Errorf("user not logged in") return nil, errors.Errorf("user not logged in")
} }
@ -77,7 +78,7 @@ type CreateUserRequest struct {
UserName string UserName string
} }
func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest) (*types.User, error) { func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest) (*cstypes.User, error) {
if !h.IsUserAdmin(ctx) { if !h.IsUserAdmin(ctx) {
return nil, errors.Errorf("user not admin") return nil, errors.Errorf("user not admin")
} }
@ -158,7 +159,7 @@ type CreateUserLARequest struct {
Oauth2AccessTokenExpiresAt time.Time Oauth2AccessTokenExpiresAt time.Time
} }
func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLARequest) (*types.LinkedAccount, error) { func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLARequest) (*cstypes.LinkedAccount, error) {
userRef := req.UserRef userRef := req.UserRef
user, resp, err := h.configstoreClient.GetUser(ctx, userRef) user, resp, err := h.configstoreClient.GetUser(ctx, userRef)
if err != nil { if err != nil {
@ -168,7 +169,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
if err != nil { if err != nil {
return nil, errors.Errorf("failed to get remote source %q: %w", req.RemoteSourceName, ErrFromRemote(resp, err)) return nil, errors.Errorf("failed to get remote source %q: %w", req.RemoteSourceName, ErrFromRemote(resp, err))
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v
@ -216,7 +217,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
return la, nil return la, nil
} }
func (h *ActionHandler) UpdateUserLA(ctx context.Context, userRef string, la *types.LinkedAccount) error { func (h *ActionHandler) UpdateUserLA(ctx context.Context, userRef string, la *cstypes.LinkedAccount) error {
user, resp, err := h.configstoreClient.GetUser(ctx, userRef) user, resp, err := h.configstoreClient.GetUser(ctx, userRef)
if err != nil { if err != nil {
return errors.Errorf("failed to get user %q: %w", userRef, ErrFromRemote(resp, err)) return errors.Errorf("failed to get user %q: %w", userRef, ErrFromRemote(resp, err))
@ -252,9 +253,9 @@ func (h *ActionHandler) UpdateUserLA(ctx context.Context, userRef string, la *ty
} }
// RefreshLinkedAccount refreshed the linked account oauth2 access token and update linked account in the configstore // RefreshLinkedAccount refreshed the linked account oauth2 access token and update linked account in the configstore
func (h *ActionHandler) RefreshLinkedAccount(ctx context.Context, rs *types.RemoteSource, userName string, la *types.LinkedAccount) (*types.LinkedAccount, error) { func (h *ActionHandler) RefreshLinkedAccount(ctx context.Context, rs *cstypes.RemoteSource, userName string, la *cstypes.LinkedAccount) (*cstypes.LinkedAccount, error) {
switch rs.AuthType { switch rs.AuthType {
case types.RemoteSourceAuthTypeOauth2: case cstypes.RemoteSourceAuthTypeOauth2:
// refresh access token if expired // refresh access token if expired
if isAccessTokenExpired(la.Oauth2AccessTokenExpiresAt) { if isAccessTokenExpired(la.Oauth2AccessTokenExpiresAt) {
userSource, err := common.GetOauth2Source(rs, "") userSource, err := common.GetOauth2Source(rs, "")
@ -282,7 +283,7 @@ func (h *ActionHandler) RefreshLinkedAccount(ctx context.Context, rs *types.Remo
// GetGitSource is a wrapper around common.GetGitSource that will also refresh // GetGitSource is a wrapper around common.GetGitSource that will also refresh
// the oauth2 access token and update the linked account when needed // the oauth2 access token and update the linked account when needed
func (h *ActionHandler) GetGitSource(ctx context.Context, rs *types.RemoteSource, userName string, la *types.LinkedAccount) (gitsource.GitSource, error) { func (h *ActionHandler) GetGitSource(ctx context.Context, rs *cstypes.RemoteSource, userName string, la *cstypes.LinkedAccount) (gitsource.GitSource, error) {
la, err := h.RefreshLinkedAccount(ctx, rs, userName, la) la, err := h.RefreshLinkedAccount(ctx, rs, userName, la)
if err != nil { if err != nil {
return nil, err return nil, err
@ -299,7 +300,7 @@ type RegisterUserRequest struct {
Oauth2AccessTokenExpiresAt time.Time Oauth2AccessTokenExpiresAt time.Time
} }
func (h *ActionHandler) RegisterUser(ctx context.Context, req *RegisterUserRequest) (*types.User, error) { func (h *ActionHandler) RegisterUser(ctx context.Context, req *RegisterUserRequest) (*cstypes.User, error) {
if req.UserName == "" { if req.UserName == "" {
return nil, util.NewErrBadRequest(errors.Errorf("user name required")) return nil, util.NewErrBadRequest(errors.Errorf("user name required"))
} }
@ -365,7 +366,7 @@ type LoginUserRequest struct {
type LoginUserResponse struct { type LoginUserResponse struct {
Token string Token string
User *types.User User *cstypes.User
} }
func (h *ActionHandler) LoginUser(ctx context.Context, req *LoginUserRequest) (*LoginUserResponse, error) { func (h *ActionHandler) LoginUser(ctx context.Context, req *LoginUserRequest) (*LoginUserResponse, error) {
@ -399,7 +400,7 @@ func (h *ActionHandler) LoginUser(ctx context.Context, req *LoginUserRequest) (*
return nil, errors.Errorf("failed to get user for remote user id %q and remote source %q: %w", remoteUserInfo.ID, rs.ID, ErrFromRemote(resp, err)) return nil, errors.Errorf("failed to get user for remote user id %q and remote source %q: %w", remoteUserInfo.ID, rs.ID, ErrFromRemote(resp, err))
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v
@ -517,7 +518,7 @@ func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSource
return nil, util.NewErrBadRequest(errors.Errorf("logged in user cannot create linked account for another user")) return nil, util.NewErrBadRequest(errors.Errorf("logged in user cannot create linked account for another user"))
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v
@ -539,7 +540,7 @@ func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSource
} }
switch rs.AuthType { switch rs.AuthType {
case types.RemoteSourceAuthTypeOauth2: case cstypes.RemoteSourceAuthTypeOauth2:
oauth2Source, err := common.GetOauth2Source(rs, "") oauth2Source, err := common.GetOauth2Source(rs, "")
if err != nil { if err != nil {
return nil, errors.Errorf("failed to create git source: %w", err) return nil, errors.Errorf("failed to create git source: %w", err)
@ -557,7 +558,7 @@ func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSource
Oauth2Redirect: redirect, Oauth2Redirect: redirect,
}, nil }, nil
case types.RemoteSourceAuthTypePassword: case cstypes.RemoteSourceAuthTypePassword:
passwordSource, err := common.GetPasswordSource(rs, "") passwordSource, err := common.GetPasswordSource(rs, "")
if err != nil { if err != nil {
return nil, errors.Errorf("failed to create git source: %w", err) return nil, errors.Errorf("failed to create git source: %w", err)
@ -602,7 +603,7 @@ type RemoteSourceAuthResult struct {
} }
type CreateUserLAResponse struct { type CreateUserLAResponse struct {
LinkedAccount *types.LinkedAccount LinkedAccount *cstypes.LinkedAccount
} }
func (h *ActionHandler) HandleRemoteSourceAuthRequest(ctx context.Context, requestType RemoteSourceRequestType, requestString string, userAccessToken, oauth2AccessToken, oauth2RefreshToken string, oauth2AccessTokenExpiresAt time.Time) (*RemoteSourceAuthResult, error) { func (h *ActionHandler) HandleRemoteSourceAuthRequest(ctx context.Context, requestType RemoteSourceRequestType, requestString string, userAccessToken, oauth2AccessToken, oauth2RefreshToken string, oauth2AccessTokenExpiresAt time.Time) (*RemoteSourceAuthResult, error) {

View File

@ -20,13 +20,13 @@ import (
"agola.io/agola/internal/services/common" "agola.io/agola/internal/services/common"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
type GetVariablesRequest struct { type GetVariablesRequest struct {
ParentType types.ConfigType ParentType cstypes.ConfigType
ParentRef string ParentRef string
Tree bool Tree bool
@ -38,7 +38,7 @@ func (h *ActionHandler) GetVariables(ctx context.Context, req *GetVariablesReque
var cssecrets []*csapi.Secret var cssecrets []*csapi.Secret
switch req.ParentType { switch req.ParentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
var err error var err error
var resp *http.Response var resp *http.Response
csvars, resp, err = h.configstoreClient.GetProjectGroupVariables(ctx, req.ParentRef, req.Tree) csvars, resp, err = h.configstoreClient.GetProjectGroupVariables(ctx, req.ParentRef, req.Tree)
@ -49,7 +49,7 @@ func (h *ActionHandler) GetVariables(ctx context.Context, req *GetVariablesReque
if err != nil { if err != nil {
return nil, nil, ErrFromRemote(resp, err) return nil, nil, ErrFromRemote(resp, err)
} }
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
var err error var err error
var resp *http.Response var resp *http.Response
csvars, resp, err = h.configstoreClient.GetProjectVariables(ctx, req.ParentRef, req.Tree) csvars, resp, err = h.configstoreClient.GetProjectVariables(ctx, req.ParentRef, req.Tree)
@ -73,10 +73,10 @@ func (h *ActionHandler) GetVariables(ctx context.Context, req *GetVariablesReque
type CreateVariableRequest struct { type CreateVariableRequest struct {
Name string Name string
ParentType types.ConfigType ParentType cstypes.ConfigType
ParentRef string ParentRef string
Values []types.VariableValue Values []cstypes.VariableValue
} }
func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableRequest) (*csapi.Variable, []*csapi.Secret, error) { func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableRequest) (*csapi.Variable, []*csapi.Secret, error) {
@ -96,9 +96,9 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableR
return nil, nil, util.NewErrBadRequest(errors.Errorf("empty variable values")) return nil, nil, util.NewErrBadRequest(errors.Errorf("empty variable values"))
} }
v := &types.Variable{ v := &cstypes.Variable{
Name: req.Name, Name: req.Name,
Parent: types.Parent{ Parent: cstypes.Parent{
Type: req.ParentType, Type: req.ParentType,
ID: req.ParentRef, ID: req.ParentRef,
}, },
@ -109,7 +109,7 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableR
var rv *csapi.Variable var rv *csapi.Variable
switch req.ParentType { switch req.ParentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
var err error var err error
var resp *http.Response var resp *http.Response
cssecrets, resp, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, true) cssecrets, resp, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, true)
@ -122,7 +122,7 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableR
if err != nil { if err != nil {
return nil, nil, errors.Errorf("failed to create variable: %w", ErrFromRemote(resp, err)) return nil, nil, errors.Errorf("failed to create variable: %w", ErrFromRemote(resp, err))
} }
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
var err error var err error
var resp *http.Response var resp *http.Response
cssecrets, resp, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, true) cssecrets, resp, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, true)
@ -146,10 +146,10 @@ type UpdateVariableRequest struct {
Name string Name string
ParentType types.ConfigType ParentType cstypes.ConfigType
ParentRef string ParentRef string
Values []types.VariableValue Values []cstypes.VariableValue
} }
func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableRequest) (*csapi.Variable, []*csapi.Secret, error) { func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableRequest) (*csapi.Variable, []*csapi.Secret, error) {
@ -169,9 +169,9 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
return nil, nil, util.NewErrBadRequest(errors.Errorf("empty variable values")) return nil, nil, util.NewErrBadRequest(errors.Errorf("empty variable values"))
} }
v := &types.Variable{ v := &cstypes.Variable{
Name: req.Name, Name: req.Name,
Parent: types.Parent{ Parent: cstypes.Parent{
Type: req.ParentType, Type: req.ParentType,
ID: req.ParentRef, ID: req.ParentRef,
}, },
@ -182,7 +182,7 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
var rv *csapi.Variable var rv *csapi.Variable
switch req.ParentType { switch req.ParentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
var err error var err error
var resp *http.Response var resp *http.Response
cssecrets, resp, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, true) cssecrets, resp, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, true)
@ -195,7 +195,7 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
if err != nil { if err != nil {
return nil, nil, errors.Errorf("failed to create variable: %w", ErrFromRemote(resp, err)) return nil, nil, errors.Errorf("failed to create variable: %w", ErrFromRemote(resp, err))
} }
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
var err error var err error
var resp *http.Response var resp *http.Response
cssecrets, resp, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, true) cssecrets, resp, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, true)
@ -214,7 +214,7 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
return rv, cssecrets, nil return rv, cssecrets, nil
} }
func (h *ActionHandler) DeleteVariable(ctx context.Context, parentType types.ConfigType, parentRef, name string) error { func (h *ActionHandler) DeleteVariable(ctx context.Context, parentType cstypes.ConfigType, parentRef, name string) error {
isVariableOwner, err := h.IsVariableOwner(ctx, parentType, parentRef) isVariableOwner, err := h.IsVariableOwner(ctx, parentType, parentRef)
if err != nil { if err != nil {
return errors.Errorf("failed to determine ownership: %w", err) return errors.Errorf("failed to determine ownership: %w", err)
@ -225,10 +225,10 @@ func (h *ActionHandler) DeleteVariable(ctx context.Context, parentType types.Con
var resp *http.Response var resp *http.Response
switch parentType { switch parentType {
case types.ConfigTypeProjectGroup: case cstypes.ConfigTypeProjectGroup:
h.log.Infof("deleting project group variable") h.log.Infof("deleting project group variable")
resp, err = h.configstoreClient.DeleteProjectGroupVariable(ctx, parentRef, name) resp, err = h.configstoreClient.DeleteProjectGroupVariable(ctx, parentRef, name)
case types.ConfigTypeProject: case cstypes.ConfigTypeProject:
h.log.Infof("deleting project variable") h.log.Infof("deleting project variable")
resp, err = h.configstoreClient.DeleteProjectVariable(ctx, parentRef, name) resp, err = h.configstoreClient.DeleteProjectVariable(ctx, parentRef, name)
} }

View File

@ -19,7 +19,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -139,14 +139,14 @@ func httpErrorFromRemote(w http.ResponseWriter, resp *http.Response, err error)
return false return false
} }
func GetConfigTypeRef(r *http.Request) (types.ConfigType, string, error) { func GetConfigTypeRef(r *http.Request) (cstypes.ConfigType, string, error) {
vars := mux.Vars(r) vars := mux.Vars(r)
projectRef, err := url.PathUnescape(vars["projectref"]) projectRef, err := url.PathUnescape(vars["projectref"])
if err != nil { if err != nil {
return "", "", util.NewErrBadRequest(errors.Errorf("wrong projectref %q: %w", vars["projectref"], err)) return "", "", util.NewErrBadRequest(errors.Errorf("wrong projectref %q: %w", vars["projectref"], err))
} }
if projectRef != "" { if projectRef != "" {
return types.ConfigTypeProject, projectRef, nil return cstypes.ConfigTypeProject, projectRef, nil
} }
projectGroupRef, err := url.PathUnescape(vars["projectgroupref"]) projectGroupRef, err := url.PathUnescape(vars["projectgroupref"])
@ -154,7 +154,7 @@ func GetConfigTypeRef(r *http.Request) (types.ConfigType, string, error) {
return "", "", util.NewErrBadRequest(errors.Errorf("wrong projectgroupref %q: %w", vars["projectgroupref"], err)) return "", "", util.NewErrBadRequest(errors.Errorf("wrong projectgroupref %q: %w", vars["projectgroupref"], err))
} }
if projectGroupRef != "" { if projectGroupRef != "" {
return types.ConfigTypeProjectGroup, projectGroupRef, nil return cstypes.ConfigTypeProjectGroup, projectGroupRef, nil
} }
return "", "", util.NewErrBadRequest(errors.Errorf("cannot get project or projectgroup ref")) return "", "", util.NewErrBadRequest(errors.Errorf("cannot get project or projectgroup ref"))

View File

@ -27,7 +27,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"agola.io/agola/internal/services/types" cstypes "agola.io/agola/internal/services/configstore/types"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
) )
@ -475,7 +475,7 @@ func (c *Client) DeleteOrg(ctx context.Context, orgRef string) (*http.Response,
return c.getResponse(ctx, "DELETE", fmt.Sprintf("/orgs/%s", orgRef), nil, jsonContent, nil) return c.getResponse(ctx, "DELETE", fmt.Sprintf("/orgs/%s", orgRef), nil, jsonContent, nil)
} }
func (c *Client) AddOrgMember(ctx context.Context, orgRef, userRef string, role types.MemberRole) (*AddOrgMemberResponse, *http.Response, error) { func (c *Client) AddOrgMember(ctx context.Context, orgRef, userRef string, role cstypes.MemberRole) (*AddOrgMemberResponse, *http.Response, error) {
req := &AddOrgMemberRequest{ req := &AddOrgMemberRequest{
Role: role, Role: role,
} }

View File

@ -19,8 +19,8 @@ import (
"net/http" "net/http"
"strconv" "strconv"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"go.uber.org/zap" "go.uber.org/zap"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -30,7 +30,7 @@ import (
type CreateOrgRequest struct { type CreateOrgRequest struct {
Name string `json:"name"` Name string `json:"name"`
Visibility types.Visibility `json:"visibility"` Visibility cstypes.Visibility `json:"visibility"`
} }
type CreateOrgHandler struct { type CreateOrgHandler struct {
@ -130,10 +130,10 @@ func (h *OrgHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type OrgResponse struct { type OrgResponse struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Visibility types.Visibility `json:"visibility,omitempty"` Visibility cstypes.Visibility `json:"visibility,omitempty"`
} }
func createOrgResponse(o *types.Organization) *OrgResponse { func createOrgResponse(o *cstypes.Organization) *OrgResponse {
org := &OrgResponse{ org := &OrgResponse{
ID: o.ID, ID: o.ID,
Name: o.Name, Name: o.Name,
@ -206,10 +206,10 @@ type OrgMembersResponse struct {
type OrgMemberResponse struct { type OrgMemberResponse struct {
User *UserResponse `json:"user"` User *UserResponse `json:"user"`
Role types.MemberRole `json:"role"` Role cstypes.MemberRole `json:"role"`
} }
func createOrgMemberResponse(user *types.User, role types.MemberRole) *OrgMemberResponse { func createOrgMemberResponse(user *cstypes.User, role cstypes.MemberRole) *OrgMemberResponse {
return &OrgMemberResponse{ return &OrgMemberResponse{
User: createUserResponse(user), User: createUserResponse(user),
Role: role, Role: role,
@ -254,7 +254,7 @@ type AddOrgMemberResponse struct {
OrgMemberResponse OrgMemberResponse
} }
func createAddOrgMemberResponse(org *types.Organization, user *types.User, role types.MemberRole) *AddOrgMemberResponse { func createAddOrgMemberResponse(org *cstypes.Organization, user *cstypes.User, role cstypes.MemberRole) *AddOrgMemberResponse {
return &AddOrgMemberResponse{ return &AddOrgMemberResponse{
Organization: createOrgResponse(org), Organization: createOrgResponse(org),
OrgMemberResponse: OrgMemberResponse{ OrgMemberResponse: OrgMemberResponse{
@ -265,7 +265,7 @@ func createAddOrgMemberResponse(org *types.Organization, user *types.User, role
} }
type AddOrgMemberRequest struct { type AddOrgMemberRequest struct {
Role types.MemberRole `json:"role"` Role cstypes.MemberRole `json:"role"`
} }
type AddOrgMemberHandler struct { type AddOrgMemberHandler struct {

View File

@ -20,8 +20,8 @@ import (
"net/url" "net/url"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -31,7 +31,7 @@ import (
type CreateProjectRequest struct { type CreateProjectRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
ParentRef string `json:"parent_ref,omitempty"` ParentRef string `json:"parent_ref,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"` Visibility cstypes.Visibility `json:"visibility,omitempty"`
RepoPath string `json:"repo_path,omitempty"` RepoPath string `json:"repo_path,omitempty"`
RemoteSourceName string `json:"remote_source_name,omitempty"` RemoteSourceName string `json:"remote_source_name,omitempty"`
SkipSSHHostKeyCheck bool `json:"skip_ssh_host_key_check,omitempty"` SkipSSHHostKeyCheck bool `json:"skip_ssh_host_key_check,omitempty"`
@ -79,7 +79,7 @@ func (h *CreateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UpdateProjectRequest struct { type UpdateProjectRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"` Visibility cstypes.Visibility `json:"visibility,omitempty"`
} }
type UpdateProjectHandler struct { type UpdateProjectHandler struct {
@ -244,7 +244,7 @@ type ProjectResponse struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
ParentPath string `json:"parent_path,omitempty"` ParentPath string `json:"parent_path,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"` Visibility cstypes.Visibility `json:"visibility,omitempty"`
GlobalVisibility string `json:"global_visibility,omitempty"` GlobalVisibility string `json:"global_visibility,omitempty"`
} }

View File

@ -20,8 +20,8 @@ import (
"net/url" "net/url"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
@ -32,7 +32,7 @@ import (
type CreateProjectGroupRequest struct { type CreateProjectGroupRequest struct {
Name string `json:"name"` Name string `json:"name"`
ParentRef string `json:"parent_ref"` ParentRef string `json:"parent_ref"`
Visibility types.Visibility `json:"visibility"` Visibility cstypes.Visibility `json:"visibility"`
} }
type CreateProjectGroupHandler struct { type CreateProjectGroupHandler struct {
@ -82,7 +82,7 @@ func (h *CreateProjectGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
type UpdateProjectGroupRequest struct { type UpdateProjectGroupRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"` Visibility cstypes.Visibility `json:"visibility,omitempty"`
} }
type UpdateProjectGroupHandler struct { type UpdateProjectGroupHandler struct {
@ -258,7 +258,7 @@ type ProjectGroupResponse struct {
Name string `json:"name"` Name string `json:"name"`
Path string `json:"path"` Path string `json:"path"`
ParentPath string `json:"parent_path"` ParentPath string `json:"parent_path"`
Visibility types.Visibility `json:"visibility"` Visibility cstypes.Visibility `json:"visibility"`
GlobalVisibility string `json:"global_visibility"` GlobalVisibility string `json:"global_visibility"`
} }

View File

@ -19,8 +19,8 @@ import (
gitsource "agola.io/agola/internal/gitsources" gitsource "agola.io/agola/internal/gitsources"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -76,7 +76,7 @@ func (h *UserRemoteReposHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
return return
} }
var la *types.LinkedAccount var la *cstypes.LinkedAccount
for _, v := range user.LinkedAccounts { for _, v := range user.LinkedAccounts {
if v.RemoteSourceID == rs.ID { if v.RemoteSourceID == rs.ID {
la = v la = v

View File

@ -19,13 +19,13 @@ import (
"net/http" "net/http"
"strconv" "strconv"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"go.uber.org/zap" "go.uber.org/zap"
errors "golang.org/x/xerrors"
"github.com/gorilla/mux" "github.com/gorilla/mux"
errors "golang.org/x/xerrors"
) )
type CreateRemoteSourceRequest struct { type CreateRemoteSourceRequest struct {
@ -152,7 +152,7 @@ type RemoteSourceResponse struct {
LoginEnabled bool `json:"login_enabled"` LoginEnabled bool `json:"login_enabled"`
} }
func createRemoteSourceResponse(r *types.RemoteSource) *RemoteSourceResponse { func createRemoteSourceResponse(r *cstypes.RemoteSource) *RemoteSourceResponse {
rs := &RemoteSourceResponse{ rs := &RemoteSourceResponse{
ID: r.ID, ID: r.ID,
Name: r.Name, Name: r.Name,

View File

@ -19,12 +19,12 @@ import (
"net/http" "net/http"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"go.uber.org/zap"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"go.uber.org/zap"
) )
type SecretResponse struct { type SecretResponse struct {
@ -85,7 +85,7 @@ func (h *SecretHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type CreateSecretRequest struct { type CreateSecretRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Type types.SecretType `json:"type,omitempty"` Type cstypes.SecretType `json:"type,omitempty"`
// internal secret // internal secret
Data map[string]string `json:"data,omitempty"` Data map[string]string `json:"data,omitempty"`
@ -142,7 +142,7 @@ func (h *CreateSecretHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UpdateSecretRequest struct { type UpdateSecretRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Type types.SecretType `json:"type,omitempty"` Type cstypes.SecretType `json:"type,omitempty"`
// internal secret // internal secret
Data map[string]string `json:"data,omitempty"` Data map[string]string `json:"data,omitempty"`

View File

@ -22,8 +22,8 @@ import (
"strconv" "strconv"
gitsource "agola.io/agola/internal/gitsources" gitsource "agola.io/agola/internal/gitsources"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -166,7 +166,7 @@ type LinkedAccountResponse struct {
RemoteUserAvatarURL string `json:"remote_user_avatar_url"` RemoteUserAvatarURL string `json:"remote_user_avatar_url"`
} }
func createUserResponse(u *types.User) *UserResponse { func createUserResponse(u *cstypes.User) *UserResponse {
user := &UserResponse{ user := &UserResponse{
ID: u.ID, ID: u.ID,
UserName: u.Name, UserName: u.Name,
@ -256,7 +256,7 @@ type CreateUserLARequest struct {
} }
type CreateUserLAResponse struct { type CreateUserLAResponse struct {
LinkedAccount *types.LinkedAccount `json:"linked_account"` LinkedAccount *cstypes.LinkedAccount `json:"linked_account"`
Oauth2Redirect string `json:"oauth2_redirect"` Oauth2Redirect string `json:"oauth2_redirect"`
} }

View File

@ -20,8 +20,8 @@ import (
"agola.io/agola/internal/services/common" "agola.io/agola/internal/services/common"
csapi "agola.io/agola/internal/services/configstore/api" csapi "agola.io/agola/internal/services/configstore/api"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/gateway/action" "agola.io/agola/internal/services/gateway/action"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
"go.uber.org/zap" "go.uber.org/zap"
@ -33,7 +33,7 @@ type VariableValue struct {
SecretVar string `json:"secret_var"` SecretVar string `json:"secret_var"`
MatchingSecretParentPath string `json:"matching_secret_parent_path"` MatchingSecretParentPath string `json:"matching_secret_parent_path"`
When *types.When `json:"when"` When *cstypes.When `json:"when"`
} }
type VariableResponse struct { type VariableResponse struct {
@ -113,7 +113,7 @@ func (h *VariableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type CreateVariableRequest struct { type CreateVariableRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Values []types.VariableValue `json:"values,omitempty"` Values []cstypes.VariableValue `json:"values,omitempty"`
} }
type CreateVariableHandler struct { type CreateVariableHandler struct {
@ -160,7 +160,7 @@ func (h *CreateVariableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
type UpdateVariableRequest struct { type UpdateVariableRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Values []types.VariableValue `json:"values,omitempty"` Values []cstypes.VariableValue `json:"values,omitempty"`
} }
type UpdateVariableHandler struct { type UpdateVariableHandler struct {

View File

@ -28,6 +28,7 @@ import (
slog "agola.io/agola/internal/log" slog "agola.io/agola/internal/log"
"agola.io/agola/internal/services/config" "agola.io/agola/internal/services/config"
"agola.io/agola/internal/services/configstore" "agola.io/agola/internal/services/configstore"
cstypes "agola.io/agola/internal/services/configstore/types"
"agola.io/agola/internal/services/executor" "agola.io/agola/internal/services/executor"
"agola.io/agola/internal/services/gateway" "agola.io/agola/internal/services/gateway"
gwapi "agola.io/agola/internal/services/gateway/api" gwapi "agola.io/agola/internal/services/gateway/api"
@ -36,7 +37,6 @@ import (
rsscheduler "agola.io/agola/internal/services/runservice" rsscheduler "agola.io/agola/internal/services/runservice"
rstypes "agola.io/agola/internal/services/runservice/types" rstypes "agola.io/agola/internal/services/runservice/types"
"agola.io/agola/internal/services/scheduler" "agola.io/agola/internal/services/scheduler"
"agola.io/agola/internal/services/types"
"agola.io/agola/internal/testutil" "agola.io/agola/internal/testutil"
"agola.io/agola/internal/util" "agola.io/agola/internal/util"
@ -427,7 +427,7 @@ func createProject(ctx context.Context, t *testing.T, giteaClient *gitea.Client,
ParentRef: path.Join("user", agolaUser01), ParentRef: path.Join("user", agolaUser01),
RemoteSourceName: "gitea", RemoteSourceName: "gitea",
RepoPath: path.Join(giteaUser01, "repo01"), RepoPath: path.Join(giteaUser01, "repo01"),
Visibility: types.VisibilityPublic, Visibility: cstypes.VisibilityPublic,
}) })
if err != nil { if err != nil {
t.Fatalf("unexpected err: %v", err) t.Fatalf("unexpected err: %v", err)