github.com/apptainer/singularity@v3.1.1+incompatible/internal/pkg/build/assembler.go (about)

     1  // Copyright (c) 2018, Sylabs Inc. All rights reserved.
     2  // This software is licensed under a 3-clause BSD license. Please consult the
     3  // LICENSE.md file distributed with the sources of this project regarding your
     4  // rights to use or distribute this software.
     5  
     6  package build
     7  
     8  import (
     9  	"fmt"
    10  
    11  	"github.com/sylabs/singularity/pkg/build/types"
    12  )
    13  
    14  // validAssemblers contains of list of know Assemblers
    15  var validAssemblers = map[string]bool{
    16  	"SIF":     true,
    17  	"sandbox": true,
    18  }
    19  
    20  // Assembler is responsible for assembling an image from a bundle.
    21  // For example a bundle may be holding multiple file systems indended
    22  // to be separate partitions within a SIF image. The assembler would need
    23  // to detect these directories and make sure it properly assembles the SIF
    24  // with them as partitions
    25  type Assembler interface {
    26  	Assemble(*types.Bundle, string) error
    27  }
    28  
    29  // IsValidAssembler returns whether or not the given Assembler is valid
    30  func IsValidAssembler(c string) (valid bool, err error) {
    31  	if _, ok := validAssemblers[c]; ok {
    32  		return true, nil
    33  	}
    34  
    35  	return false, fmt.Errorf("Invalid Assembler %s", c)
    36  }