original_docstring: Check the type of step to create the correct class object
docstring: Check the type of step to create the correct class object
docstring_tokens: Check the type of step to create the correct class object
code: def create_step(self, name, block):
          '''Check the type of step to create the correct class object'''
          step_type=grab_field_value(block, "type", "freestyle")
          cwd=grab_field_value(block, "working_directory", "/codefresh/volume")
          cwd=replace_parameter_variable_by_step_output(cwd, "WORKING_DIR")
   
          if step_type == 'freestyle':
              shell=grab_field_value(block, "shell", "sh")
              commands=""
              if 'commands' in block:
                  logging.debug("COMMAND: %s", block['commands'])
                  string=''
                  for line in block['commands']:
                      string += f"{line}\n"
                  string += "\n"     # adding empty line to force | output
                  commands=string
   
              image=replace_parameter_variable_by_step_output(block['image'], "IMAGE")
              #self.logger.debug("Freestyle step cwd: %s", cwd)
              #self.logger.debug("Freestyle step cwd after: %s", cwd)
  
              step_obj = Plugins(name,  "freestyle", "0.0.1", block,
                  [
                      Parameter('image',       self.replace_variable(image)),
                      Parameter("working_directory", self.replace_variable(cwd)),
                      Parameter("shell",       self.replace_variable(shell)),
                      Parameter("commands",    commands)
                  ])
          elif step_type == 'git-clone':
              (repo_owner, repo_name) = parse_repo_field(block['repo'])
              step_obj = Plugins(name, "git-clone", "0.0.1", block,
                  [
                      Parameter('CF_REPO_OWNER', self.replace_variable(repo_owner)),
                      Parameter("CF_REPO_NAME", self.replace_variable(repo_name)),
                      Parameter("CF_BRANCH",    self.replace_variable(block['revision']))
                  ])
          elif step_type == 'build':
              tag=grab_field_value(block, "tag", '${CF_BRANCH}')
              dockerfile=grab_field_value(block, "dockerfile", "Dockerfile")
              registry=grab_field_value(block, "registry", "docker-config")
              self.add_secret_volume(registry);
              step_obj = Plugins(name, "build", "0.0.1", block,
                  [
                      Parameter('image_name', self.replace_variable(block['image_name'])),
                      Parameter("tag", self.replace_variable(tag)),
                      Parameter("dockerfile", self.replace_variable(dockerfile)),
                      Parameter("working_directory", self.replace_variable(cwd)),
                      Parameter("docker-config", registry)
                  ])
          elif '/' in step_type:
              self.logger.critical("Typed step not supported %s",step_type)
              raise StepTypeNotSupported("Typed step")
          else:
              raise StepTypeNotSupported(step_type)
  
          if "when" in block:
              conditions=create_conditions_for_a_step(block['when'])
              self.logger.debug("Plugins %s conditions: %s",name, step_obj.conditions)
              step_obj.conditions=conditions
  
          self.logger.debug("Plugins %s conditions: %s",name, step_obj.conditions)
          return step_obj
code_tokens: def create_step ( self , name , block ) : step_type = grab_field_value ( block , "type" , "freestyle" ) cwd = grab_field_value ( block , "working_directory" , "/codefresh/volume" ) cwd = replace_parameter_variable_by_step_output ( cwd , "WORKING_DIR" ) if step_type == 'freestyle' : shell = grab_field_value ( block , "shell" , "sh" ) commands = "" if 'commands' in block : logging . debug ( "COMMAND: %s" , block [ 'commands' ] ) string = '' for line in block [ 'commands' ] : string += f"{line}\n" string += "\n" commands = string image = replace_parameter_variable_by_step_output ( block [ 'image' ] , "IMAGE" ) step_obj = Plugins ( name , "freestyle" , "0.0.1" , block , [ Parameter ( 'image' , self . replace_variable ( image ) ) , Parameter ( "working_directory" , self . replace_variable ( cwd ) ) , Parameter ( "shell" , self . replace_variable ( shell ) ) , Parameter ( "commands" , commands ) ] ) elif step_type == 'git-clone' : ( repo_owner , repo_name ) = parse_repo_field ( block [ 'repo' ] ) step_obj = Plugins ( name , "git-clone" , "0.0.1" , block , [ Parameter ( 'CF_REPO_OWNER' , self . replace_variable ( repo_owner ) ) , Parameter ( "CF_REPO_NAME" , self . replace_variable ( repo_name ) ) , Parameter ( "CF_BRANCH" , self . replace_variable ( block [ 'revision' ] ) ) ] ) elif step_type == 'build' : tag = grab_field_value ( block , "tag" , '${CF_BRANCH}' ) dockerfile = grab_field_value ( block , "dockerfile" , "Dockerfile" ) registry = grab_field_value ( block , "registry" , "docker-config" ) self . add_secret_volume ( registry ) ; step_obj = Plugins ( name , "build" , "0.0.1" , block , [ Parameter ( 'image_name' , self . replace_variable ( block [ 'image_name' ] ) ) , Parameter ( "tag" , self . replace_variable ( tag ) ) , Parameter ( "dockerfile" , self . replace_variable ( dockerfile ) ) , Parameter ( "working_directory" , self . replace_variable ( cwd ) ) , Parameter ( "docker-config" , registry ) ] ) elif '/' in step_type : self . logger . critical ( "Typed step not supported %s" , step_type ) raise StepTypeNotSupported ( "Typed step" ) else : raise StepTypeNotSupported ( step_type ) if "when" in block : conditions = create_conditions_for_a_step ( block [ 'when' ] ) self . logger . debug ( "Plugins %s conditions: %s" , name , step_obj . conditions ) step_obj . conditions = conditions self . logger . debug ( "Plugins %s conditions: %s" , name , step_obj . conditions ) return step_obj
short_docstring: Check the type of step to create the correct class object
short_docstring_tokens: Check the type of step to create the correct class object
comment: '''Check the type of step to create the correct class object'''$SEP$# adding empty line to force | output$SEP$#self.logger.debug("Freestyle step cwd: %s", cwd)$SEP$#self.logger.debug("Freestyle step cwd after: %s", cwd)