Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
flux2
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
GitHub Mirror
fluxcd
flux2
Commits
a0ed1c20
Commit
a0ed1c20
authored
5 years ago
by
stefanprodan
Browse files
Options
Downloads
Patches
Plain Diff
Add git tag option to create source
parent
1d7b8cd5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/tk/create_source.go
+26
-10
26 additions, 10 deletions
cmd/tk/create_source.go
with
26 additions
and
10 deletions
cmd/tk/create_source.go
+
26
−
10
View file @
a0ed1c20
...
@@ -28,16 +28,30 @@ The create source command generates a source.fluxcd.io resource and waits for it
...
@@ -28,16 +28,30 @@ The create source command generates a source.fluxcd.io resource and waits for it
For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret.
For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret.
For private Git repositories, the basic authentication credentials are stored in a Kubernetes secret.`
,
For private Git repositories, the basic authentication credentials are stored in a Kubernetes secret.`
,
Example
:
` # Create a source from a public Git repository master branch
Example
:
` # Create a source from a public Git repository master branch
create source podinfo --git-url https://github.com/stefanprodan/podinfo-deploy --git-branch master
create source podinfo \
--git-url=https://github.com/stefanprodan/podinfo \
--git-branch=master
# Create a source from a Git repository pinned to specific git tag
create source podinfo \
--git-url=https://github.com/stefanprodan/podinfo \
--git-tag="3.2.3"
# Create a source from a public Git repository tag that matches a semver range
# Create a source from a public Git repository tag that matches a semver range
create source podinfo --git-url https://github.com/stefanprodan/podinfo-deploy --git-semver=">=0.0.1-rc.1 <0.1.0"
create source podinfo \
--git-url=https://github.com/stefanprodan/podinfo \
--git-semver=">=3.2.0 <3.3.0"
# Create a source from a Git repository using SSH authentication
# Create a source from a Git repository using SSH authentication
create source podinfo --git-url ssh://git@github.com/stefanprodan/podinfo-deploy
create source podinfo \
--git-url=ssh://git@github.com/stefanprodan/podinfo \
--git-branch=master
# Create a source from a Git repository using basic authentication
# Create a source from a Git repository using basic authentication
create source podinfo --git-url https://github.com/stefanprodan/podinfo-deploy -u username -p password
create source podinfo \
--git-url=https://github.com/stefanprodan/podinfo \
--username=username \
--password=password
`
,
`
,
RunE
:
createSourceCmdRun
,
RunE
:
createSourceCmdRun
,
}
}
...
@@ -45,6 +59,7 @@ For private Git repositories, the basic authentication credentials are stored in
...
@@ -45,6 +59,7 @@ For private Git repositories, the basic authentication credentials are stored in
var
(
var
(
sourceGitURL
string
sourceGitURL
string
sourceGitBranch
string
sourceGitBranch
string
sourceGitTag
string
sourceGitSemver
string
sourceGitSemver
string
sourceUsername
string
sourceUsername
string
sourcePassword
string
sourcePassword
string
...
@@ -53,6 +68,7 @@ var (
...
@@ -53,6 +68,7 @@ var (
func
init
()
{
func
init
()
{
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitURL
,
"git-url"
,
""
,
"git address, e.g. ssh://git@host/org/repository"
)
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitURL
,
"git-url"
,
""
,
"git address, e.g. ssh://git@host/org/repository"
)
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitBranch
,
"git-branch"
,
"master"
,
"git branch"
)
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitBranch
,
"git-branch"
,
"master"
,
"git branch"
)
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitTag
,
"git-tag"
,
""
,
"git tag"
)
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitSemver
,
"git-semver"
,
""
,
"git tag semver range"
)
createSourceCmd
.
Flags
()
.
StringVar
(
&
sourceGitSemver
,
"git-semver"
,
""
,
"git tag semver range"
)
createSourceCmd
.
Flags
()
.
StringVarP
(
&
sourceUsername
,
"username"
,
"u"
,
""
,
"basic authentication username"
)
createSourceCmd
.
Flags
()
.
StringVarP
(
&
sourceUsername
,
"username"
,
"u"
,
""
,
"basic authentication username"
)
createSourceCmd
.
Flags
()
.
StringVarP
(
&
sourcePassword
,
"password"
,
"p"
,
""
,
"basic authentication password"
)
createSourceCmd
.
Flags
()
.
StringVarP
(
&
sourcePassword
,
"password"
,
"p"
,
""
,
"basic authentication password"
)
...
@@ -109,6 +125,7 @@ func createSourceCmdRun(cmd *cobra.Command, args []string) error {
...
@@ -109,6 +125,7 @@ func createSourceCmdRun(cmd *cobra.Command, args []string) error {
Interval
:
metav1
.
Duration
{
Interval
:
metav1
.
Duration
{
Duration
:
interval
,
Duration
:
interval
,
},
},
Reference
:
&
sourcev1
.
GitRepositoryRef
{},
},
},
}
}
...
@@ -117,14 +134,13 @@ func createSourceCmdRun(cmd *cobra.Command, args []string) error {
...
@@ -117,14 +134,13 @@ func createSourceCmdRun(cmd *cobra.Command, args []string) error {
Name
:
name
,
Name
:
name
,
}
}
}
}
if
sourceGitSemver
!=
""
{
if
sourceGitSemver
!=
""
{
gitRepository
.
Spec
.
Reference
=
&
source
v1
.
GitRepositoryRef
{
gitRepository
.
Spec
.
Reference
.
SemVer
=
source
GitSemver
SemVer
:
sourceGit
Semver
,
}
else
if
sourceGit
Tag
!=
""
{
}
gitRepository
.
Spec
.
Reference
.
Tag
=
sourceGitTag
}
else
{
}
else
{
gitRepository
.
Spec
.
Reference
=
&
sourcev1
.
GitRepositoryRef
{
gitRepository
.
Spec
.
Reference
.
Branch
=
sourceGitBranch
Branch
:
sourceGitBranch
,
}
}
}
kubeClient
,
err
:=
utils
.
kubeClient
(
kubeconfig
)
kubeClient
,
err
:=
utils
.
kubeClient
(
kubeconfig
)
...
...
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