Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit config and fix linting #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exclude: "^vendor/.*"
repos:
- repo: https://github.com/syntaqx/git-hooks
rev: v0.0.16
hooks:
- id: circleci-config-validate
- id: go-fmt
- repo: git://github.com/PyCQA/pylint
rev: pylint-2.4.4
hooks:
- id: pylint
types: [file] # Overrides types: [python]
files: \.(star|ipd)$
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
34 changes: 34 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[MASTER]

disable=
missing-docstring,
undefined-variable,
assert-on-tuple,
invalid-name,
len-as-condition,
unused-argument,
duplicate-code,
no-member,
syntax-error,
fixme,
redefined-outer-name,
too-many-locals,
redefined-builtin,
too-many-arguments,
dangerous-default-value,
singleton-comparison,
superfluous-parens,
misplaced-comparison-constant,
anomalous-backslash-in-string,


[FORMAT]

# Maximum number of characters on a single line.
max-line-length=120

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$

# Maximum number of lines in a single file.
max-module-lines=2000
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ require (
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
sigs.k8s.io/yaml v1.1.0
)

go 1.13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your machine added this line behind the scenes, because you have go 1.13 installed. However if we merge it, we hav a go.mod with go 1.13, a .circleci/config.yml with go 1.12 and a Dockerfile with go 1.11.
I recommend to remove this line from your PR to not conflict with #26, and then after #26 is merged, everything is up to date on the same version 😊

1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stripe/skycfg v0.0.0-20190805025019-bafbc3998017 h1:QF2hQ30rLdDMk6oB4ezDZ7GKiu7iL7ulyg7BT0VvjL8=
github.com/stripe/skycfg v0.0.0-20190805025019-bafbc3998017/go.mod h1:nc0qou0URq+8vaEcIz0O6ZD9DgYdLiwYRWWyB2LwSAU=
github.com/stripe/skycfg v0.0.0-20200303020846-4f599970a3e6 h1:Nr78kwzRyXZaimz7tFFlJcc5mO2rMecmP/eiCPHDeqE=
github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds=
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8=
Expand Down
14 changes: 7 additions & 7 deletions testdata/addon.ipd
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@


def match(ctx):
print("match")
return True
print("match")
return True

def status(ctx):
return ctx.cluster + " status"
return ctx.cluster + " status"

def install(ctx):
if ctx.snafoo != None:
error("Non-existent context is not `None': {ctx}".format(ctx=ctx.snafoo))
print("install " + ctx.cluster)
if ctx.snafoo != None:
error("Non-existent context is not `None': {ctx}".format(ctx=ctx.snafoo))
print("install " + ctx.cluster)

def remove(ctx):
print("remove " + ctx.cluster)
print("remove " + ctx.cluster)
17 changes: 9 additions & 8 deletions testdata/ingress.ipd
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ metav1 = proto.package("k8s.io.apimachinery.pkg.apis.meta.v1")


def install(ctx):
print("Installing ingress for cluster={cluster}...".format(cluster=ctx.cluster))
print("Installing ingress for cluster={cluster}...".format(cluster=ctx.cluster))

data = vault.read("secret/car/cert")
data = vault.read("secret/car/cert")

kube.put(
name = ctx.namespace,
data = [
corev1.Namespace(metadata=metav1.ObjectMeta(labels={"foo": "bar"})),
])
kube.put(
name=ctx.namespace,
data=[
corev1.Namespace(metadata=metav1.ObjectMeta(labels={"foo": "bar"})),
],
)

print("{a}".format(a=data["crt"]))
print("{a}".format(a=data["crt"]))
4 changes: 2 additions & 2 deletions testdata/istio/helm.ipd
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
def install(ctx):
print('Installing helm chart for cluster={cluster}...'.format(cluster=ctx.cluster))

globalValues="""
globalValues = """
global:
priorityClassName: "cluster-critical"
"""
pilotValues="""
pilotValues = """
pilot:
replicaCount: 3
image: "docker.io/istio/pilot:v1.2.3"
Expand Down
2 changes: 1 addition & 1 deletion testdata/main.ipd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load("clusters.star", "CLUSTERS")
def clusters(ctx):
if ctx.cluster != None:
return [c for c in CLUSTERS if c.cluster == ctx.cluster]
elif ctx.env != None:
if ctx.env != None:
return [c for c in CLUSTERS if c.env == ctx.env]
return CLUSTERS

Expand Down
4 changes: 2 additions & 2 deletions testdata/values.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

moreValues="""
moreValues = """
global:
configNamespace: istio-pilot
"""

globalValues="""
globalValues = """
global:
priorityClassName: "cluster-critical",
"""