github.com/jfrog/jfrog-cli-core/v2@v2.51.0/common/spec/builder.go (about)

     1  package spec
     2  
     3  import (
     4  	"strconv"
     5  )
     6  
     7  type builder struct {
     8  	pattern                 string
     9  	exclusions              []string
    10  	target                  string
    11  	explode                 string
    12  	bypassArchiveInspection bool
    13  	props                   string
    14  	targetProps             string
    15  	excludeProps            string
    16  	sortOrder               string
    17  	sortBy                  []string
    18  	offset                  int
    19  	limit                   int
    20  	build                   string
    21  	project                 string
    22  	excludeArtifacts        bool
    23  	includeDeps             bool
    24  	bundle                  string
    25  	publicGpgKey            string
    26  	recursive               bool
    27  	flat                    bool
    28  	regexp                  bool
    29  	ant                     bool
    30  	includeDirs             bool
    31  	archiveEntries          string
    32  	validateSymlinks        bool
    33  	symlinks                bool
    34  	archive                 string
    35  	transitive              bool
    36  	targetPathInArchive     string
    37  	include                 []string
    38  }
    39  
    40  func NewBuilder() *builder {
    41  	return &builder{}
    42  }
    43  
    44  func (b *builder) Pattern(pattern string) *builder {
    45  	b.pattern = pattern
    46  	return b
    47  }
    48  
    49  func (b *builder) ArchiveEntries(archiveEntries string) *builder {
    50  	b.archiveEntries = archiveEntries
    51  	return b
    52  }
    53  
    54  func (b *builder) Exclusions(exclusions []string) *builder {
    55  	b.exclusions = exclusions
    56  	return b
    57  }
    58  
    59  func (b *builder) Target(target string) *builder {
    60  	b.target = target
    61  	return b
    62  }
    63  
    64  func (b *builder) Explode(explode string) *builder {
    65  	b.explode = explode
    66  	return b
    67  }
    68  
    69  func (b *builder) BypassArchiveInspection(bypassArchiveInspection bool) *builder {
    70  	b.bypassArchiveInspection = bypassArchiveInspection
    71  	return b
    72  }
    73  
    74  func (b *builder) Props(props string) *builder {
    75  	b.props = props
    76  	return b
    77  }
    78  
    79  func (b *builder) TargetProps(targetProps string) *builder {
    80  	b.targetProps = targetProps
    81  	return b
    82  }
    83  
    84  func (b *builder) ExcludeProps(excludeProps string) *builder {
    85  	b.excludeProps = excludeProps
    86  	return b
    87  }
    88  
    89  func (b *builder) SortOrder(sortOrder string) *builder {
    90  	b.sortOrder = sortOrder
    91  	return b
    92  }
    93  
    94  func (b *builder) SortBy(sortBy []string) *builder {
    95  	b.sortBy = sortBy
    96  	return b
    97  }
    98  
    99  func (b *builder) Offset(offset int) *builder {
   100  	b.offset = offset
   101  	return b
   102  }
   103  
   104  func (b *builder) Limit(limit int) *builder {
   105  	b.limit = limit
   106  	return b
   107  }
   108  
   109  func (b *builder) Build(build string) *builder {
   110  	b.build = build
   111  	return b
   112  }
   113  
   114  func (b *builder) Project(project string) *builder {
   115  	b.project = project
   116  	return b
   117  }
   118  
   119  func (b *builder) ExcludeArtifacts(excludeArtifacts bool) *builder {
   120  	b.excludeArtifacts = excludeArtifacts
   121  	return b
   122  }
   123  
   124  func (b *builder) IncludeDeps(includeDeps bool) *builder {
   125  	b.includeDeps = includeDeps
   126  	return b
   127  }
   128  
   129  func (b *builder) Bundle(bundle string) *builder {
   130  	b.bundle = bundle
   131  	return b
   132  }
   133  
   134  func (b *builder) PublicGpgKey(gpgKey string) *builder {
   135  	b.publicGpgKey = gpgKey
   136  	return b
   137  }
   138  
   139  func (b *builder) Archive(archive string) *builder {
   140  	b.archive = archive
   141  	return b
   142  }
   143  
   144  func (b *builder) TargetPathInArchive(targetPathInArchive string) *builder {
   145  	b.targetPathInArchive = targetPathInArchive
   146  	return b
   147  }
   148  
   149  func (b *builder) Recursive(recursive bool) *builder {
   150  	b.recursive = recursive
   151  	return b
   152  }
   153  
   154  func (b *builder) Flat(flat bool) *builder {
   155  	b.flat = flat
   156  	return b
   157  }
   158  
   159  func (b *builder) Regexp(regexp bool) *builder {
   160  	b.regexp = regexp
   161  	return b
   162  }
   163  
   164  func (b *builder) Ant(ant bool) *builder {
   165  	b.ant = ant
   166  	return b
   167  }
   168  
   169  func (b *builder) IncludeDirs(includeDirs bool) *builder {
   170  	b.includeDirs = includeDirs
   171  	return b
   172  }
   173  
   174  func (b *builder) ValidateSymlinks(validateSymlinks bool) *builder {
   175  	b.validateSymlinks = validateSymlinks
   176  	return b
   177  }
   178  
   179  func (b *builder) Symlinks(symlinks bool) *builder {
   180  	b.symlinks = symlinks
   181  	return b
   182  }
   183  
   184  func (b *builder) Transitive(transitive bool) *builder {
   185  	b.transitive = transitive
   186  	return b
   187  }
   188  
   189  func (b *builder) Include(include []string) *builder {
   190  	b.include = include
   191  	return b
   192  }
   193  
   194  func (b *builder) BuildSpec() *SpecFiles {
   195  	return &SpecFiles{
   196  		Files: []File{
   197  			{
   198  				Pattern:                 b.pattern,
   199  				Exclusions:              b.exclusions,
   200  				Target:                  b.target,
   201  				Props:                   b.props,
   202  				TargetProps:             b.targetProps,
   203  				ExcludeProps:            b.excludeProps,
   204  				SortOrder:               b.sortOrder,
   205  				SortBy:                  b.sortBy,
   206  				Offset:                  b.offset,
   207  				Limit:                   b.limit,
   208  				Build:                   b.build,
   209  				Project:                 b.project,
   210  				Bundle:                  b.bundle,
   211  				PublicGpgKey:            b.publicGpgKey,
   212  				Explode:                 b.explode,
   213  				BypassArchiveInspection: strconv.FormatBool(b.bypassArchiveInspection),
   214  				ArchiveEntries:          b.archiveEntries,
   215  				Archive:                 b.archive,
   216  				TargetPathInArchive:     b.targetPathInArchive,
   217  				Recursive:               strconv.FormatBool(b.recursive),
   218  				Flat:                    strconv.FormatBool(b.flat),
   219  				Regexp:                  strconv.FormatBool(b.regexp),
   220  				Ant:                     strconv.FormatBool(b.ant),
   221  				IncludeDirs:             strconv.FormatBool(b.includeDirs),
   222  				ValidateSymlinks:        strconv.FormatBool(b.validateSymlinks),
   223  				ExcludeArtifacts:        strconv.FormatBool(b.excludeArtifacts),
   224  				IncludeDeps:             strconv.FormatBool(b.includeDeps),
   225  				Symlinks:                strconv.FormatBool(b.symlinks),
   226  				Transitive:              strconv.FormatBool(b.transitive),
   227  				include:                 b.include,
   228  			},
   229  		},
   230  	}
   231  }