Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beaver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
beaver
Commits
ef4877d6d4e0
Commit
ef4877d6d4e0
authored
2 years ago
by
steeve.chailloux
Browse files
Options
Downloads
Patches
Plain Diff
runner: add Ytt type and Ytt.BuildArgs methode
parent
47583b2d05ff
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runner/config.go
+23
-4
23 additions, 4 deletions
runner/config.go
runner/config_test.go
+26
-0
26 additions, 0 deletions
runner/config_test.go
with
49 additions
and
4 deletions
runner/config.go
+
23
−
4
View file @
ef4877d6
...
...
@@ -109,7 +109,29 @@
type
CmdSpec
struct
{
Variables
[]
Variable
Charts
CmdCharts
Ytt
[]
string
Ytt
Ytt
}
type
Ytt
[]
string
func
(
y
Ytt
)
BuildArgs
(
namespace
string
,
compiled
[]
string
)
([]
string
,
error
)
{
// ytt -f $chartsTmpFile --file-mark "$(basename $chartsTmpFile):type=yaml-plain"\
// -f base/ytt/ -f base/ytt.yml -f ns1/ytt/ -f ns1/ytt.yml
var
args
[]
string
for
_
,
c
:=
range
compiled
{
args
=
append
(
args
,
"-f"
,
c
,
"--file-mark"
,
filepath
.
Base
(
c
))
}
for
_
,
entry
:=
range
[]
string
{
filepath
.
Join
(
"base"
,
"ytt"
),
filepath
.
Join
(
"base"
,
"ytt.yaml"
),
filepath
.
Join
(
"environments"
,
namespace
,
"ytt"
),
filepath
.
Join
(
"environments"
,
namespace
,
"ytt.yaml"
)}
{
if
_
,
err
:=
os
.
Stat
(
entry
);
!
os
.
IsExist
(
err
)
{
args
=
append
(
args
,
"-f"
,
entry
)
}
}
return
args
,
nil
}
type
CmdCharts
map
[
string
]
CmdChart
...
...
@@ -144,9 +166,6 @@
return
args
,
nil
}
// ytt -f $chartsTmpFile --file-mark "$(basename $chartsTmpFile):type=yaml-plain"\
// -f base/ytt/ -f base/ytt.yml -f ns1/ytt/ -f ns1/ytt.yml
func
cmdChartFromChart
(
c
Chart
)
CmdChart
{
return
CmdChart
{
Type
:
c
.
Type
,
...
...
This diff is collapsed.
Click to expand it.
runner/config_test.go
+
26
−
0
View file @
ef4877d6
package
runner
import
(
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
...
...
@@ -4,7 +5,8 @@
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"orus.io/cloudcrane/beaver/testutils"
)
func
TestConfig
(
t
*
testing
.
T
)
{
...
...
@@ -17,3 +19,27 @@
assert
.
Equal
(
t
,
"vendor/helm/postgresql"
,
config
.
Spec
.
Charts
[
"postgres"
]
.
Path
)
assert
.
Equal
(
t
,
"vendor/ytt/odoo"
,
config
.
Spec
.
Charts
[
"odoo"
]
.
Path
)
}
func
TestYttBuildArgs
(
t
*
testing
.
T
)
{
tl
:=
testutils
.
NewTestLogger
(
t
)
testNS
:=
"ns1"
absConfigDir
,
err
:=
filepath
.
Abs
(
"fixtures/"
)
require
.
NoError
(
t
,
err
)
c
:=
NewCmdConfig
(
tl
.
Logger
(),
absConfigDir
,
testNS
,
false
)
require
.
NoError
(
t
,
c
.
Initialize
())
args
,
err
:=
c
.
Spec
.
Ytt
.
BuildArgs
(
testNS
,
[]
string
{
"/tmp/postgres.1234.yaml"
,
"/tmp/odoo.5678.yaml"
})
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
args
,
[]
string
{
"-f"
,
"/tmp/postgres.1234.yaml"
,
"--file-mark"
,
"postgres.1234.yaml"
,
"-f"
,
"/tmp/odoo.5678.yaml"
,
"--file-mark"
,
"odoo.5678.yaml"
,
"-f"
,
"base/ytt"
,
"-f"
,
"base/ytt.yaml"
,
"-f"
,
"environments/ns1/ytt"
,
"-f"
,
"environments/ns1/ytt.yaml"
,
},
)
}
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