Fix for minor Go lint issues

Issues addressed:
* package comment should not have leading space
* exported var UiConfig should have comment or be unexported
* if block ends with a return statement, so drop this else and outdent its block
* var UiConfig should be UIConfig

Change-Id: I04b380445d7c97a816f75a9af006d2461b256356
This commit is contained in:
Sirajudeen 2020-06-17 15:38:07 -05:00
parent ad44dbced7
commit 4e25c19021
11 changed files with 25 additions and 14 deletions

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package main package main
import ( import (

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package main package main
import ( import (
@ -216,9 +217,8 @@ func randBytes(length int) ([]byte, error) {
_, err := rand.Read(b) _, err := rand.Read(b)
if err != nil { if err != nil {
return nil, err return nil, err
} else {
return b, nil
} }
return b, nil
} }
// this creates a random ciphertext for demo purposes // this creates a random ciphertext for demo purposes

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package main package main
import ( import (

View File

@ -61,7 +61,7 @@ func launch(cmd *cobra.Command, args []string) {
// Read AirshipUI config file // Read AirshipUI config file
if err := configs.GetConfigFromFile(); err == nil { if err := configs.GetConfigFromFile(); err == nil {
// launch any plugins marked as autoStart: true in airshipui.json // launch any plugins marked as autoStart: true in airshipui.json
for _, p := range configs.UiConfig.Plugins { for _, p := range configs.UIConfig.Plugins {
if p.Executable.AutoStart { if p.Executable.AutoStart {
waitgrp.Add(1) waitgrp.Add(1)
go RunBinaryWithOptions( go RunBinaryWithOptions(

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package commands package commands
import ( import (
@ -38,6 +39,7 @@ func newVersionCmd() *cobra.Command {
return versionCmd return versionCmd
} }
// Version returns application version
func Version() string { func Version() string {
return version return version
} }

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package configs package configs
import ( import (
@ -22,8 +23,9 @@ import (
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
) )
// variables related to UI config
var ( var (
UiConfig Config UIConfig Config
) )
// Config basic structure to hold configuration params for Airship UI // Config basic structure to hold configuration params for Airship UI
@ -33,12 +35,14 @@ type Config struct {
Clusters []Cluster `json:"clusters,omitempty"` Clusters []Cluster `json:"clusters,omitempty"`
} }
// AuthMethod structure to hold authentication parameters
type AuthMethod struct { type AuthMethod struct {
Type string `json:"type,omitempty"` Type string `json:"type,omitempty"`
Value []string `json:"values,omitempty"` Value []string `json:"values,omitempty"`
URL string `json:"url,omitempty"` URL string `json:"url,omitempty"`
} }
// Plugin structure to hold plugin specific parameters
type Plugin struct { type Plugin struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Dashboard struct { Dashboard struct {
@ -86,6 +90,7 @@ type WsComponentType string
// WsSubComponentType is used to set the specific subcomponent types allowable for WsRequests // WsSubComponentType is used to set the specific subcomponent types allowable for WsRequests
type WsSubComponentType string type WsSubComponentType string
// constants related to specific request/component/subcomponent types for WsRequests
const ( const (
AirshipCTL WsRequestType = "airshipctl" AirshipCTL WsRequestType = "airshipctl"
Electron WsRequestType = "electron" Electron WsRequestType = "electron"
@ -135,6 +140,7 @@ type WsMessage struct {
ClusterOptions config.ClusterOptions `json:"clusterOptions,omitempty"` ClusterOptions config.ClusterOptions `json:"clusterOptions,omitempty"`
} }
// GetConfigFromFile reads configuration file and returns error on any error reading the file
// TODO: add watcher to the json file to reload conf on change // TODO: add watcher to the json file to reload conf on change
func GetConfigFromFile() error { func GetConfigFromFile() error {
var fileName string var fileName string
@ -158,11 +164,7 @@ func GetConfigFromFile() error {
return err return err
} }
err = json.Unmarshal(byteValue, &UiConfig) err = json.Unmarshal(byteValue, &UIConfig)
if err != nil {
return err
}
return err return err
} }

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package ctl package ctl
import ( import (

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package ctl package ctl
import ( import (

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package ctl package ctl
import ( import (

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package ctl package ctl
import ( import (
@ -20,7 +21,7 @@ import (
"opendev.org/airship/airshipui/internal/configs" "opendev.org/airship/airshipui/internal/configs"
) )
// HandleBaremetalRequest will flop between requests so we don't have to have them all mapped as function calls // HandleDocumentRequest will flop between requests so we don't have to have them all mapped as function calls
func HandleDocumentRequest(request configs.WsMessage) configs.WsMessage { func HandleDocumentRequest(request configs.WsMessage) configs.WsMessage {
response := configs.WsMessage{ response := configs.WsMessage{
Type: configs.AirshipCTL, Type: configs.AirshipCTL,

View File

@ -11,6 +11,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package webservice package webservice
import ( import (
@ -186,7 +187,7 @@ func WebServer() {
func clientInit(configs.WsMessage) configs.WsMessage { func clientInit(configs.WsMessage) configs.WsMessage {
// if no auth method is supplied start with minimal functionality // if no auth method is supplied start with minimal functionality
if len(configs.UiConfig.AuthMethod.URL) == 0 { if len(configs.UIConfig.AuthMethod.URL) == 0 {
isAuthenticated = true isAuthenticated = true
} }
@ -194,8 +195,8 @@ func clientInit(configs.WsMessage) configs.WsMessage {
Type: configs.Electron, Type: configs.Electron,
Component: configs.Initialize, Component: configs.Initialize,
IsAuthenticated: isAuthenticated, IsAuthenticated: isAuthenticated,
Dashboards: configs.UiConfig.Clusters, Dashboards: configs.UIConfig.Clusters,
Plugins: configs.UiConfig.Plugins, Plugins: configs.UIConfig.Plugins,
Authentication: configs.UiConfig.AuthMethod, Authentication: configs.UIConfig.AuthMethod,
} }
} }