Skip to content

Commit

Permalink
Uniformate spaciing in comments gbefore function definition
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Vito Moscaritolo <[email protected]>
  • Loading branch information
mavimo committed Nov 25, 2018
1 parent c596f12 commit e31d20d
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 112 deletions.
22 changes: 11 additions & 11 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var DefaultConfigPath string
// AppConf is the default configuration from the local system.
var AppConf = NewAppConfig()

//AppSSHClient is the SSH client
// AppSSHClient is the SSH client
type AppSSHClient struct {
}

Expand All @@ -45,7 +45,7 @@ func NewAppConfig() AppConfig {
return appConf
}

//WriteCurrentConfig write the configuration to file
// WriteCurrentConfig write the configuration to file
func (config HetznerConfig) WriteCurrentConfig() {
configFileName := filepath.Join(DefaultConfigPath, "config.json")
configJSON, err := json.Marshal(&config)
Expand All @@ -61,17 +61,17 @@ func (config HetznerConfig) WriteCurrentConfig() {
}
}

//AddContext add context to config
// AddContext add context to config
func (config *HetznerConfig) AddContext(context HetznerContext) {
config.Contexts = append(config.Contexts, context)
}

//AddSSHKey add a new SSH key to config
// AddSSHKey add a new SSH key to config
func (config *HetznerConfig) AddSSHKey(key clustermanager.SSHKey) {
config.SSHKeys = append(config.SSHKeys, key)
}

