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:
parent
ad44dbced7
commit
4e25c19021
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -216,9 +217,8 @@ func randBytes(length int) ([]byte, error) {
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return b, nil
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// this creates a random ciphertext for demo purposes
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -61,7 +61,7 @@ func launch(cmd *cobra.Command, args []string) {
|
||||
// Read AirshipUI config file
|
||||
if err := configs.GetConfigFromFile(); err == nil {
|
||||
// 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 {
|
||||
waitgrp.Add(1)
|
||||
go RunBinaryWithOptions(
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
@ -38,6 +39,7 @@ func newVersionCmd() *cobra.Command {
|
||||
return versionCmd
|
||||
}
|
||||
|
||||
// Version returns application version
|
||||
func Version() string {
|
||||
return version
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package configs
|
||||
|
||||
import (
|
||||
@ -22,8 +23,9 @@ import (
|
||||
"opendev.org/airship/airshipctl/pkg/config"
|
||||
)
|
||||
|
||||
// variables related to UI config
|
||||
var (
|
||||
UiConfig Config
|
||||
UIConfig Config
|
||||
)
|
||||
|
||||
// Config basic structure to hold configuration params for Airship UI
|
||||
@ -33,12 +35,14 @@ type Config struct {
|
||||
Clusters []Cluster `json:"clusters,omitempty"`
|
||||
}
|
||||
|
||||
// AuthMethod structure to hold authentication parameters
|
||||
type AuthMethod struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Value []string `json:"values,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Plugin structure to hold plugin specific parameters
|
||||
type Plugin struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Dashboard struct {
|
||||
@ -86,6 +90,7 @@ type WsComponentType string
|
||||
// WsSubComponentType is used to set the specific subcomponent types allowable for WsRequests
|
||||
type WsSubComponentType string
|
||||
|
||||
// constants related to specific request/component/subcomponent types for WsRequests
|
||||
const (
|
||||
AirshipCTL WsRequestType = "airshipctl"
|
||||
Electron WsRequestType = "electron"
|
||||
@ -135,6 +140,7 @@ type WsMessage struct {
|
||||
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
|
||||
func GetConfigFromFile() error {
|
||||
var fileName string
|
||||
@ -158,11 +164,7 @@ func GetConfigFromFile() error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(byteValue, &UiConfig)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = json.Unmarshal(byteValue, &UIConfig)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package ctl
|
||||
|
||||
import (
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package ctl
|
||||
|
||||
import (
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package ctl
|
||||
|
||||
import (
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package ctl
|
||||
|
||||
import (
|
||||
@ -20,7 +21,7 @@ import (
|
||||
"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 {
|
||||
response := configs.WsMessage{
|
||||
Type: configs.AirshipCTL,
|
||||
|
@ -11,6 +11,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package webservice
|
||||
|
||||
import (
|
||||
@ -186,7 +187,7 @@ func WebServer() {
|
||||
|
||||
func clientInit(configs.WsMessage) configs.WsMessage {
|
||||
// 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
|
||||
}
|
||||
|
||||
@ -194,8 +195,8 @@ func clientInit(configs.WsMessage) configs.WsMessage {
|
||||
Type: configs.Electron,
|
||||
Component: configs.Initialize,
|
||||
IsAuthenticated: isAuthenticated,
|
||||
Dashboards: configs.UiConfig.Clusters,
|
||||
Plugins: configs.UiConfig.Plugins,
|
||||
Authentication: configs.UiConfig.AuthMethod,
|
||||
Dashboards: configs.UIConfig.Clusters,
|
||||
Plugins: configs.UIConfig.Plugins,
|
||||
Authentication: configs.UIConfig.AuthMethod,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user