Skip to content

Commit

Permalink
chore(api): apply gofmt -s (simplify) to the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Hambley committed Dec 7, 2017
1 parent 3922d0d commit 05f1d26
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 111 deletions.
4 changes: 2 additions & 2 deletions api/src/github.com/harrowio/harrow/authz/service.go
Expand Up @@ -173,7 +173,7 @@ func (s *txService) Can(action string, thing interface{}) (bool, error) {

func (s *txService) useBasicCapablities() {
s.capabilities = BasicCapabilities()
for capability, _ := range s.addedRoles {
for capability := range s.addedRoles {
s.capabilities[capability] = true
}
}
Expand Down Expand Up @@ -507,7 +507,7 @@ func (s *txService) CanUpdate(thing interface{}) (bool, error) {

func (self *txService) CapabilitiesBySubject() map[string][]string {
result := map[string][]string{}
for cap, _ := range self.capabilities {
for cap := range self.capabilities {
sep := strings.Index(cap, "-")
verb := cap[0:sep]
subject := cap[sep+1:]
Expand Down
8 changes: 4 additions & 4 deletions api/src/github.com/harrowio/harrow/authz/service_test.go
Expand Up @@ -159,10 +159,10 @@ func Test_txService_CapabilitiesBySubject_returnsSetOfAllSubjectsWithCapabilitie
service := NewService(tx, user, config.GetConfig())

expected := map[string][]string{
"public": []string{"read"},
"session": []string{"create", "validate"},
"user": []string{"signup"},
"organization": []string{"create"},
"public": {"read"},
"session": {"create", "validate"},
"user": {"signup"},
"organization": {"create"},
}

capabilities := service.CapabilitiesBySubject()
Expand Down
6 changes: 3 additions & 3 deletions api/src/github.com/harrowio/harrow/awslib/awslib.go
Expand Up @@ -60,7 +60,7 @@ func FilterInstancesByTag(asInstances []*autoscaling.Instance, tag string) ([]*e
params := &ec2.DescribeInstancesInput{
InstanceIds: instanceIDs,
Filters: []*ec2.Filter{
&ec2.Filter{Name: aws.String("tag-key"), Values: []*string{aws.String(tag)}},
{Name: aws.String("tag-key"), Values: []*string{aws.String(tag)}},
},
NextToken: nextToken,
}
Expand All @@ -85,7 +85,7 @@ func FilterInstancesByTag(asInstances []*autoscaling.Instance, tag string) ([]*e
func GetTags(instanceId string) ([]*ec2.TagDescription, error) {
input := &ec2.DescribeTagsInput{
Filters: []*ec2.Filter{
&ec2.Filter{Name: aws.String("resource-id"), Values: []*string{aws.String(instanceId)}},
{Name: aws.String("resource-id"), Values: []*string{aws.String(instanceId)}},
},
}
out, err := ec2Service.DescribeTags(input)
Expand Down Expand Up @@ -136,7 +136,7 @@ func PutMetricData(metricName string, value float64) error {
input := &cloudwatch.PutMetricDataInput{
Namespace: aws.String("harrow"),
MetricData: []*cloudwatch.MetricDatum{
&cloudwatch.MetricDatum{
{
MetricName: aws.String(metricName),
Value: aws.Float64(value),
},
Expand Down
Expand Up @@ -39,7 +39,7 @@ func Test_RedisSource(t *testing.T) {
transport.Close()
}()
cnt := 0
for _ = range msgs {
for range msgs {
cnt++
}
if cnt != n {
Expand Down
2 changes: 1 addition & 1 deletion api/src/github.com/harrowio/harrow/cmd/op-metrics/main.go
Expand Up @@ -106,7 +106,7 @@ func Main() {
waitTime99Metrics []Metric = []Metric{}
waitTime95Metrics []Metric = []Metric{}
waitTimeMeanMetrics []Metric = []Metric{}
pendingOpCounts []Metric = []Metric{Metric{X: time.Now().Unix(), Y: pendingOpCount}}
pendingOpCounts []Metric = []Metric{{X: time.Now().Unix(), Y: pendingOpCount}}
)

for _, t := range timeouts {
Expand Down
2 changes: 1 addition & 1 deletion api/src/github.com/harrowio/harrow/config/oauth.go
Expand Up @@ -20,7 +20,7 @@ type OAuthProviderConfig struct {
func (c Config) OAuthConfig() OAuthConfig {
return OAuthConfig{
Providers: map[string]OAuthProviderConfig{
"github": OAuthProviderConfig{
"github": {
ClientId: os.Getenv("HAR_OAUTH_GITHUB_CLIENT_ID"),
ClientSecret: os.Getenv("HAR_OAUTH_GITHUB_CLIENT_SECRET"),
ProviderUrl: getEnvWithDefault("HAR_OAUTH_GITHUB_PROVIDER_URL", "https://test.tld/#/a/github/callback/"),
Expand Down
72 changes: 36 additions & 36 deletions api/src/github.com/harrowio/harrow/diff/diff_test.go
Expand Up @@ -46,10 +46,10 @@ func TestChanges_returns_a_list_of_changed_lines(t *testing.T) {
}

expected := []*Change{
&Change{Context, 1, "a"},
&Change{Removal, 2, "b"},
&Change{Addition, 2, "d"},
&Change{Context, 3, "c"},
{Context, 1, "a"},
{Removal, 2, "b"},
{Addition, 2, "d"},
{Context, 3, "c"},
}

if got, want := changes, expected; !reflect.DeepEqual(got, want) {
Expand All @@ -64,18 +64,18 @@ func TestChanges_increases_line_numbers_for_every_addition(t *testing.T) {
}

expected := []*Change{
&Change{Addition, 1, "A=1"},
&Change{Context, 2, "a() {"},
&Change{Context, 3, " date"},
&Change{Context, 4, "}"},
&Change{Context, 5, ""},
&Change{Addition, 6, "C=1"},
&Change{Addition, 7, ""},
&Change{Context, 8, "b() {"},
&Change{Context, 9, " date"},
&Change{Context, 10, "}"},
&Change{Addition, 11, ""},
&Change{Addition, 12, "B=1"},
{Addition, 1, "A=1"},
{Context, 2, "a() {"},
{Context, 3, " date"},
{Context, 4, "}"},
{Context, 5, ""},
{Addition, 6, "C=1"},
{Addition, 7, ""},
{Context, 8, "b() {"},
{Context, 9, " date"},
{Context, 10, "}"},
{Addition, 11, ""},
{Addition, 12, "B=1"},
}

if got, want := changes, expected; !reflect.DeepEqual(got, want) {
Expand All @@ -100,13 +100,13 @@ func TestChanges_extracts_line_number_from_hunk_header(t *testing.T) {
}

expected := []*Change{
&Change{Context, 65, "65"},
&Change{Context, 66, "66"},
&Change{Context, 67, "67"},
&Change{Removal, 68, "68"},
&Change{Context, 68, "69"},
&Change{Context, 69, "70"},
&Change{Context, 70, "71"},
{Context, 65, "65"},
{Context, 66, "66"},
{Context, 67, "67"},
{Removal, 68, "68"},
{Context, 68, "69"},
{Context, 69, "70"},
{Context, 70, "71"},
}

if got, want := changes, expected; !reflect.DeepEqual(got, want) {
Expand All @@ -131,19 +131,19 @@ func TestChanges_extracts_processes_multiple_hunk_headers(t *testing.T) {
}

expected := []*Change{
&Change{Context, 65, "65"},
&Change{Context, 66, "66"},
&Change{Context, 67, "67"},
&Change{Removal, 68, "68"},
&Change{Context, 68, "69"},
&Change{Context, 69, "70"},
&Change{Context, 70, "71"},
&Change{Context, 95, "95"},
&Change{Context, 96, "96"},
&Change{Context, 97, "97"},
&Change{Removal, 98, "98"},
&Change{Context, 98, "99"},
&Change{Context, 99, "100"},
{Context, 65, "65"},
{Context, 66, "66"},
{Context, 67, "67"},
{Removal, 68, "68"},
{Context, 68, "69"},
{Context, 69, "70"},
{Context, 70, "71"},
{Context, 95, "95"},
{Context, 96, "96"},
{Context, 97, "97"},
{Removal, 98, "98"},
{Context, 98, "99"},
{Context, 99, "100"},
}

if got, want := changes, expected; !reflect.DeepEqual(got, want) {
Expand Down
Expand Up @@ -71,7 +71,7 @@ func (l *capabilityList) add(capabilities []string) *capabilityList {
}

merged := make([]string, 0, len(set))
for cap, _ := range set {
for cap := range set {
merged = append(merged, cap)
}

Expand Down
6 changes: 3 additions & 3 deletions api/src/github.com/harrowio/harrow/domain/delivery_test.go
Expand Up @@ -27,13 +27,13 @@ func Test_Delivery_Links(t *testing.T) {
}

expected := map[string]map[string]string{
"self": map[string]string{
"self": {
"href": "http://www.example.com/deliveries/607982b8-b0f1-4762-8bd1-ac230310ef8e",
},
"webhook": map[string]string{
"webhook": {
"href": "http://www.example.com/webhooks/54d4fc6c-a5e3-4fd0-b707-7a295c3da6d7",
},
"schedule": map[string]string{
"schedule": {
"href": "http://www.example.com/schedules/13fdf67b-b672-4713-914f-d02b066e3173",
},
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/github.com/harrowio/harrow/domain/money.go
Expand Up @@ -93,5 +93,5 @@ func (self Money) MarshalJSON() ([]byte, error) {
}

func (self *Money) UnmarshalJSON(src []byte) error {
return self.Scan(src[1:len(src)])
return self.Scan(src[1:])
}
22 changes: 11 additions & 11 deletions api/src/github.com/harrowio/harrow/domain/operation_test.go
Expand Up @@ -130,7 +130,7 @@ func Test_Operation_Environment_ReturnsEnvironmentForAJob(t *testing.T) {

store := &mockEnvStore{
byJobUuid: map[string]*Environment{
job.Uuid: &Environment{
job.Uuid: {
Uuid: job.EnvironmentUuid,
},
},
Expand Down Expand Up @@ -164,8 +164,8 @@ func Test_Operation_Secrets(t *testing.T) {
}

expSecrets := []*Secret{
&Secret{EnvironmentUuid: env.Uuid},
&Secret{EnvironmentUuid: env.Uuid},
{EnvironmentUuid: env.Uuid},
{EnvironmentUuid: env.Uuid},
}
secretStore := &mockSecretStore{
byEnvironmentUuid: map[string][]*Secret{
Expand Down Expand Up @@ -201,8 +201,8 @@ func Test_Operation_IsReady(t *testing.T) {
}

secrets := []*Secret{
&Secret{EnvironmentUuid: env.Uuid, Status: SecretPending},
&Secret{EnvironmentUuid: env.Uuid, Status: SecretPending},
{EnvironmentUuid: env.Uuid, Status: SecretPending},
{EnvironmentUuid: env.Uuid, Status: SecretPending},
}
secretStore := &mockSecretStore{
byEnvironmentUuid: map[string][]*Secret{
Expand All @@ -211,8 +211,8 @@ func Test_Operation_IsReady(t *testing.T) {
}

repos := []*Repository{
&Repository{Uuid: "485f5eb0-b1e6-4617-b409-efd7d29ecfac"},
&Repository{Uuid: "3b58159a-39f8-4227-9e07-429dbbf89063"},
{Uuid: "485f5eb0-b1e6-4617-b409-efd7d29ecfac"},
{Uuid: "3b58159a-39f8-4227-9e07-429dbbf89063"},
}
reposStore := &mockRepositoryStore{
byJobUuid: map[string][]*Repository{
Expand All @@ -230,8 +230,8 @@ func Test_Operation_IsReady(t *testing.T) {

// Adding only the RepositoryCredentials should not make the operation ready
repoCredentials := []*RepositoryCredential{
&RepositoryCredential{RepositoryUuid: repos[0].Uuid},
&RepositoryCredential{RepositoryUuid: repos[1].Uuid},
{RepositoryUuid: repos[0].Uuid},
{RepositoryUuid: repos[1].Uuid},
}
repoCredentialsStore = &mockRepositoryCredentialsStore{
byRepositoryUuid: map[string]*RepositoryCredential{
Expand Down Expand Up @@ -274,8 +274,8 @@ func Test_Operation_Repositories_JobOperation(t *testing.T) {
}

repos := []*Repository{
&Repository{Uuid: "485f5eb0-b1e6-4617-b409-efd7d29ecfac"},
&Repository{Uuid: "3b58159a-39f8-4227-9e07-429dbbf89063"},
{Uuid: "485f5eb0-b1e6-4617-b409-efd7d29ecfac"},
{Uuid: "3b58159a-39f8-4227-9e07-429dbbf89063"},
}
reposStore := &mockRepositoryStore{
byJobUuid: map[string][]*Repository{
Expand Down
Expand Up @@ -38,10 +38,10 @@ func Test_ProjectMembership_Links(t *testing.T) {
pm.Links(links, "http", "example.com")

expected := map[string]map[string]string{
"project": map[string]string{
"project": {
"href": "http://example.com/projects/" + pm.ProjectUuid,
},
"user": map[string]string{
"user": {
"href": "http://example.com/users/" + pm.UserUuid,
},
}
Expand Down
Expand Up @@ -16,13 +16,13 @@ func Test_ScheduledExecution_ExecutionsBetween(t *testing.T) {
to := must3339("2000-01-01T00:08:05Z")

expected := []*ScheduledExecution{
&ScheduledExecution{Time: must3339("2000-01-01T00:02:00Z"), Spec: eachTwoSpec, Description: "each two"},
&ScheduledExecution{Time: must3339("2000-01-01T00:03:00Z"), Spec: eachThreeSpec, Description: "each three"},
&ScheduledExecution{Time: must3339("2000-01-01T00:04:00Z"), Spec: eachTwoSpec, Description: "each two"},
&ScheduledExecution{Time: must3339("2000-01-01T00:06:00Z"), Spec: eachTwoSpec, Description: "each two"},
&ScheduledExecution{Time: must3339("2000-01-01T00:06:00Z"), Spec: eachThreeSpec, Description: "each three"},
&ScheduledExecution{Time: must3339("2000-01-01T00:07:00Z"), Spec: onSevenSpec, Description: "on seven"},
&ScheduledExecution{Time: must3339("2000-01-01T00:08:00Z"), Spec: eachTwoSpec, Description: "each two"},
{Time: must3339("2000-01-01T00:02:00Z"), Spec: eachTwoSpec, Description: "each two"},
{Time: must3339("2000-01-01T00:03:00Z"), Spec: eachThreeSpec, Description: "each three"},
{Time: must3339("2000-01-01T00:04:00Z"), Spec: eachTwoSpec, Description: "each two"},
{Time: must3339("2000-01-01T00:06:00Z"), Spec: eachTwoSpec, Description: "each two"},
{Time: must3339("2000-01-01T00:06:00Z"), Spec: eachThreeSpec, Description: "each three"},
{Time: must3339("2000-01-01T00:07:00Z"), Spec: onSevenSpec, Description: "on seven"},
{Time: must3339("2000-01-01T00:08:00Z"), Spec: eachTwoSpec, Description: "each two"},
}

executions, err := ExecutionsBetween(from, to, -1, []*Schedule{eachTwo, eachThree, onSeven})
Expand Down Expand Up @@ -60,7 +60,7 @@ func Test_ScheduledExecution_ExecutionsBetween_Hourly(t *testing.T) {
from := must3339("2000-01-01T00:00:00Z")
to := must3339("2000-01-02T00:00:00Z")
schedules := []*Schedule{
&Schedule{Cronspec: &hourlySpec, Description: "each hour"},
{Cronspec: &hourlySpec, Description: "each hour"},
}
executions, err := ExecutionsBetween(from, to, -1, schedules)
if err != nil {
Expand All @@ -83,10 +83,10 @@ func Test_ScheduledExecution_ExecutionsBetween_OneTimes(t *testing.T) {
from := must3339("2000-01-01T00:00:00Z")
to := must3339("2000-01-02T00:00:00Z")
schedules := []*Schedule{
&Schedule{Timespec: &withinSpec, Description: "spec within"},
&Schedule{Timespec: &anotherWithinSpec, Description: "another spec within"},
{Timespec: &withinSpec, Description: "spec within"},
{Timespec: &anotherWithinSpec, Description: "another spec within"},
// this Schedule should not appear in the output
&Schedule{Timespec: &notWithinSpec, Description: "spec outside"},
{Timespec: &notWithinSpec, Description: "spec outside"},
}
executions, err := ExecutionsBetween(from, to, -1, schedules)
if err != nil {
Expand Down Expand Up @@ -114,9 +114,9 @@ func Test_ScheduledExecution_ExecutionsBetween_OneTimes_WithN(t *testing.T) {
from := must3339("2000-01-01T00:00:00Z")
to := must3339("2000-01-02T00:00:00Z")
schedules := []*Schedule{
&Schedule{Timespec: &withinSpec, Description: "spec within"},
&Schedule{Timespec: &anotherWithinSpec, Description: "another spec within"},
&Schedule{Timespec: &notWithinSpec, Description: "not within"},
{Timespec: &withinSpec, Description: "spec within"},
{Timespec: &anotherWithinSpec, Description: "another spec within"},
{Timespec: &notWithinSpec, Description: "not within"},
}
// N=1
executions, err := ExecutionsBetween(from, to, 1, schedules)
Expand All @@ -141,10 +141,10 @@ func Test_ScheduledExecution_ExecutionsBetween_Mixed_WithN(t *testing.T) {
from := must3339("2000-01-01T00:00:00Z")
to := must3339("2000-01-02T00:00:00Z")
schedules := []*Schedule{
&Schedule{Timespec: &withinSpec, Description: "spec within"},
&Schedule{Cronspec: &minutelySpec, Description: "each other minute"},
&Schedule{Timespec: &anotherWithinSpec, Description: "another spec within"},
&Schedule{Timespec: &notWithinSpec, Description: "not within"},
{Timespec: &withinSpec, Description: "spec within"},
{Cronspec: &minutelySpec, Description: "each other minute"},
{Timespec: &anotherWithinSpec, Description: "another spec within"},
{Timespec: &notWithinSpec, Description: "not within"},
}
executions, err := ExecutionsBetween(from, to, 5, schedules)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/src/github.com/harrowio/harrow/domain/secret_test.go
Expand Up @@ -78,10 +78,10 @@ func Test_Secret_Links(t *testing.T) {
secret := &Secret{Uuid: "456", EnvironmentUuid: "123"}
resp := secret.Links(make(map[string]map[string]string), "https", "test.tld")
want := map[string]map[string]string{
"self": map[string]string{
"self": {
"href": "https://test.tld/secrets/456",
},
"environment": map[string]string{
"environment": {
"href": "https://test.tld/environments/123",
},
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/github.com/harrowio/harrow/domain/user_history.go
Expand Up @@ -42,7 +42,7 @@ func (self *Set) Size() int { return len(self.items) }
func (self *Set) Intersect(other *Set) *Set {
result := NewSet()

for item, _ := range self.items {
for item := range self.items {
if other.Includes(item) {
result.Add(item)
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/github.com/harrowio/harrow/domain/user_test.go
Expand Up @@ -27,7 +27,7 @@ func (store *mockSubscriptionStore) Find(watchableUuid, event, userUuid string)
func (store *mockSubscriptionStore) FindEventsForUser(watchableId, userUuid string) ([]string, error) {
prefix := watchableId + ":" + userUuid + ":"
result := []string{}
for key, _ := range store.subscriptions {
for key := range store.subscriptions {
if strings.HasPrefix(key, prefix) {
result = append(result, key[len(prefix):])
}
Expand Down

0 comments on commit 05f1d26

Please sign in to comment.