//DeleteSSHKey remove the SSH key from config
// DeleteSSHKey remove the SSH key from config
func (config *HetznerConfig) DeleteSSHKey(name string) error {

index, err := config.FindSSHKeyByName(name)
Expand All @@ -84,7 +84,7 @@ func (config *HetznerConfig) DeleteSSHKey(name string) error {
return nil
}

//FindSSHKeyByName find a SSH key in config by name
// FindSSHKeyByName find a SSH key in config by name
func (config *HetznerConfig) FindSSHKeyByName(name string) (int, error) {
for i, v := range config.SSHKeys {
if v.Name == name {
Expand All @@ -95,7 +95,7 @@ func (config *HetznerConfig) FindSSHKeyByName(name string) (int, error) {
return -1, fmt.Errorf("unable to find '%s' SSH key", name)
}

//AddCluster add a cluster in config
// AddCluster add a cluster in config
func (config *HetznerConfig) AddCluster(cluster clustermanager.Cluster) {
for i, v := range config.Clusters {
if v.Name == cluster.Name {
Expand All @@ -107,7 +107,7 @@ func (config *HetznerConfig) AddCluster(cluster clustermanager.Cluster) {
config.Clusters = append(config.Clusters, cluster)
}

//DeleteCluster remove cluster from config
// DeleteCluster remove cluster from config
func (config *HetznerConfig) DeleteCluster(name string) error {

index, _ := config.FindClusterByName(name)
Expand All @@ -121,7 +121,7 @@ func (config *HetznerConfig) DeleteCluster(name string) error {
return nil
}

//FindClusterByName find a cluster by name in config
// FindClusterByName find a cluster by name in config
func (config *HetznerConfig) FindClusterByName(name string) (int, *clustermanager.Cluster) {
for i, cluster := range config.Clusters {
if cluster.Name == name {
Expand All @@ -132,7 +132,7 @@ func (config *HetznerConfig) FindClusterByName(name string) (int, *clustermanage
return -1, nil
}

//SwitchContextByName switch to context with a specific name in app
// SwitchContextByName switch to context with a specific name in app
func (app *AppConfig) SwitchContextByName(name string) error {
ctx, err := app.FindContextByName(name)

Expand All @@ -152,7 +152,7 @@ func (app *AppConfig) SwitchContextByName(name string) error {
return nil
}

//FindContextByName find a context using name
// FindContextByName find a context using name
func (app *AppConfig) FindContextByName(name string) (*HetznerContext, error) {

for _, ctx := range app.Config.Contexts {
Expand Down
8 changes: 4 additions & 4 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import (
"github.com/xetys/hetzner-kube/pkg/clustermanager"
)

//HetznerContext declare the hetzner cloud context
// HetznerContext declare the hetzner cloud context
type HetznerContext struct {
Token string `json:"token"`
Name string `json:"name"`
}

//SSHKey (deprecated)
// SSHKey (deprecated)
type SSHKey struct {
Name string `json:"name"`
PrivateKeyPath string `json:"private_key_path"`
PublicKeyPath string `json:"public_key_path"`
}

//HetznerConfig define the hetzner cloud provider config
// HetznerConfig define the hetzner cloud provider config
type HetznerConfig struct {
ActiveContextName string `json:"active_context_name"`
Contexts []HetznerContext `json:"contexts"`
SSHKeys []clustermanager.SSHKey `json:"ssh_keys"`
Clusters []clustermanager.Cluster `json:"clusters"`
}

//AppConfig define the application configuration
// AppConfig define the application configuration
type AppConfig struct {
Client *hcloud.Client
Context context.Context
Expand Down
2 changes: 1 addition & 1 deletion cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func randomName() string {
return fmt.Sprintf("%s-%s%s", randomdata.Adjective(), randomdata.Noun(), randomdata.Adjective())
}

//FatalOnError is an helper function to transform error to fatl
// FatalOnError is an helper function to transform error to fatl
func FatalOnError(err error) {
if err != nil {
log.Fatal(err)
Expand Down
14 changes: 7 additions & 7 deletions pkg/addons/addon_cert_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/xetys/hetzner-kube/pkg/clustermanager"
)

//CertmanagerAddon installs cert-manager
// CertmanagerAddon installs cert-manager
type CertmanagerAddon struct {
masterNode *clustermanager.Node
communicator clustermanager.NodeCommunicator
Expand All @@ -23,35 +23,35 @@ func init() {
addAddon(NewCertmanagerAddon)
}

//Name returns the addons name
// Name returns the addons name
func (addon *CertmanagerAddon) Name() string {
return "cert-manager"
}

//Requires returns a slice with the name of required addons
// Requires returns a slice with the name of required addons
func (addon *CertmanagerAddon) Requires() []string {
return []string{"helm"}
}

//Description returns the addons description
// Description returns the addons description
func (addon *CertmanagerAddon) Description() string {
return "Auto-TLS provisioning & management"
}

//URL returns the URL of the addons underlying project
// URL returns the URL of the addons underlying project
func (addon *CertmanagerAddon) URL() string {
return "https://github.com/jetstack/cert-manager"
}

//Install performs all steps to install the addon
// Install performs all steps to install the addon
func (addon *CertmanagerAddon) Install(args ...string) {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm install --name cert-manager --namespace ingress stable/cert-manager")
FatalOnError(err)
log.Println("cert-manager installed")
}

//Uninstall performs all steps to remove the addon
// Uninstall performs all steps to remove the addon
func (addon *CertmanagerAddon) Uninstall() {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm delete --purge cert-manager")
Expand Down
14 changes: 7 additions & 7 deletions pkg/addons/addon_docker_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/xetys/hetzner-kube/pkg/clustermanager"
)

//DockerregistryAddon installs a private container registry
// DockerregistryAddon installs a private container registry
type DockerregistryAddon struct {
masterNode *clustermanager.Node
communicator clustermanager.NodeCommunicator
Expand All @@ -23,35 +23,35 @@ func init() {
addAddon(NewDockerregistryAddon)
}

//Name returns the addons name
// Name returns the addons name
func (addon *DockerregistryAddon) Name() string {
return "docker-registry"
}

//Requires returns a slice with the name of required addons
// Requires returns a slice with the name of required addons
func (addon *DockerregistryAddon) Requires() []string {
return []string{"helm"}
}

//Description returns the addons description
// Description returns the addons description
func (addon *DockerregistryAddon) Description() string {
return "Private container registry"
}

//URL returns the URL of the addons underlying project
// URL returns the URL of the addons underlying project
func (addon *DockerregistryAddon) URL() string {
return "https://github.com/kubernetes/charts/tree/master/stable/docker-registry"
}

//Install performs all steps to install the addon
// Install performs all steps to install the addon
func (addon *DockerregistryAddon) Install(args ...string) {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm install --set persistence.enabled=true stable/docker-registry")
FatalOnError(err)
log.Println("docker-registry installed")
}

//Uninstall performs all steps to remove the addon
// Uninstall performs all steps to remove the addon
func (addon DockerregistryAddon) Uninstall() {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm delete --purge `helm list | grep docker-registry | awk '{print $1;}'`")
Expand Down
12 changes: 6 additions & 6 deletions pkg/addons/addon_hcloud_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ func init() {
addAddon(NewHCloudControllerManagerAddon)
}

//Name returns the addons name
// Name returns the addons name
func (addon *HCloudControllerManagerAddon) Name() string {
return "hcloud-controller-manager"
}

//Requires returns a slice with the name of required addons
// Requires returns a slice with the name of required addons
func (addon *HCloudControllerManagerAddon) Requires() []string {
return []string{}
}

//Description returns the addons description
// Description returns the addons description
func (addon *HCloudControllerManagerAddon) Description() string {
return "Hetzner Cloud official cloud controller manager"
}

//URL returns the URL of the addons underlying project
// URL returns the URL of the addons underlying project
func (addon *HCloudControllerManagerAddon) URL() string {
return "https://github.com/hetznercloud/hcloud-cloud-controller-manager"
}

//Install performs all steps to install the addon
// Install performs all steps to install the addon
func (addon *HCloudControllerManagerAddon) Install(args ...string) {
// set external cloud provider
config := `
Expand All @@ -74,7 +74,7 @@ Environment="KUBELET_EXTRA_ARGS=--cloud-provider=external"
FatalOnError(err)
}

//Uninstall performs all steps to remove the addon
// Uninstall performs all steps to remove the addon
func (addon *HCloudControllerManagerAddon) Uninstall() {
_, err := addon.communicator.RunCmd(*addon.masterNode, "kubectl delete -f https://raw.githubusercontent.com/hetznercloud/hcloud-cloud-controller-manager/master/deploy/v1.2.0.yaml")
FatalOnError(err)
Expand Down
16 changes: 8 additions & 8 deletions pkg/addons/addon_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/xetys/hetzner-kube/pkg/clustermanager"
)

//HelmAddon installs helm
// HelmAddon installs helm
type HelmAddon struct {
masterNode *clustermanager.Node
communicator clustermanager.NodeCommunicator
}

//NewHelmAddon installs helm to the cluster
// NewHelmAddon installs helm to the cluster
func NewHelmAddon(provider clustermanager.ClusterProvider, communicator clustermanager.NodeCommunicator) ClusterAddon {
masterNode, _ := provider.GetMasterNode()
return HelmAddon{masterNode: masterNode, communicator: communicator}
Expand All @@ -22,27 +22,27 @@ func init() {
addAddon(NewHelmAddon)
}

//Name returns the addons name
// Name returns the addons name
func (addon HelmAddon) Name() string {
return "helm"
}

//Requires returns a slice with the name of required addons
// Requires returns a slice with the name of required addons
func (addon HelmAddon) Requires() []string {
return []string{}
}

//Description returns the addons description
// Description returns the addons description
func (addon HelmAddon) Description() string {
return "Kubernetes Package Manager"
}

//URL returns the URL of the addons underlying project
// URL returns the URL of the addons underlying project
func (addon HelmAddon) URL() string {
return "https://helm.sh"
}

//Install performs all steps to install the addon
// Install performs all steps to install the addon
func (addon HelmAddon) Install(args ...string) {

node := *addon.masterNode
Expand Down Expand Up @@ -78,7 +78,7 @@ subjects:
fmt.Println("Helm installed")
}

//Uninstall performs all steps to remove the addon
// Uninstall performs all steps to remove the addon
func (addon HelmAddon) Uninstall() {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm reset --force")
Expand Down
16 changes: 8 additions & 8 deletions pkg/addons/addon_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/xetys/hetzner-kube/pkg/clustermanager"
)

//IngressAddon installs an ingress controller
// IngressAddon installs an ingress controller
type IngressAddon struct {
masterNode *clustermanager.Node
communicator clustermanager.NodeCommunicator
}

//NewIngressAddon creates an addon to install a nginx ingress controller
// NewIngressAddon creates an addon to install a nginx ingress controller
func NewIngressAddon(provider clustermanager.ClusterProvider, communicator clustermanager.NodeCommunicator) ClusterAddon {
masterNode, err := provider.GetMasterNode()
FatalOnError(err)
Expand All @@ -23,35 +23,35 @@ func init() {
addAddon(NewIngressAddon)
}

//Name returns the addons name
// Name returns the addons name
func (addon *IngressAddon) Name() string {
return "nginx-ingress-controller"
}

//Requires returns a slice with the name of required addons
// Requires returns a slice with the name of required addons
func (addon *IngressAddon) Requires() []string {
return []string{"helm"}
}

//Description returns the addons description
// Description returns the addons description
func (addon *IngressAddon) Description() string {
return "an ingress based load balancer for K8S"
}

//URL returns the URL of the addons underlying project
// URL returns the URL of the addons underlying project
func (addon *IngressAddon) URL() string {
return ""
}

//Install performs all steps to install the addon
// Install performs all steps to install the addon
func (addon *IngressAddon) Install(args ...string) {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm install --name ingress --namespace ingress --set rbac.create=true,controller.kind=DaemonSet,controller.service.type=ClusterIP,controller.hostNetwork=true stable/nginx-ingress")
FatalOnError(err)
log.Println("nginx ingress installed")
}

//Uninstall performs all steps to remove the addon
// Uninstall performs all steps to remove the addon
func (addon *IngressAddon) Uninstall() {
node := *addon.masterNode
_, err := addon.communicator.RunCmd(node, "helm delete --purge ingress")
Expand Down
Loading

0 comments on commit e31d20d

Please sign in to comment.