Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
ksonnet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ijaz Ahmad
ksonnet
Commits
6f85019c
Commit
6f85019c
authored
7 years ago
by
Jessica Yuen
Browse files
Options
Downloads
Patches
Plain Diff
Add alias 'ks generate' for 'ks prototype use'
parent
b7ddd956
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/prototype.go
+14
-4
14 additions, 4 deletions
cmd/prototype.go
with
14 additions
and
4 deletions
cmd/prototype.go
+
14
−
4
View file @
6f85019c
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
func
init
()
{
func
init
()
{
RootCmd
.
AddCommand
(
prototypeCmd
)
RootCmd
.
AddCommand
(
prototypeCmd
)
RootCmd
.
AddCommand
(
generateCmd
)
prototypeCmd
.
AddCommand
(
prototypeListCmd
)
prototypeCmd
.
AddCommand
(
prototypeListCmd
)
prototypeCmd
.
AddCommand
(
prototypeDescribeCmd
)
prototypeCmd
.
AddCommand
(
prototypeDescribeCmd
)
prototypeCmd
.
AddCommand
(
prototypeSearchCmd
)
prototypeCmd
.
AddCommand
(
prototypeSearchCmd
)
...
@@ -271,6 +272,15 @@ unique enough to resolve to 'io.ksonnet.pkg.single-port-deployment'.`,
...
@@ -271,6 +272,15 @@ unique enough to resolve to 'io.ksonnet.pkg.single-port-deployment'.`,
--image=nginx`
,
--image=nginx`
,
}
}
// generateCmd acts as an alias for `prototype use`
var
generateCmd
=
&
cobra
.
Command
{
Use
:
"generate <prototype-name> <component-name> [type] [parameter-flags]"
,
Short
:
prototypeUseCmd
.
Short
,
DisableFlagParsing
:
prototypeUseCmd
.
DisableFlagParsing
,
RunE
:
prototypeUseCmd
.
RunE
,
Long
:
prototypeUseCmd
.
Long
,
}
var
prototypeUseCmd
=
&
cobra
.
Command
{
var
prototypeUseCmd
=
&
cobra
.
Command
{
Use
:
"use <prototype-name> <componentName> [type] [parameter-flags]"
,
Use
:
"use <prototype-name> <componentName> [type] [parameter-flags]"
,
Short
:
`Expand prototype, place in components/ directory of ksonnet app`
,
Short
:
`Expand prototype, place in components/ directory of ksonnet app`
,
...
@@ -282,11 +292,11 @@ var prototypeUseCmd = &cobra.Command{
...
@@ -282,11 +292,11 @@ var prototypeUseCmd = &cobra.Command{
}
}
manager
,
err
:=
metadata
.
Find
(
metadata
.
AbsPath
(
cwd
))
manager
,
err
:=
metadata
.
Find
(
metadata
.
AbsPath
(
cwd
))
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
'prototype use'
can only be run in a ksonnet application directory:
\n\n
%v"
,
err
)
return
fmt
.
Errorf
(
"
Command
can only be run in a ksonnet application directory:
\n\n
%v"
,
err
)
}
}
if
len
(
rawArgs
)
<
1
{
if
len
(
rawArgs
)
<
1
{
return
fmt
.
Errorf
(
"Command
'prototype preview'
requires a prototype name
\n\n
%s"
,
cmd
.
UsageString
())
return
fmt
.
Errorf
(
"Command requires a prototype name
\n\n
%s"
,
cmd
.
UsageString
())
}
}
query
:=
rawArgs
[
0
]
query
:=
rawArgs
[
0
]
...
@@ -311,7 +321,7 @@ var prototypeUseCmd = &cobra.Command{
...
@@ -311,7 +321,7 @@ var prototypeUseCmd = &cobra.Command{
var
componentName
string
var
componentName
string
var
templateType
prototype
.
TemplateType
var
templateType
prototype
.
TemplateType
if
args
:=
flags
.
Args
();
len
(
args
)
==
1
{
if
args
:=
flags
.
Args
();
len
(
args
)
==
1
{
return
fmt
.
Errorf
(
"
'prototype use'
is missing argument 'componentName'
\n\n
%s"
,
cmd
.
UsageString
())
return
fmt
.
Errorf
(
"
Command
is missing argument 'componentName'
\n\n
%s"
,
cmd
.
UsageString
())
}
else
if
len
(
args
)
==
2
{
}
else
if
len
(
args
)
==
2
{
componentName
=
args
[
1
]
componentName
=
args
[
1
]
templateType
=
prototype
.
Jsonnet
templateType
=
prototype
.
Jsonnet
...
@@ -322,7 +332,7 @@ var prototypeUseCmd = &cobra.Command{
...
@@ -322,7 +332,7 @@ var prototypeUseCmd = &cobra.Command{
return
err
return
err
}
}
}
else
{
}
else
{
return
fmt
.
Errorf
(
"
'prototype use'
has too many arguments (takes a prototype name and a component name)
\n\n
%s"
,
cmd
.
UsageString
())
return
fmt
.
Errorf
(
"
Command
has too many arguments (takes a prototype name and a component name)
\n\n
%s"
,
cmd
.
UsageString
())
}
}
params
,
err
:=
getParameters
(
proto
,
flags
)
params
,
err
:=
getParameters
(
proto
,
flags
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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