-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
131 lines (101 loc) · 3.77 KB
/
init.go
File metadata and controls
131 lines (101 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package main
import (
"fmt"
"github.com/fatih/color"
"io/ioutil"
"os"
)
var configTemplate = []byte(`
apiVersion: v1
kind: Config
preferences: {}
# Set the default context to use
current-context: dev
# Provide a link between a cluster and user
contexts:
- name: dev
context:
# Name of cluster profile
cluster: dev
# Name of user profile
user: dev
# Define the available Kubernetes clusters for the environment
clusters:
# Lists the information for your Kubernetes clusers (we will only setup one per environment)
# This information dictates:
# - where the API server endpoint is (server)
# - what version the API is compatible with (api-version)
# - whether to require a valid certificate (insecure-skip-tls-verify)
# - what certificate autority to expect:
# -- (certificate-authority) for a file path to the certificate
# -- (certificate-authority-data) for a base64 encoding of the certificate data
- name: dev
cluster:
# Server is the address of the kubernetes cluster (https://hostname:port).
server: https://uri-to-kubernetes-api:listening-port/
# APIVersion is the preferred api version for communicating with the kubernetes cluster (v1beta1, v1beta2, v1beta3, etc).
api-version: v1beta3
# InsecureSkipTLSVerify skips the validity check for the server's certificate.
# This will make your HTTPS connections insecure.
insecure-skip-tls-verify: false
# Use one of the options below for CA validation
# CertificateAuthority is the path to a cert file for the certificate authority.
certificate-authority:
# CertificateAuthorityData contains PEM-encoded certificate authority certificates.
# Overrides CertificateAuthority.
certificate-authority-data:
# Define the available users for the environment
users:
#
- name: dev
user:
# The following are the available authentication options using the Kubernetes API.
# Configure the correct option which is configured on your Kubernetes API.
# Option 1
# Token-based authentication
# Token is the bearer token for authentication to the kubernetes cluster.
token:
# Option 2
# Password-based authentication
# Username is the username for basic authentication to the kubernetes cluster.
username:
# Password is the password for basic authentication to the kubernetes cluster.
password:
# Option 3
# Key-based authentication
# ClientCertificate is the path to a client cert file for TLS.
client-certificate:
# ClientCertificateData contains PEM-encoded data from a client cert file for TLS. Overrides ClientCertificate.
client-certificate-data:
# ClientKey is the path to a client key file for TLS.
client-key:
# ClientKeyData contains PEM-encoded data from a client key file for TLS. Overrides ClientKey.
client-key-data:
# Option 4
# AuthPath is the path to a kubernetes auth file (~/.kubernetes_auth).
# If you provide an AuthPath, the other options specified are ignored
#auth-path:
`)
func (app *appConfig) Init() {
dirs := []string{
app.workingDir + "/dist",
app.workingDir + "/templates",
app.envDir + "/partials",
}
for _, directory := range dirs {
// Initialise Directories
err = os.MkdirAll(directory, 0755)
if err != nil {
color.Red(fmt.Sprintf("Could not create folder: %s", directory))
os.Exit(1)
}
color.Green(fmt.Sprintf("Created folder: %s", directory))
}
// Initialise environment file
err := ioutil.WriteFile(app.envFile, configTemplate, 0644)
if err != nil {
color.Red(fmt.Sprintf("Could not create environment file: %s", app.envFile))
os.Exit(1)
}
color.Green(fmt.Sprintf("Created environment file: %s", app.envFile))
}