Skip to content

Commit

Permalink
Pure formatting (automatic gofmt update)
Browse files Browse the repository at this point in the history
Signed-off-by: Albertin Loic <[email protected]>
  • Loading branch information
loicalbertin committed Nov 18, 2022
1 parent 8aac43e commit 0c1811f
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 98 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ const DefaultPluginDir = "plugins"
// DefaultServerGracefulShutdownTimeout is the default timeout for a graceful shutdown of a Yorc server before exiting
const DefaultServerGracefulShutdownTimeout = 5 * time.Minute

//DefaultKeepOperationRemotePath is set to false by default in order to remove path created to store operation artifacts on nodes.
// DefaultKeepOperationRemotePath is set to false by default in order to remove path created to store operation artifacts on nodes.
const DefaultKeepOperationRemotePath = false

//DefaultArchiveArtifacts is set to false by default.
// DefaultArchiveArtifacts is set to false by default.
// When ArchiveArtifacts is true, destination hosts need tar to be installed,
// to be able to unarchive artifacts.
const DefaultArchiveArtifacts = false
Expand Down
6 changes: 4 additions & 2 deletions deployments/definition_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ func fixAlienBlockStorages(ctx context.Context, deploymentID, nodeName string) e
return nil
}

/**
/*
*
This function create a given number of floating IP instances
*/
func createNodeInstances(consulStore consulutil.ConsulStore, numberInstances uint32, deploymentID, nodeName string) {
Expand Down Expand Up @@ -643,7 +644,8 @@ func createMissingBlockStorageForNodes(ctx context.Context, consulStore consulut
return nil
}

/**
/*
*
This function check if a nodes need a block storage, and return the name of BlockStorage node.
*/
func checkBlockStorage(ctx context.Context, deploymentID, nodeName string) (bool, []string, error) {
Expand Down
14 changes: 8 additions & 6 deletions deployments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ func DeploymentStatusFromString(status string, ignoreCase bool) (DeploymentStatu
// GetDeploymentStatus returns a DeploymentStatus for a given deploymentId
//
// If the given deploymentId doesn't refer to an existing deployment an error is returned. This error could be checked with
// IsDeploymentNotFoundError(err error) bool
//
// IsDeploymentNotFoundError(err error) bool
//
// For example:
// if status, err := GetDeploymentStatus(kv, deploymentId); err != nil {
// if IsDeploymentNotFoundError(err) {
// // Do something in case of deployment not found
// }
// }
//
// if status, err := GetDeploymentStatus(kv, deploymentId); err != nil {
// if IsDeploymentNotFoundError(err) {
// // Do something in case of deployment not found
// }
// }
func GetDeploymentStatus(ctx context.Context, deploymentID string) (DeploymentStatus, error) {
exist, value, err := consulutil.GetStringValue(path.Join(consulutil.DeploymentKVPrefix, deploymentID, "status"))
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions deployments/substitution_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ func isSubstitutionNodeInstance(ctx context.Context, deploymentID, nodeName, nod

// getSubstitutableNodeType returns the node type of a substitutable node.
// There are 2 cases :
// - either this node a reference to an external service, and the node type
// here is a real node type (abstract)
// - or this is a reference to a managed service, and the node type here
// does not exist, it is the name of a template whose import contains the
// real node type
// - either this node a reference to an external service, and the node type
// here is a real node type (abstract)
// - or this is a reference to a managed service, and the node type here
// does not exist, it is the name of a template whose import contains the
// real node type
func getSubstitutableNodeType(ctx context.Context, deploymentID, nodeName, nodeType string) (string, error) {
_, err := GetParentType(ctx, deploymentID, nodeType)
if err == nil {
Expand Down
16 changes: 8 additions & 8 deletions helper/labelsutil/internal/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (o *SetOperator) createFilter(labelKey string) (Filter, error) {
/* ###################################################### */
/* ###################################################### */

//CompositionStrategy is used to define the type of combination used into composite filter
// CompositionStrategy is used to define the type of combination used into composite filter
type CompositionStrategy int

const (
Expand All @@ -224,7 +224,7 @@ const (
Or CompositionStrategy = iota
)

//CompositeFilter is a filter made of other filters, combined using AND method
// CompositeFilter is a filter made of other filters, combined using AND method
type CompositeFilter struct {
Strat CompositionStrategy //combination operator, AND or OR
filters []Filter
Expand Down Expand Up @@ -270,7 +270,7 @@ func (f *CompositeFilter) matchOr(labels map[string]string) (bool, error) {

/* ###################################################### */

//RegexStrategy is used to define the type of search used into regexp filter
// RegexStrategy is used to define the type of search used into regexp filter
type RegexStrategy int

const (
Expand All @@ -284,7 +284,7 @@ const (
Differs RegexStrategy = iota
)

//RegexFilter is a filter checking if a label matches a regular expression
// RegexFilter is a filter checking if a label matches a regular expression
type RegexFilter struct {
LabelKey string
Strat RegexStrategy
Expand Down Expand Up @@ -321,7 +321,7 @@ func (f *RegexFilter) Matches(labels map[string]string) (bool, error) {

/* ###################################################### */

//ComparisonOperator is used to define the type of comparison used into comparison filter
// ComparisonOperator is used to define the type of comparison used into comparison filter
type ComparisonOperator int

const (
Expand All @@ -339,7 +339,7 @@ const (
Neq ComparisonOperator = iota
)

//ComparisonFilter is a filter checking if a label is higher than a certain value
// ComparisonFilter is a filter checking if a label is higher than a certain value
type ComparisonFilter struct {
LabelKey string
Cop ComparisonOperator
Expand Down Expand Up @@ -474,7 +474,7 @@ func siToFloat64(fval float64, funit string, lvalS string) (float64, float64, er

/* ###################################################### */

//KeyFilterStrat is used to define the type of combination used into LabelExists filter
// KeyFilterStrat is used to define the type of combination used into LabelExists filter
type KeyFilterStrat int

const (
Expand All @@ -484,7 +484,7 @@ const (
Absent KeyFilterStrat = iota
)

//KeyFilter is a filter checking if a label is existing or not
// KeyFilter is a filter checking if a label is existing or not
type KeyFilter struct {
LabelKey string
Strat KeyFilterStrat
Expand Down
2 changes: 2 additions & 0 deletions prov/ansible/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,9 @@ func (e *executionCommon) addRunnablesSpecificInputsAndOutputs() error {
}

// resolveIsPerInstanceOperation sets e.isPerInstanceOperation to true if the given operationName contains one of the following patterns (case doesn't matter):
//
// add_target, remove_target, add_source, remove_source, target_changed
//
// And in case of a relationship operation the relationship does not derive from "tosca.relationships.HostedOn" as it makes no sense till we scale at compute level
func (e *executionCommon) resolveIsPerInstanceOperation(ctx context.Context, operationName string) error {
op := strings.ToLower(operationName)
Expand Down
2 changes: 1 addition & 1 deletion prov/kubernetes/k8s_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func replaceServiceIPInResourceSpec(ctx context.Context, clientset kubernetes.In
return replaceServiceDepLookups(ctx, clientset, namespace, rSpec, serviceDepsLookups.RawString())
}

//Return the external IP of a given node
// Return the external IP of a given node
func getExternalIPAdress(ctx context.Context, clientset kubernetes.Interface, nodeName string) (string, error) {
node, err := clientset.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
if err != nil {
Expand Down
14 changes: 10 additions & 4 deletions prov/kubernetes/k8s_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ func TestGetNoneExternalIPAdress(t *testing.T) {
}
}

/* Return a map of mocked k8s objects corresponding to their resource in
Currently support only : StatefulSet, PVC, Service and Deployment */
/*
Return a map of mocked k8s objects corresponding to their resource in
Currently support only : StatefulSet, PVC, Service and Deployment
*/
func mockSupportedResources() map[string]runtime.Object {
pvc := &corev1.PersistentVolumeClaim{ObjectMeta: metav1.ObjectMeta{Name: "pvcTest", Namespace: "test-ns"}}
dep := &v1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "deploymentTest", Namespace: "test-ns"}}
Expand All @@ -136,9 +139,12 @@ func mockSupportedResources() map[string]runtime.Object {
return supportedRes
}

/* React to get on k8s objects. After 2 get if deleteObj boolean is set to true then it fakely delete it. If the boolean is set to false,
/*
React to get on k8s objects. After 2 get if deleteObj boolean is set to true then it fakely delete it. If the boolean is set to false,
then it marked the object as succefully present or deployed for pods controllers.
If the API continue to receive GET, raise error by signaling the errorChan */
If the API continue to receive GET, raise error by signaling the errorChan
*/
func fakeGetObjectReaction(k8sObject runtime.Object, errorChan chan struct{}, deleteObj bool) k8stesting.ReactionFunc {
getCount := 0
return func(action k8stesting.Action) (bool, runtime.Object, error) {
Expand Down
20 changes: 10 additions & 10 deletions prov/kubernetes/supported_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/ystia/yorc/v4/events"
)

//Interface to implement for new supported objects in K8s
// Interface to implement for new supported objects in K8s
type yorcK8sObject interface {
// Operations for yorc kubernetes objects
createResource(ctx context.Context, deploymentID string, clientset kubernetes.Interface, namespace string) error
Expand Down Expand Up @@ -130,9 +130,9 @@ func (yorcPVC *yorcK8sPersistentVolumeClaim) streamLogs(ctx context.Context, dep
}

/*
----------------------------------------------
| Deployment |
----------------------------------------------
----------------------------------------------
| Deployment |
----------------------------------------------
*/
func (yorcDep *yorcK8sDeployment) unmarshalResource(ctx context.Context, e *execution, deploymentID string, clientset kubernetes.Interface, rSpec string) error {
err := json.Unmarshal([]byte(rSpec), &yorcDep)
Expand Down Expand Up @@ -231,9 +231,9 @@ func (yorcDep *yorcK8sDeployment) streamLogs(ctx context.Context, deploymentID s
}

/*
----------------------------------------------
| StatefulSet |
----------------------------------------------
----------------------------------------------
| StatefulSet |
----------------------------------------------
*/
func (yorcSts *yorcK8sStatefulSet) unmarshalResource(ctx context.Context, e *execution, deploymentID string, clientset kubernetes.Interface, rSpec string) error {
err := json.Unmarshal([]byte(rSpec), &yorcSts)
Expand Down Expand Up @@ -325,9 +325,9 @@ func (yorcSts *yorcK8sStatefulSet) streamLogs(ctx context.Context, deploymentID
}

/*
----------------------------------------------
| Service |
----------------------------------------------
----------------------------------------------
| Service |
----------------------------------------------
*/
func (yorcSvc *yorcK8sService) unmarshalResource(ctx context.Context, e *execution, deploymentID string, clientset kubernetes.Interface, rSpec string) error {
return json.Unmarshal([]byte(rSpec), &yorcSvc)
Expand Down
14 changes: 7 additions & 7 deletions prov/operations/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ func ResolveInputsWithInstances(ctx context.Context, deploymentID, nodeName, tas
//
// It may happen in rare cases that several capabilities match the same requirement.
// Values are stored in this way:
// * TARGET_CAPABILITY_NAMES: comma-separated list of matching capabilities names. It could be use to loop over the injected variables
// * TARGET_CAPABILITY_<capabilityName>_TYPE: actual type of the capability
// * TARGET_CAPABILITY_TYPE: actual type of the capability of the first matching capability
// * TARGET_CAPABILITY_<capabilityName>_PROPERTY_<propertyName>: value of a property
// * TARGET_CAPABILITY_PROPERTY_<propertyName>: value of a property for the first matching capability
// * TARGET_CAPABILITY_<capabilityName>_<instanceName>_ATTRIBUTE_<attributeName>: value of an attribute of a given instance
// * TARGET_CAPABILITY_<instanceName>_ATTRIBUTE_<attributeName>: value of an attribute of a given instance for the first matching capability
// - TARGET_CAPABILITY_NAMES: comma-separated list of matching capabilities names. It could be use to loop over the injected variables
// - TARGET_CAPABILITY_<capabilityName>_TYPE: actual type of the capability
// - TARGET_CAPABILITY_TYPE: actual type of the capability of the first matching capability
// - TARGET_CAPABILITY_<capabilityName>_PROPERTY_<propertyName>: value of a property
// - TARGET_CAPABILITY_PROPERTY_<propertyName>: value of a property for the first matching capability
// - TARGET_CAPABILITY_<capabilityName>_<instanceName>_ATTRIBUTE_<attributeName>: value of an attribute of a given instance
// - TARGET_CAPABILITY_<instanceName>_ATTRIBUTE_<attributeName>: value of an attribute of a given instance for the first matching capability
func GetTargetCapabilityPropertiesAndAttributesValues(ctx context.Context, deploymentID, nodeName string, op prov.Operation) (map[string]*deployments.TOSCAValue, error) {
// Only for relationship operations
if !IsRelationshipOperation(op) {
Expand Down
5 changes: 3 additions & 2 deletions storage/internal/elastic/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ func (s *elasticStore) verifyLastIndex(indexName string, deploymentID string, es
// List simulates long polling request by :
// - periodically querying ES for documents (Aggregation to get the max iid and 0 size result).
// - if a some result is found, wait some time (es_refresh_wait_timeout) in order to:
// - let ES index recently added documents AND to let
// - let Yorc eventually Set a document that has a less iid than the older known document in ES (concurrence issues)
// - let ES index recently added documents AND to let
// - let Yorc eventually Set a document that has a less iid than the older known document in ES (concurrence issues)
//
// - if no result if found after the the given 'timeout', return empty slice
func (s *elasticStore) List(ctx context.Context, k string, waitIndex uint64, timeout time.Duration) ([]store.KeyValueOut, uint64, error) {
log.Debugf("List called k: %s, waitIndex: %d, timeout: %v", k, waitIndex, timeout)
Expand Down
16 changes: 9 additions & 7 deletions testutil/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import (
)

// NewTestConsulInstance allows to :
// - creates and returns a new Consul server and client
// - starts a Consul Publisher
// - loads stores
// - stores common-types to Consul
// - creates and returns a new Consul server and client
// - starts a Consul Publisher
// - loads stores
// - stores common-types to Consul
//
// Warning: You need to defer the server stop command in the caller
func NewTestConsulInstance(t testing.TB, cfg *config.Configuration) (*testutil.TestServer, *api.Client) {
logLevel := "debug"
Expand All @@ -57,9 +58,10 @@ func NewTestConsulInstanceWithConfigAndStore(t testing.TB, cb testutil.ServerCon
}

// NewTestConsulInstanceWithConfig sets up a consul instance for testing :
// - creates and returns a new Consul server and client
// - starts a Consul Publisher
// - stores common-types to Consul only if storeCommons bool parameter is true
// - creates and returns a new Consul server and client
// - starts a Consul Publisher
// - stores common-types to Consul only if storeCommons bool parameter is true
//
// Warning: You need to defer the server stop command in the caller
func NewTestConsulInstanceWithConfig(t testing.TB, cb testutil.ServerConfigCallback, cfg *config.Configuration, storeCommons bool) (*testutil.TestServer, *api.Client) {

Expand Down
2 changes: 0 additions & 2 deletions tosca/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
)

// An Output is the representation of the output part of a TOSCA Operation Definition
//
//
type Output struct {
ValueAssign *ValueAssignment `json:"value_assignment,omitempty"`
AttributeMapping *AttributeMapping `json:"attribute_mapping,omitempty"`
Expand Down
52 changes: 26 additions & 26 deletions tosca/substitution_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ type SubstitutionMapping struct {
// PropAttrMapping defines a property or attribute mapping.
// It accepts several grammars.
//
// - Single-line grammar:
// <property_name>: <property_value>
// or
// <property_name>: [ <input_name> ]
// or
// <property_name>: [ <node_template_name>, <node_template_property_name> ]
// or
// <property_name>: [ <node_template_name>, <node_template_capability_name> | <node_template_requirement_name>, <property_name> ]
// - Single-line grammar:
// <property_name>: <property_value>
// or
// <property_name>: [ <input_name> ]
// or
// <property_name>: [ <node_template_name>, <node_template_property_name> ]
// or
// <property_name>: [ <node_template_name>, <node_template_capability_name> | <node_template_requirement_name>, <property_name> ]
//
// - Multi-line grammar:
// <property_name>:
// - Multi-line grammar:
// <property_name>:
// mapping: [ < input_name > ]
// or
// <property_name>:
// or
// <property_name>:
// mapping: [ <node_template_name>, <node_template_property_name> ]
// or
// <property_name>:
// or
// <property_name>:
// mapping: [ <node_template_name>, <node_template_capability_name> | <node_template_requirement_name>, <property_name> ]
// or
// <property_name>:
// or
// <property_name>:
// value: <property_value>
//
// See http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/TOSCA-Simple-Profile-YAML-v1.2.html
Expand Down Expand Up @@ -124,17 +124,17 @@ func (p *PropAttrMapping) UnmarshalYAML(unmarshal func(interface{}) error) error
// CapReqMapping defines a capability mapping or a requirement mapping.
// It accepts two grammars.
//
// - Single-line grammar:
// <capability_name>: [ <node_template_name>, <node_template_capability_name> ]
// - Single-line grammar:
// <capability_name>: [ <node_template_name>, <node_template_capability_name> ]
//
// - Multi-line grammar:
// <capability_name>:
// mapping: [ <node_template_name>, <node_template_capability_name> ]
// <capability_name>:
// properties:
// <property_name>: <property_value>
// attributes:
// <attribute_name>: <attribute_value>
// - Multi-line grammar:
// <capability_name>:
// mapping: [ <node_template_name>, <node_template_capability_name> ]
// <capability_name>:
// properties:
// <property_name>: <property_value>
// attributes:
// <attribute_name>: <attribute_value>
//
// See http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/TOSCA-Simple-Profile-YAML-v1.2.html
// section 3.8.9 Capability mapping and 3.8.10 Requirement mapping
Expand Down
4 changes: 2 additions & 2 deletions tosca/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ type NodeTemplate struct {
Interfaces map[string]InterfaceDefinition `yaml:"interfaces,omitempty" json:"interfaces,omitempty"`
}

//A Repository is representation of TOSCA Repository
// A Repository is representation of TOSCA Repository
//
//See http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/csprd01/TOSCA-Simple-Profile-YAML-v1.0-csprd01.html#_Toc430015673 for more details
// See http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/csprd01/TOSCA-Simple-Profile-YAML-v1.0-csprd01.html#_Toc430015673 for more details
type Repository struct {
URL string `yaml:"url,omitempty" json:"url,omitempty"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Expand Down
Loading

0 comments on commit 0c1811f

Please sign in to comment.