DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Package Parameters in OpenWhisk

Package Parameters in OpenWhisk

Attaching OpenWhisk parameters to packages can be tricky, and setting parameters on individually on the command line can get clunky fast. Put them in a file instead.

Lorna Mitchell user avatar by
Lorna Mitchell
·
May. 30, 17 · Cloud Zone · Tutorial
Like (2)
Save
Tweet
2.34K Views

Join the DZone community and get the full member experience.

Join For Free

I love OpenWhisk, but I struggled a little to get the parameters attached in a sane way for a while, so I am capturing my notes here for future reference! Parameters can be attached to actions or packages; I tend to break my actions down really small and pass data into them, while preferring to set parameters on the package that the actions belong to.

You can set parameters on the command line individually, like this:

wsk package update mypackage -p dbname awesomedb

This gets clunky once you have a few parameters, and you can't add new parameters — whatever you use here will remove any previous params and overwrite. Instead, I like to hold the parameters in a file, and edit it and update the action as needed.

Pro tip: You probably don't want to store the parameters file in source control! Feed it to your deployment toolchain.

Parameters files should be formatted something like this (it's JSON):

{
    "slackURL": "https://hooks.slack.com/services/blah/blah",
    "cloudantURL": "https://wibble-squeak-bluemix.cloudant.com",
    "dbname": "awesomedb"
}


Then to supply this file (called params.json) to the package:

wsk package update mypackage -P params.json

(That's an uppercase P , not the lowercase one as in the earlier example)

You can use this approach to more easily repeat existing parameters, and just add/change what you need to.

Pro-tip: Wondering what parameters are already set on this package? Use wsk package get mypackage parameters to see!

Data (computing) Pass (software) Command (computing)

Published at DZone with permission of Lorna Mitchell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Is Kafka? Everything You Need to Know
  • Purpose-Driven Microservice Design
  • Refactor Switch to a One-Liner
  • Architecture as Code With C4 and Plantuml

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo