Ask Your Question
0

Struct as Class Parameter?

asked 2015-07-28 13:09:20 -0500

sumoway gravatar image

Can a module's class (init.pp) have a Struct as a parameter? I want to do this...

class sumologic (
  Struct[ {
    NotUndef[access_id]    => String[15,15],
    NotUndef[access_key]   => String[65,65],
    Optional[local]        => Boolean,
    Optional[clobber]      => Boolean,
    Optional[ephemeral]    => Boolean,
    Optional[name]         => String[1],
    Optional[override]     => Boolean,
    Optional[proxy_host]   => String[1],
    Optional[proxy_domain] => String[1],
    Optional[proxy_pass]   => String[1],
    Optional[proxy_port]   => Integer[0],
    Optional[proxy_user]   => String[1]
  } ] $sumo_conf,
  Array[ Struct[ {
    name => String[1],
    Optional[description]    => String[1],
    Optional[category]       => String[1],
    Optional[host_name]      => String[1],
    Optional[timezone]       => String[1], # TZ database format
    source_type              => Enum[ 'LocalFile', 'RemoteFileV2',
      'LocalWindowsEventLog', 'RemoteWindowsEventLog', 'LocalWindowsPerfMon',
      'RemoteWindowsPerfMon', 'Syslog', 'Script', 'AmazonS3', 'HTTP' ],
    Optional[infer_date]     => Boolean,
    Optional[multiline]      => Boolean,
    Optional[infer_boundary] => Boolean,
    Optional[regex_boundary] => String[1],
    Optional[force_timezone] => Boolean,
    Optional[date_format]    => String[1],
    Optional[filters]        => Array[String[1]],
    alive                    => Boolean
  } ] ] $sources_json
) {...}

...but it complains...

Error: Syntax error at 'Struct'; expected ')' at...init.pp: 51

Line 51 is the 2nd line above where it reads: "Struct [ {"

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-08-15 13:58:23 -0500

Woefdram gravatar image

It looks like you want class sumologic to accept a nested hash. I think your declaration should look something like this:

class sumologic ( $struct ) { ... }

The exact definition of that struct is done elsewhere.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-28 13:09:20 -0500

Seen: 127 times

Last updated: Aug 15 '15