Merge "Fix for Lint warnings"
This commit is contained in:
commit
9ad4db66f4
@ -33,8 +33,8 @@ airshipctl config get-credentials
|
|||||||
airshipctl config get-credentials e2e`
|
airshipctl config get-credentials e2e`
|
||||||
)
|
)
|
||||||
|
|
||||||
// An AuthInfo refers to a particular user for a cluster
|
|
||||||
// NewCmdConfigGetAuthInfo returns a Command instance for 'config -AuthInfo' sub command
|
// NewCmdConfigGetAuthInfo returns a Command instance for 'config -AuthInfo' sub command
|
||||||
|
// An AuthInfo refers to a particular user for a cluster
|
||||||
func NewCmdConfigGetAuthInfo(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
func NewCmdConfigGetAuthInfo(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||||
o := &config.AuthInfoOptions{}
|
o := &config.AuthInfoOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
@ -415,7 +415,7 @@ func (c *Config) SetKubeConfig(kubeConfig *clientcmdapi.Config) {
|
|||||||
c.kubeConfig = kubeConfig
|
c.kubeConfig = kubeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get A Cluster
|
// GetCluster returns a cluster instance
|
||||||
func (c *Config) GetCluster(cName, cType string) (*Cluster, error) {
|
func (c *Config) GetCluster(cName, cType string) (*Cluster, error) {
|
||||||
_, exists := c.Clusters[cName]
|
_, exists := c.Clusters[cName]
|
||||||
if !exists {
|
if !exists {
|
||||||
@ -519,8 +519,7 @@ func (c *Config) GetClusters() []*Cluster {
|
|||||||
return clusters
|
return clusters
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context Operations from Config point of view
|
// GetContext returns a context instance
|
||||||
// Get Context
|
|
||||||
func (c *Config) GetContext(cName string) (*Context, error) {
|
func (c *Config) GetContext(cName string) (*Context, error) {
|
||||||
context, exists := c.Contexts[cName]
|
context, exists := c.Contexts[cName]
|
||||||
if !exists {
|
if !exists {
|
||||||
@ -580,7 +579,7 @@ func (c *Config) ModifyContext(context *Context, theContext *ContextOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentContext methods Returns the appropriate information for the current context
|
// GetCurrentContext methods Returns the appropriate information for the current context
|
||||||
// Current Context holds labels for the approriate config objects
|
// Current Context holds labels for the approriate config objects
|
||||||
// Cluster is the name of the cluster for this context
|
// Cluster is the name of the cluster for this context
|
||||||
// ClusterType is the name of the clustertype for this context, it should be a flag we pass to it??
|
// ClusterType is the name of the clustertype for this context, it should be a flag we pass to it??
|
||||||
@ -647,6 +646,7 @@ func (c *Config) CurrentContextEntryPoint(clusterType string, phase string) (str
|
|||||||
phase), nil
|
phase), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAuthInfo returns an instance of authino
|
||||||
// Credential or AuthInfo related methods
|
// Credential or AuthInfo related methods
|
||||||
func (c *Config) GetAuthInfo(aiName string) (*AuthInfo, error) {
|
func (c *Config) GetAuthInfo(aiName string) (*AuthInfo, error) {
|
||||||
authinfo, exists := c.AuthInfos[aiName]
|
authinfo, exists := c.AuthInfos[aiName]
|
||||||
|
@ -13,7 +13,7 @@ const (
|
|||||||
Initinfra = "initinfra"
|
Initinfra = "initinfra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sorted
|
// AllClusterTypes holds cluster types
|
||||||
var AllClusterTypes = [2]string{Ephemeral, Target}
|
var AllClusterTypes = [2]string{Ephemeral, Target}
|
||||||
|
|
||||||
// Constants defining default values
|
// Constants defining default values
|
||||||
|
@ -5,15 +5,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Repo errors
|
// ErrIncompatibleAuthOptions is returned when incompatible
|
||||||
|
// AuthTypes are provided
|
||||||
// ErrMutuallyExclusiveAuthSSHPass is returned when ssh-pass type
|
|
||||||
// is selected and http-pass, ssh-key or key-pass options are defined
|
|
||||||
type ErrIncompatibleAuthOptions struct {
|
type ErrIncompatibleAuthOptions struct {
|
||||||
ForbiddenOptions []string
|
ForbiddenOptions []string
|
||||||
AuthType string
|
AuthType string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewErrIncompetibleAuthOptions returns Error of type
|
||||||
|
// ErrIncompatibleAuthOptions
|
||||||
func NewErrIncompetibleAuthOptions(fo []string, ao string) error {
|
func NewErrIncompetibleAuthOptions(fo []string, ao string) error {
|
||||||
return ErrIncompatibleAuthOptions{
|
return ErrIncompatibleAuthOptions{
|
||||||
ForbiddenOptions: fo,
|
ForbiddenOptions: fo,
|
||||||
@ -21,11 +21,14 @@ func NewErrIncompetibleAuthOptions(fo []string, ao string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error of type ErrIncompatibleAuthOptions is returned when
|
||||||
|
// ssh-pass type is selected and http-pass, ssh-key or key-pass
|
||||||
|
// options are defined
|
||||||
func (e ErrIncompatibleAuthOptions) Error() string {
|
func (e ErrIncompatibleAuthOptions) Error() string {
|
||||||
return fmt.Sprintf("Can not use %s options, with auth type %s", e.ForbiddenOptions, e.AuthType)
|
return fmt.Sprintf("Can not use %s options, with auth type %s", e.ForbiddenOptions, e.AuthType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrAuthTypeNotSupported is returned with wrong AuthType is provided
|
// ErrAuthTypeNotSupported is returned when wrong AuthType is provided
|
||||||
type ErrAuthTypeNotSupported struct {
|
type ErrAuthTypeNotSupported struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ type Config struct {
|
|||||||
kubeConfig *kubeconfig.Config
|
kubeConfig *kubeconfig.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encapsulates the Cluster Type as an enumeration
|
// ClusterPurpose encapsulates the Cluster Type as an enumeration
|
||||||
type ClusterPurpose struct {
|
type ClusterPurpose struct {
|
||||||
// Cluster map of referenceable names to cluster configs
|
// Cluster map of referenceable names to cluster configs
|
||||||
ClusterTypes map[string]*Cluster `json:"cluster-type"`
|
ClusterTypes map[string]*Cluster `json:"cluster-type"`
|
||||||
@ -86,7 +86,7 @@ type Cluster struct {
|
|||||||
Bootstrap string `json:"bootstrap-info"`
|
Bootstrap string `json:"bootstrap-info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modules, generic configuration for modules
|
// Modules encapsulates all module configurations
|
||||||
// Configuration that the Bootstrap Module would need
|
// Configuration that the Bootstrap Module would need
|
||||||
// Configuration that the Document Module would need
|
// Configuration that the Document Module would need
|
||||||
// Configuration that the Workflows Module would need
|
// Configuration that the Workflows Module would need
|
||||||
@ -179,7 +179,7 @@ type RepoCheckout struct {
|
|||||||
ForceCheckout bool `json:"force"`
|
ForceCheckout bool `json:"force"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Holds the complex cluster name information
|
// ClusterComplexName holds the complex cluster name information
|
||||||
// Encapsulates the different operations around using it.
|
// Encapsulates the different operations around using it.
|
||||||
type ClusterComplexName struct {
|
type ClusterComplexName struct {
|
||||||
Name string
|
Name string
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package document
|
package document
|
||||||
|
|
||||||
|
// Label Selectors
|
||||||
const (
|
const (
|
||||||
// Label Selectors
|
|
||||||
BaseAirshipSelector = "airshipit.org"
|
BaseAirshipSelector = "airshipit.org"
|
||||||
EphemeralHostSelector = BaseAirshipSelector + "/ephemeral-node in (True, true)"
|
EphemeralHostSelector = BaseAirshipSelector + "/ephemeral-node in (True, true)"
|
||||||
EphemeralUserDataSelector = BaseAirshipSelector + "/ephemeral-user-data in (True, true)"
|
EphemeralUserDataSelector = BaseAirshipSelector + "/ephemeral-user-data in (True, true)"
|
||||||
InitInfraSelector = BaseAirshipSelector + "/phase = initinfra"
|
InitInfraSelector = BaseAirshipSelector + "/phase = initinfra"
|
||||||
|
|
||||||
// Annotation Selectors
|
// DeployToK8sSelector checks that deploy-k8s label is not equal to true or True (string)
|
||||||
// Please note that by default every document in the manifest is to be deployed to kubernetes cluster.
|
// Please note that by default every document in the manifest is to be deployed to kubernetes cluster.
|
||||||
// so this selector simply checks that deploy-k8s label is not equal to true or True (string)
|
|
||||||
DeployToK8sSelector = "config.kubernetes.io/local-config notin (True, true)"
|
DeployToK8sSelector = "config.kubernetes.io/local-config notin (True, true)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package redfish
|
package redfish
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -17,9 +29,10 @@ const (
|
|||||||
RedfishURLSchemeSeparator = "+"
|
RedfishURLSchemeSeparator = "+"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetResourceIDFromURL returns a parsed Redfish resource ID
|
||||||
|
// from the Redfish URL
|
||||||
// Redfish Id ref is a URI which contains resource Id
|
// Redfish Id ref is a URI which contains resource Id
|
||||||
// as the last part. This function extracts resource
|
// as the last part.
|
||||||
// ID from ID ref
|
|
||||||
func GetResourceIDFromURL(refURL string) string {
|
func GetResourceIDFromURL(refURL string) string {
|
||||||
u, err := url.Parse(refURL)
|
u, err := url.Parse(refURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -33,7 +46,7 @@ func GetResourceIDFromURL(refURL string) string {
|
|||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks whether an ID exists in Redfish IDref collection
|
// IsIDInList checks whether an ID exists in Redfish IDref collection
|
||||||
func IsIDInList(idRefList []redfishClient.IdRef, id string) bool {
|
func IsIDInList(idRefList []redfishClient.IdRef, id string) bool {
|
||||||
for _, r := range idRefList {
|
for _, r := range idRefList {
|
||||||
rID := GetResourceIDFromURL(r.OdataId)
|
rID := GetResourceIDFromURL(r.OdataId)
|
||||||
|
@ -58,7 +58,7 @@ func DummyConfig() *config.Config {
|
|||||||
return conf
|
return conf
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyContext , utility function used for tests
|
// DummyContext creates a Context config object for unit testing
|
||||||
func DummyContext() *config.Context {
|
func DummyContext() *config.Context {
|
||||||
c := config.NewContext()
|
c := config.NewContext()
|
||||||
c.NameInKubeconf = "dummy_cluster_ephemeral"
|
c.NameInKubeconf = "dummy_cluster_ephemeral"
|
||||||
@ -72,7 +72,7 @@ func DummyContext() *config.Context {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyCluster, utility function used for tests
|
// DummyCluster creates a Cluster config object for unit testing
|
||||||
func DummyCluster() *config.Cluster {
|
func DummyCluster() *config.Cluster {
|
||||||
c := config.NewCluster()
|
c := config.NewCluster()
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ func DummyCluster() *config.Cluster {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyManifest , utility function used for tests
|
// DummyManifest creates a Manifest config object for unit testing
|
||||||
func DummyManifest() *config.Manifest {
|
func DummyManifest() *config.Manifest {
|
||||||
m := config.NewManifest()
|
m := config.NewManifest()
|
||||||
// Repositories is the map of repository adddressable by a name
|
// Repositories is the map of repository adddressable by a name
|
||||||
@ -97,7 +97,7 @@ func DummyManifest() *config.Manifest {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyRepository, utility function used for tests
|
// DummyRepository creates a Repository config object for unit testing
|
||||||
func DummyRepository() *config.Repository {
|
func DummyRepository() *config.Repository {
|
||||||
return &config.Repository{
|
return &config.Repository{
|
||||||
URLString: "http://dummy.url.com/manifests.git",
|
URLString: "http://dummy.url.com/manifests.git",
|
||||||
@ -112,7 +112,7 @@ func DummyRepository() *config.Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyRepoAuth , utility function used for tests
|
// DummyRepoAuth creates a RepoAuth config object for unit testing
|
||||||
func DummyRepoAuth() *config.RepoAuth {
|
func DummyRepoAuth() *config.RepoAuth {
|
||||||
return &config.RepoAuth{
|
return &config.RepoAuth{
|
||||||
Type: "ssh-key",
|
Type: "ssh-key",
|
||||||
@ -120,7 +120,8 @@ func DummyRepoAuth() *config.RepoAuth {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyRepoCheckout, utility function used for checks
|
// DummyRepoCheckout creates a RepoCheckout config object
|
||||||
|
// for unit testing
|
||||||
func DummyRepoCheckout() *config.RepoCheckout {
|
func DummyRepoCheckout() *config.RepoCheckout {
|
||||||
return &config.RepoCheckout{
|
return &config.RepoCheckout{
|
||||||
Tag: "v1.0.1",
|
Tag: "v1.0.1",
|
||||||
@ -128,7 +129,7 @@ func DummyRepoCheckout() *config.RepoCheckout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyAuthInfo , utility function used for tests
|
// DummyAuthInfo creates a AuthInfo config object for unit testing
|
||||||
func DummyAuthInfo() *config.AuthInfo {
|
func DummyAuthInfo() *config.AuthInfo {
|
||||||
a := config.NewAuthInfo()
|
a := config.NewAuthInfo()
|
||||||
authinfo := kubeconfig.NewAuthInfo()
|
authinfo := kubeconfig.NewAuthInfo()
|
||||||
@ -141,7 +142,8 @@ func DummyAuthInfo() *config.AuthInfo {
|
|||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyKubeAuthInfo , utility function used for tests
|
// DummyKubeAuthInfo creates a AuthInfo kubeconfig object
|
||||||
|
// for unit testing
|
||||||
func DummyKubeAuthInfo() *kubeconfig.AuthInfo {
|
func DummyKubeAuthInfo() *kubeconfig.AuthInfo {
|
||||||
authinfo := kubeconfig.NewAuthInfo()
|
authinfo := kubeconfig.NewAuthInfo()
|
||||||
authinfo.Username = "dummy_username"
|
authinfo.Username = "dummy_username"
|
||||||
@ -152,14 +154,14 @@ func DummyKubeAuthInfo() *kubeconfig.AuthInfo {
|
|||||||
return authinfo
|
return authinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyModules , utility function used for tests
|
// DummyModules returns Modules config objects for unit testing
|
||||||
func DummyModules() *config.Modules {
|
func DummyModules() *config.Modules {
|
||||||
m := config.NewModules()
|
m := config.NewModules()
|
||||||
m.BootstrapInfo["dummy_bootstrap_config"] = DummyBootstrap()
|
m.BootstrapInfo["dummy_bootstrap_config"] = DummyBootstrap()
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// DummyClusterPurpose , utility function used for tests
|
// DummyClusterPurpose creates ClusterPurpose config object for unit testing
|
||||||
func DummyClusterPurpose() *config.ClusterPurpose {
|
func DummyClusterPurpose() *config.ClusterPurpose {
|
||||||
cp := config.NewClusterPurpose()
|
cp := config.NewClusterPurpose()
|
||||||
cp.ClusterTypes["ephemeral"] = DummyCluster()
|
cp.ClusterTypes["ephemeral"] = DummyCluster()
|
||||||
@ -193,6 +195,8 @@ func InitConfig(t *testing.T) (conf *config.Config, cleanup func(*testing.T)) {
|
|||||||
return conf, cleanup
|
return conf, cleanup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DummyClusterOptions creates ClusterOptions config object
|
||||||
|
// for unit testing
|
||||||
func DummyClusterOptions() *config.ClusterOptions {
|
func DummyClusterOptions() *config.ClusterOptions {
|
||||||
co := &config.ClusterOptions{}
|
co := &config.ClusterOptions{}
|
||||||
co.Name = "dummy_cluster"
|
co.Name = "dummy_cluster"
|
||||||
@ -205,6 +209,8 @@ func DummyClusterOptions() *config.ClusterOptions {
|
|||||||
return co
|
return co
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DummyContextOptions creates ContextOptions config object
|
||||||
|
// for unit testing
|
||||||
func DummyContextOptions() *config.ContextOptions {
|
func DummyContextOptions() *config.ContextOptions {
|
||||||
co := &config.ContextOptions{}
|
co := &config.ContextOptions{}
|
||||||
co.Name = "dummy_context"
|
co.Name = "dummy_context"
|
||||||
@ -216,6 +222,8 @@ func DummyContextOptions() *config.ContextOptions {
|
|||||||
return co
|
return co
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DummyAuthInfoOptions creates AuthInfoOptions config object
|
||||||
|
// for unit testing
|
||||||
func DummyAuthInfoOptions() *config.AuthInfoOptions {
|
func DummyAuthInfoOptions() *config.AuthInfoOptions {
|
||||||
authinfo := &config.AuthInfoOptions{}
|
authinfo := &config.AuthInfoOptions{}
|
||||||
authinfo.Username = "dummy_username"
|
authinfo.Username = "dummy_username"
|
||||||
@ -226,6 +234,7 @@ func DummyAuthInfoOptions() *config.AuthInfoOptions {
|
|||||||
return authinfo
|
return authinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DummyBootstrap creates Bootstrap config object for unit testing
|
||||||
func DummyBootstrap() *config.Bootstrap {
|
func DummyBootstrap() *config.Bootstrap {
|
||||||
bs := &config.Bootstrap{}
|
bs := &config.Bootstrap{}
|
||||||
cont := config.Container{
|
cont := config.Container{
|
||||||
|
Loading…
Reference in New Issue
Block a user