Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
19ea2386
Commit
19ea2386
authored
1 year ago
by
Danis Kirasirov
Committed by
Pavel Antonov
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Удален метод получения Organization для объекта System, который используется в шаблонах
parent
ba6ead1a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/template/builder.go
+4
-9
4 additions, 9 deletions
pkg/template/builder.go
pkg/template/builder_test.go
+0
-21
0 additions, 21 deletions
pkg/template/builder_test.go
pkg/template/system.go
+0
-24
0 additions, 24 deletions
pkg/template/system.go
with
4 additions
and
54 deletions
pkg/template/builder.go
+
4
−
9
View file @
19ea2386
...
...
@@ -5,17 +5,14 @@ import (
"context"
"text/template"
"git.perx.ru/perxis/perxis-go/pkg/account"
"git.perx.ru/perxis/perxis-go/pkg/collections"
"git.perx.ru/perxis/perxis-go/pkg/content"
"git.perx.ru/perxis/perxis-go/pkg/environments"
"git.perx.ru/perxis/perxis-go/pkg/organizations"
"git.perx.ru/perxis/perxis-go/pkg/spaces"
)
type
Builder
struct
{
ctx
context
.
Context
acc
*
account
.
Account
cnt
*
content
.
Content
SpaceID
string
EnvID
string
...
...
@@ -26,13 +23,11 @@ type Builder struct {
space
*
spaces
.
Space
environment
*
environments
.
Environment
collection
*
collections
.
Collection
organization
*
organizations
.
Organization
}
func
NewBuilder
(
acc
*
account
.
Account
,
cnt
*
content
.
Content
,
space
,
env
,
col
string
)
*
Builder
{
func
NewBuilder
(
cnt
*
content
.
Content
,
space
,
env
,
col
string
)
*
Builder
{
return
&
Builder
{
ctx
:
context
.
Background
(),
acc
:
acc
,
cnt
:
cnt
,
SpaceID
:
space
,
EnvID
:
env
,
...
...
This diff is collapsed.
Click to expand it.
pkg/template/builder_test.go
+
0
−
21
View file @
19ea2386
...
...
@@ -5,7 +5,6 @@ import (
"errors"
"testing"
"git.perx.ru/perxis/perxis-go/pkg/account"
"git.perx.ru/perxis/perxis-go/pkg/collections"
colsmocks
"git.perx.ru/perxis/perxis-go/pkg/collections/mocks"
"git.perx.ru/perxis/perxis-go/pkg/content"
...
...
@@ -13,8 +12,6 @@ import (
envsmocks
"git.perx.ru/perxis/perxis-go/pkg/environments/mocks"
"git.perx.ru/perxis/perxis-go/pkg/items"
mocksitems
"git.perx.ru/perxis/perxis-go/pkg/items/mocks"
"git.perx.ru/perxis/perxis-go/pkg/organizations"
orgsmocks
"git.perx.ru/perxis/perxis-go/pkg/organizations/mocks"
"git.perx.ru/perxis/perxis-go/pkg/spaces"
spsmocks
"git.perx.ru/perxis/perxis-go/pkg/spaces/mocks"
"github.com/stretchr/testify/assert"
...
...
@@ -31,7 +28,6 @@ func TestBuilder_Execute(t *testing.T) {
want
any
wantErr
bool
getAcc
func
()
(
acc
*
account
.
Account
,
assertExpectations
func
(
t
*
testing
.
T
))
getCnt
func
()
(
cnt
*
content
.
Content
,
assertExpectations
func
(
t
*
testing
.
T
))
}{
{
name
:
"error"
,
str
:
"hello {{ .a }}"
,
data
:
"world"
,
want
:
""
,
wantErr
:
true
},
...
...
@@ -100,15 +96,6 @@ func TestBuilder_Execute(t *testing.T) {
}},
{
name
:
"lookup without itemID"
,
SpaceID
:
"space"
,
EnvID
:
"env"
,
str
:
"hello {{ lookup
\"
secrets.pass
\"
}}"
,
data
:
""
,
want
:
""
,
wantErr
:
true
},
{
name
:
"system#1"
,
SpaceID
:
"space"
,
str
:
"hello {{ system.SpaceID }}"
,
data
:
""
,
want
:
"hello space"
,
wantErr
:
false
},
{
name
:
"system organization"
,
SpaceID
:
"space"
,
EnvID
:
"env"
,
getCnt
:
func
()
(
cnt
*
content
.
Content
,
assertExpectations
func
(
t
*
testing
.
T
))
{
spsSvc
:=
&
spsmocks
.
Spaces
{}
spsSvc
.
On
(
"Get"
,
context
.
Background
(),
"space"
)
.
Return
(
&
spaces
.
Space
{
OrgID
:
"orgid"
},
nil
)
.
Once
()
return
&
content
.
Content
{
Spaces
:
spsSvc
},
func
(
t
*
testing
.
T
)
{
spsSvc
.
AssertExpectations
(
t
)
}
},
getAcc
:
func
()
(
acc
*
account
.
Account
,
assertExpectations
func
(
t
*
testing
.
T
))
{
orgsSvc
:=
&
orgsmocks
.
Organizations
{}
orgsSvc
.
On
(
"Get"
,
context
.
Background
(),
"orgid"
)
.
Return
(
&
organizations
.
Organization
{
Name
:
"Org"
},
nil
)
.
Once
()
return
&
account
.
Account
{
Organizations
:
orgsSvc
},
func
(
t
*
testing
.
T
)
{
orgsSvc
.
AssertExpectations
(
t
)
}
},
str
:
"hello {{ system.Organization.Name }}"
,
want
:
"hello Org"
,
wantErr
:
false
},
{
name
:
"system space"
,
SpaceID
:
"space"
,
getCnt
:
func
()
(
cnt
*
content
.
Content
,
assertExpectations
func
(
t
*
testing
.
T
))
{
spsSvc
:=
&
spsmocks
.
Spaces
{}
spsSvc
.
On
(
"Get"
,
context
.
Background
(),
"space"
)
.
Return
(
&
spaces
.
Space
{
Description
:
"description"
},
nil
)
.
Once
()
...
...
@@ -128,14 +115,7 @@ func TestBuilder_Execute(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
var
acc
*
account
.
Account
var
cnt
*
content
.
Content
if
tt
.
getAcc
!=
nil
{
var
checkFn
func
(
*
testing
.
T
)
acc
,
checkFn
=
tt
.
getAcc
()
defer
checkFn
(
t
)
}
if
tt
.
getCnt
!=
nil
{
var
checkFn
func
(
*
testing
.
T
)
cnt
,
checkFn
=
tt
.
getCnt
()
...
...
@@ -144,7 +124,6 @@ func TestBuilder_Execute(t *testing.T) {
b
:=
&
Builder
{
ctx
:
context
.
Background
(),
acc
:
acc
,
cnt
:
cnt
,
SpaceID
:
tt
.
SpaceID
,
EnvID
:
tt
.
EnvID
,
...
...
This diff is collapsed.
Click to expand it.
pkg/template/system.go
+
0
−
24
View file @
19ea2386
...
...
@@ -3,7 +3,6 @@ package template
import
(
"git.perx.ru/perxis/perxis-go/pkg/collections"
"git.perx.ru/perxis/perxis-go/pkg/environments"
"git.perx.ru/perxis/perxis-go/pkg/organizations"
"git.perx.ru/perxis/perxis-go/pkg/spaces"
)
...
...
@@ -23,14 +22,6 @@ func (s *System) CollectionID() string {
return
s
.
builder
.
CollID
}
func
(
s
*
System
)
OrganizationID
()
(
string
,
error
)
{
org
,
err
:=
s
.
Organization
()
if
err
!=
nil
{
return
""
,
err
}
return
org
.
ID
,
nil
}
func
(
s
*
System
)
Space
()
(
*
spaces
.
Space
,
error
)
{
if
s
.
builder
.
space
!=
nil
{
return
s
.
builder
.
space
,
nil
...
...
@@ -60,18 +51,3 @@ func (s *System) Collection() (*collections.Collection, error) {
s
.
builder
.
collection
=
coll
return
s
.
builder
.
collection
,
err
}
func
(
s
*
System
)
Organization
()
(
*
organizations
.
Organization
,
error
)
{
if
s
.
builder
.
organization
!=
nil
{
return
s
.
builder
.
organization
,
nil
}
sp
,
err
:=
s
.
Space
()
if
err
!=
nil
{
return
nil
,
err
}
org
,
err
:=
s
.
builder
.
acc
.
Organizations
.
Get
(
s
.
builder
.
ctx
,
sp
.
OrgID
)
s
.
builder
.
organization
=
org
return
s
.
builder
.
organization
,
err
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment