Completed
Push — master ( 471a4d...6ed34d )
by Arma
06:19
created

ExpandRepoName   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %
Metric Value
wmc 3
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 21 3
1
#!/usr/bin/env python
2
3
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
4
# contributor license agreements.  See the NOTICE file distributed with
5
# this work for additional information regarding copyright ownership.
6
# The ASF licenses this file to You under the Apache License, Version 2.0
7
# (the "License"); you may not use this file except in compliance with
8
# the License.  You may obtain a copy of the License at
9
#
10
#     http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
17
18
import sys
19
import requests
20
import json
21
import getopt
22
import argparse
23
import os
24
import yaml
25
26
from getpass import getpass
27
from st2actions.runners.pythonrunner import Action
28
29
class ExpandRepoName(Action):
30
    def run(self, repo_name):
31
        """Returns the data required to install packs from repo_name.
32
33
        Keyword arguments:
34
          repo_name -- The Reposistory name to look up in the Packs config.yaml.
35
36
        Returns: A Dict containing repo_url and subtree.
37
38
        Raises:
39
          ValueError: If the supplied repo_name is present (or complete).
40
        """
41
        # Set up the results object
42
        results = {}
43
44
        try:
45
            results['repo_url'] = self.config["repositories"][repo_name]["repo"]
46
            results['subtree'] = self.config["repositories"][repo_name]["subtree"]
47
        except KeyError:
48
            raise ValueError("Missing repositories config for '%s'" % repo_name)
49
        else:
50
            return results
51