github.com/jchauncey/draft@v0.3.0/pkg/draft/defaultpacks/golang.go (about)

     1  package defaultpacks
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"github.com/Azure/draft/pkg/draft/pack"
     7  )
     8  
     9  const golangValues = `# Default values for golang.
    10  # This is a YAML-formatted file.
    11  # Declare variables to be passed into your templates.
    12  replicaCount: 2
    13  image:
    14    registry: docker.io
    15    org: library
    16    name: golang
    17    tag: onbuild
    18    pullPolicy: IfNotPresent
    19  service:
    20    name: golang
    21    type: ClusterIP
    22    externalPort: 80
    23    internalPort: 8080
    24  resources:
    25    limits:
    26      cpu: 100m
    27      memory: 128Mi
    28    requests:
    29      cpu: 100m
    30      memory: 128Mi
    31  `
    32  
    33  const golangDetect = `
    34  #!/usr/bin/env bash
    35  # bin/detect <build-dir>
    36  set -e
    37  
    38  build=$(cd "$1/" && pwd)
    39  
    40  if test -f "${build}/Godeps/Godeps.json" || # godeps
    41     test -f "${build}/vendor/vendor.json" || # govendor
    42     test -f "${build}/glide.yaml" || # glide
    43     (test -d "${build}/src" && test -n "$(find "${build}/src" -mindepth 2 -type f -name '*.go' | sed 1q)") # gb
    44  then
    45    echo Go
    46  else
    47    exit 1
    48  fi
    49  `
    50  
    51  const golangDockerfile = `FROM golang:onbuild
    52  EXPOSE 8080
    53  `
    54  
    55  // GolangFiles returns all of the files needed for the golang default pack
    56  // Paths are relative to the pack root
    57  func GolangFiles() []*pack.File {
    58  	return []*pack.File{
    59  		{
    60  			// values.yaml
    61  			Path:    filepath.Join(pack.ChartDir, pack.ValuesfileName),
    62  			Content: []byte(golangValues),
    63  			Perm:    0644,
    64  		},
    65  		{
    66  			// .helmignore
    67  			Path:    filepath.Join(pack.ChartDir, pack.IgnorefileName),
    68  			Content: []byte(commonIgnore),
    69  			Perm:    0644,
    70  		},
    71  		{
    72  			// deployment.yaml
    73  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.DeploymentName),
    74  			Content: []byte(commonDeployment),
    75  			Perm:    0644,
    76  		},
    77  		{
    78  			// service.yaml
    79  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.ServiceName),
    80  			Content: []byte(commonService),
    81  			Perm:    0644,
    82  		},
    83  		{
    84  			// ingress.yaml
    85  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.IngressName),
    86  			Content: []byte(commonIngress),
    87  			Perm:    0644,
    88  		},
    89  		{
    90  			// NOTES.txt
    91  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.NotesName),
    92  			Content: []byte(commonNotes),
    93  			Perm:    0644,
    94  		},
    95  		{
    96  			// _helpers.tpl
    97  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.HelpersName),
    98  			Content: []byte(commonHelpers),
    99  			Perm:    0644,
   100  		},
   101  		{
   102  			// detect
   103  			Path:    filepath.Join(pack.DetectName),
   104  			Content: []byte(golangDetect),
   105  			Perm:    0755,
   106  		},
   107  		{
   108  			// NOTICE
   109  			Path:    filepath.Join(pack.HerokuLicenseName),
   110  			Content: []byte(commonHerokuLicense),
   111  			Perm:    0644,
   112  		},
   113  		{
   114  			// Dockerfile
   115  			Path:    filepath.Join(pack.DockerfileName),
   116  			Content: []byte(golangDockerfile),
   117  			Perm:    0644,
   118  		},
   119  		{
   120  			// .dockerignore
   121  			Path:    filepath.Join(pack.DockerignoreName),
   122  			Content: []byte(commonDockerignore),
   123  			Perm:    0644,
   124  		},
   125  	}
   126  }