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
9fc121fe
Commit
9fc121fe
authored
7 years ago
by
Alex Clemmer
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #151 from hausdorff/proto-list
Add `prototype list` command
parents
e21a8e17
f70428dd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/prototype.go
+24
-0
24 additions, 0 deletions
cmd/prototype.go
prototype/index.go
+8
-0
8 additions, 0 deletions
prototype/index.go
prototype/interface.go
+1
-0
1 addition, 0 deletions
prototype/interface.go
with
33 additions
and
0 deletions
cmd/prototype.go
+
24
−
0
View file @
9fc121fe
...
...
@@ -26,6 +26,7 @@ import (
func
init
()
{
RootCmd
.
AddCommand
(
prototypeCmd
)
prototypeCmd
.
AddCommand
(
prototypeListCmd
)
prototypeCmd
.
AddCommand
(
prototypeDescribeCmd
)
prototypeCmd
.
AddCommand
(
prototypeSearchCmd
)
prototypeCmd
.
AddCommand
(
prototypeUseCmd
)
...
...
@@ -77,6 +78,29 @@ Commands:
ksonnet prototype search deployment`
,
}
var
prototypeListCmd
=
&
cobra
.
Command
{
Use
:
"list <name-substring>"
,
Short
:
`List all known ksonnet prototypes`
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
!=
0
{
return
fmt
.
Errorf
(
"Command 'prototype list' does not take any arguments"
)
}
index
:=
prototype
.
NewIndex
([]
*
prototype
.
SpecificationSchema
{})
protos
,
err
:=
index
.
List
()
if
err
!=
nil
{
return
err
}
else
if
len
(
protos
)
==
0
{
return
fmt
.
Errorf
(
"No prototypes found"
)
}
fmt
.
Print
(
protos
)
return
nil
},
Long
:
`List all known ksonnet prototypes.`
,
}
var
prototypeDescribeCmd
=
&
cobra
.
Command
{
Use
:
"describe <prototype-name>"
,
Short
:
`Describe a ksonnet prototype`
,
...
...
This diff is collapsed.
Click to expand it.
prototype/index.go
+
8
−
0
View file @
9fc121fe
...
...
@@ -13,6 +13,14 @@ type index struct {
prototypes
map
[
string
]
*
SpecificationSchema
}
func
(
idx
*
index
)
List
()
(
SpecificationSchemas
,
error
)
{
prototypes
:=
[]
*
SpecificationSchema
{}
for
_
,
prototype
:=
range
idx
.
prototypes
{
prototypes
=
append
(
prototypes
,
prototype
)
}
return
prototypes
,
nil
}
func
(
idx
*
index
)
SearchNames
(
query
string
,
opts
SearchOptions
)
(
SpecificationSchemas
,
error
)
{
// TODO(hausdorff): This is the world's worst search algorithm. Improve it at
// some point.
...
...
This diff is collapsed.
Click to expand it.
prototype/interface.go
+
1
−
0
View file @
9fc121fe
...
...
@@ -31,6 +31,7 @@ const (
// Index represents a queryable index of prototype specifications.
type
Index
interface
{
List
()
(
SpecificationSchemas
,
error
)
SearchNames
(
query
string
,
opts
SearchOptions
)
(
SpecificationSchemas
,
error
)
}
...
...
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