Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Use Cases:

User has configured a pipeline with multiple plugins , User wants to use REST endpoint to see the plugins used in the app along with programs, streams and datasets used by the pipeline when getting application detail.

User is populating runtime arguments, for the DBSource plugin in his pipeline, he wants to get all the configured macros for that plugin stage, so its easy for user to provide those values as runtime arguments.

User Story:


1) User wants to see list of plugins in the app when calling application detail REST endpoint.
2) For a plugin, user wants to get the details on plugin, including plugin properties and list of macros used in properties.

Design:


 
class PluginDetail {
	String pluginName;
	String pluginType;
}
 
Example : PluginDetail {pluginName : "source1", pluginType: "DBSource"}

 

PluginDetail for plugins will be added to co.cask.cdap.proto.ApplicationDetail

public class ApplicationDetail {
  // existing
  private final String name;
  private final String version;
  private final String description;
  private final String configuration;
  private final List<StreamDetail> streams;
  private final List<DatasetDetail> datasets;
  private final List<ProgramRecord> programs;
  private final ArtifactSummary artifact;
  // new field
  private final List<PluginDetail> plugins;
}


REST Endpoint :

GET: /v3/namespaces/{namespace-id}/apps/{app-id}/plugins/{plugin-id}
 
{plugin-id} is unique in the app.
this will return JSON of Plugin object corresponding to the plugin-id. 
public final class Plugin {
  // Existing
  private final ArtifactId artifactId;
  private final PluginClass pluginClass;
  private final PluginProperties properties;
  // new field 
  
  /* macros used at this plugin 
   * Examples : 
   * for the field value ${hostname}:${port}/${path}, the set would be[hostname, port, path]
   * for the field value ${secure(accessKey)}, the set would be [accessKey]
   * for the field value ${key1:${key2}}, the set would be [key2, key1:${key2}]
   * for the field value \${u-name}, the set would be empty as macro is escaped    
   * for the field value ${key1\${key2}}, the set would be [key1\${key2}] so the user understands key2 is not a macro and will provide value for the key, "key1${key2}"
   */
   private final Set<String> macros;
   Plugin(ArtifactId artifactId, PluginClass pluginClass, PluginProperties, @Nullable Set<String> macros) {
	...
  }
  ...
}

 

Another Option is instead of returning Set<String> macros, we can return MacroInfo object.

class MacroInfo {
	Set<String> properties;
	Set<MacroFunction> functions;
}


class MacroFunction {
	String functionName;
	List<String> arguments;
}

 

Though the UI will only be interested in properties, having macro function information will be useful when getting details of a plugin.

Notes:

macros can either be nullable to support backward compatibility
or we need upgrade step to provide empty set for macros when upgrading pipeline.

 

  • No labels