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
4275521f
Commit
4275521f
authored
7 years ago
by
Alex Clemmer
Browse files
Options
Downloads
Patches
Plain Diff
Transition system prototypes to ksonnet-lib beta.3
parent
b68464fd
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
prototype/systemPrototypes.go
+28
-236
28 additions, 236 deletions
prototype/systemPrototypes.go
with
28 additions
and
236 deletions
prototype/systemPrototypes.go
+
28
−
236
View file @
4275521f
...
...
@@ -11,33 +11,13 @@ var defaultPrototypes = []*SpecificationSchema{
Description
:
`A simple namespace. Labels are automatically populated from the name of the
namespace.`
,
ShortDescription
:
`Namespace with labels automatically populated from the name`
,
YAMLBody
:
[]
string
{
"kind: Namespace"
,
"apiVersion: v1"
,
"metadata:"
,
" name: ${name}"
,
" labels:"
,
" name: ${name}"
,
},
JSONBody
:
[]
string
{
`{`
,
` "kind": "Namespace",`
,
` "apiVersion": "v1",`
,
` "metadata": {`
,
` "name": ${name},`
,
` "labels": {`
,
` "name": ${name}`
,
` }`
,
` }`
,
`}`
,
},
JsonnetBody
:
[]
string
{
`local k = import "k.libsonnet";`
,
`local n
s
= k.core.v1.namespace;`
,
`local n
amespace
= k.core.v1.namespace;`
,
``
,
`n
s.new() +
`
,
`
ns.mixin.metadata.name
(import 'param://name')
+
`
,
`
ns.mixin.metadata.l
abels({name: import 'param://name'})`
,
`n
amespace
`
,
`
.new
(import 'param://name')`
,
`
.withL
abels({name: import 'param://name'})`
,
},
},
},
...
...
@@ -60,51 +40,17 @@ will typically look something like:
ks prototype use service --targetLabelSelector "{app: 'nginx'}" [...]`
,
ShortDescription
:
`Service that exposes a single port`
,
YAMLBody
:
[]
string
{
`kind: Service`
,
`apiVersion: v1`
,
`metadata:`
,
` name: ${name}`
,
`spec:`
,
` selector:`
,
` ${targetLabelSelector}`
,
` type: ${type}`
,
` ports:`
,
` - protocol: ${protocol}`
,
` port: ${servicePort}`
,
` targetPort: ${targetPort}`
,
},
JSONBody
:
[]
string
{
`{`
,
` "kind": "Service",`
,
` "apiVersion": "v1",`
,
` "metadata": {`
,
` "name": ${name}`
,
` },`
,
` "spec": {`
,
` "selector":`
,
` ${targetLabelSelector},`
,
` "type": ${type},`
,
` "ports": [`
,
` {`
,
` "protocol": ${protocol},`
,
` "port": ${servicePort},`
,
` "targetPort": ${targetPort}`
,
` }`
,
` ]`
,
` }`
,
`}`
,
},
JsonnetBody
:
[]
string
{
`local k = import "k.libsonnet";`
,
`local service = k.core.v1.service;`
,
`local port = k.core.v1.service.mixin.spec.portsType;`
,
``
,
`service.new(`
,
` import 'param://name',`
,
` import 'param://targetLabelSelector',`
,
` port.new(import 'param://servicePort', import 'param://targetPort')) +`
,
`service.mixin.spec.type(import 'param://type')`
,
`service`
,
` .new(`
,
` import 'param://name',`
,
` import 'param://targetLabelSelector',`
,
` port.new(import 'param://servicePort', import 'param://targetPort'))`
,
` .withType(import 'param://type')`
,
},
},
},
...
...
@@ -123,95 +69,6 @@ will typically look something like:
Description
:
`A service that exposes 'servicePort', and directs traffic
to 'targetLabelSelector', at 'targetPort'.`
,
ShortDescription
:
`A deployment exposed with a service`
,
YAMLBody
:
[]
string
{
`apiVersion: v1`
,
`items:`
,
` - apiVersion: v1`
,
` kind: Service`
,
` metadata:`
,
` name: ${name}`
,
` spec:`
,
` ports:`
,
` - port: ${servicePort}`
,
` targetPort: ${containerPort}`
,
` selector:`
,
` app: ${name}`
,
` type: ${type}`
,
` - apiVersion: apps/v1beta1`
,
` kind: Deployment`
,
` metadata:`
,
` name: ${name}`
,
` spec:`
,
` replicas: ${replicas}`
,
` template:`
,
` metadata:`
,
` labels:`
,
` app: ${name}`
,
` spec:`
,
` containers:`
,
` - image: ${name}`
,
` name: ${image}`
,
` ports:`
,
` - containerPort: ${containerPort}`
,
`kind: List`
,
},
JSONBody
:
[]
string
{
`{`
,
` "apiVersion": "v1",`
,
` "items": [`
,
` {`
,
` "apiVersion": "v1",`
,
` "kind": "Service",`
,
` "metadata": {`
,
` "name": ${name}`
,
` },`
,
` "spec": {`
,
` "ports": [`
,
` {`
,
` "port": ${servicePort},`
,
` "targetPort": ${containerPort}`
,
` }`
,
` ],`
,
` "selector": {`
,
` "app": ${name}`
,
` },`
,
` "type": ${type}`
,
` }`
,
` },`
,
` {`
,
` "apiVersion": "apps/v1beta1",`
,
` "kind": "Deployment",`
,
` "metadata": {`
,
` "name": ${name}`
,
` },`
,
` "spec": {`
,
` "replicas": ${replicas},`
,
` "template": {`
,
` "metadata": {`
,
` "labels": {`
,
` "app": ${name}`
,
` }`
,
` },`
,
` "spec": {`
,
` "containers": [`
,
` {`
,
` "image": ${name},`
,
` "name": ${image},`
,
` "ports": [`
,
` {`
,
` "containerPort": ${containerPort}`
,
` }`
,
` ]`
,
` }`
,
` ]`
,
` }`
,
` }`
,
` }`
,
` }`
,
` ],`
,
` "kind": "List"`
,
`}`
,
},
JsonnetBody
:
[]
string
{
`local k = import "k.libsonnet";`
,
`local deployment = k.apps.v1beta1.deployment;`
,
...
...
@@ -223,18 +80,21 @@ to 'targetLabelSelector', at 'targetPort'.`,
`local targetPort = import 'param://containerPort';`
,
`local labels = {app: import 'param://name'};`
,
``
,
`local appService = service.new(`
,
` import 'param://name',`
,
` labels,`
,
` servicePort.new(import 'param://servicePort', targetPort)) +`
,
`service.mixin.spec.type(import 'param://type');`
,
`local appService = service`
,
` .new(`
,
` import 'param://name',`
,
` labels,`
,
` servicePort.new(import 'param://servicePort', targetPort))`
,
` .withType(import 'param://type');`
,
``
,
`local appDeployment = deployment.new(`
,
` import 'param://name',`
,
` import 'param://replicas',`
,
` container.new(import 'param://name', import 'param://image') +`
,
` container.ports(containerPort.new(targetPort)),`
,
` labels);`
,
`local appDeployment = deployment`
,
` .new(`
,
` import 'param://name',`
,
` import 'param://replicas',`
,
` container`
,
` .new(import 'param://name', import 'param://image')`
,
` .withPorts(containerPort.new(targetPort)),`
,
` labels);`
,
``
,
`k.core.v1.list.new([appService, appDeployment])`
,
},
...
...
@@ -250,30 +110,11 @@ to 'targetLabelSelector', at 'targetPort'.`,
Template
:
SnippetSchema
{
Description
:
`A simple config map with optional user-specified data.`
,
ShortDescription
:
`A simple config map with optional user-specified data`
,
YAMLBody
:
[]
string
{
"apiVersion: v1"
,
"kind: ConfigMap"
,
"metadata:"
,
" name: ${name}"
,
"data: ${data}"
,
},
JSONBody
:
[]
string
{
`{`
,
` "apiVersion": "v1",`
,
` "kind": "ConfigMap",`
,
` "metadata": {`
,
` "name": ${name}`
,
` },`
,
` "data": ${data}`
,
`}`
,
},
JsonnetBody
:
[]
string
{
`local k = import "k.libsonnet";`
,
`local configMap = k.core.v1.configMap;`
,
``
,
`configMap.new() +`
,
`configMap.mixin.metadata.name(import 'param://name') +`
,
`configMap.data(import 'param://data')`
,
`configMap.new(import 'param://name', import 'param://data')`
,
},
},
},
...
...
@@ -291,56 +132,6 @@ to 'targetLabelSelector', at 'targetPort'.`,
(default: 1), and exposes a port (default: 80). Labels are automatically
populated from 'name'.`
,
ShortDescription
:
`Replicates a container n times, exposes a single port`
,
YAMLBody
:
[]
string
{
"apiVersion: apps/v1beta1"
,
"kind: Deployment"
,
"metadata:"
,
" name: ${name}"
,
"spec:"
,
" replicas: ${replicas:1}"
,
" template:"
,
" metadata:"
,
" labels:"
,
" app: ${name}"
,
" spec:"
,
" containers:"
,
" - name: ${name}"
,
" image: ${image}"
,
" ports:"
,
" - containerPort: ${port:80}"
,
},
JSONBody
:
[]
string
{
`{`
,
` "apiVersion": "apps/v1beta1",`
,
` "kind": "Deployment",`
,
` "metadata": {`
,
` "name": ${name}`
,
` },`
,
` "spec": {`
,
` "replicas": ${replicas:1},`
,
` "template": {`
,
` "metadata": {`
,
` "labels": {`
,
` "app": ${name}`
,
` }`
,
` },`
,
` "spec": {`
,
` "containers": [`
,
` {`
,
` "name": ${name},`
,
` "image": ${image},`
,
` "ports": [`
,
` {`
,
` "containerPort": ${port:80}`
,
` }`
,
` ]`
,
` }`
,
` ]`
,
` }`
,
` }`
,
` }`
,
`}`
,
},
JsonnetBody
:
[]
string
{
`local k = import "k.libsonnet";`
,
`local deployment = k.apps.v1beta1.deployment;`
,
...
...
@@ -350,8 +141,9 @@ populated from 'name'.`,
`deployment.new(`
,
` import 'param://name',`
,
` import 'param://replicas',`
,
` container.new(import 'param://name', import 'param://image') +`
,
` container.ports(port.new(import 'param://port')),`
,
` container`
,
` .new(import 'param://name', import 'param://image')`
,
` .withPorts(port.new(import 'param://port')),`
,
` {app: import 'param://name'})`
,
},
},
...
...
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