Skip to content
This repository has been archived by the owner on Jul 26, 2020. It is now read-only.

Code Refactor #6

Open
wants to merge 16 commits 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
2 changes: 2 additions & 0 deletions .golangci.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ run:

linters:
fast: true
enable:
- golint

# all available settings of specific linters
linters-settings:
Expand Down
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ repos:
types: [go]
language: golang
pass_filenames: false

- id: gomodtidy
name: gomodtidy
description: Tidy modules.
entry: GO111MODULE=on go mod tidy
entry: env GO111MODULE=on go mod tidy
types: [go]
language: golang
pass_filenames: false
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"os"
"path/filepath"

"github.com/breadtubetv/bake/providers"

"github.com/breadtubetv/bake/pkg/providers"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
53 changes: 53 additions & 0 deletions cmd/testconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright © 2019 NAME HERE <EMAIL ADDRESS>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"

"github.com/breadtubetv/bake/pkg/creators"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// testconfigCmd represents the testconfig command
var testconfigCmd = &cobra.Command{
Use: "testconfig",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("testconfig called")
creators.AddConfig(viper.GetViper())
},
}

func init() {
rootCmd.AddCommand(testconfigCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// testconfigCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// testconfigCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"path"

"github.com/breadtubetv/bake/providers"
"github.com/breadtubetv/bake/pkg/providers"
"github.com/breadtubetv/bake/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
2 changes: 1 addition & 1 deletion cmd/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"regexp"

"github.com/breadtubetv/bake/providers"
"github.com/breadtubetv/bake/pkg/providers"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ go 1.12
require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.3
github.com/spf13/viper v1.3.2
github.com/stretchr/testify v1.2.2
github.com/stretchr/testify v1.3.0
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
google.golang.org/api v0.4.0
Expand Down
7 changes: 6 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
Expand All @@ -33,6 +34,8 @@ github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQz
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
Expand All @@ -47,8 +50,10 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg=
Expand Down
35 changes: 35 additions & 0 deletions pkg/creators/creators.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package creators

import (
"fmt"

"github.com/breadtubetv/bake/pkg/providers"
"github.com/spf13/viper"
)

// Creator refers to a single BreadTube creator.
// A creator can have many providers.
type Creator struct {
Name string
Permalink string
Slug string
Tags []string
Providers providers.Providers
}

// FindCreatorBySlug retreives the creator based on the provided
// slug, loads the creator, and returns its creator object.
func FindCreatorBySlug(slug string) *Creator {
fmt.Print(slug)
fmt.Println(viper.GetString("projectRoot"))
return &Creator{}
}

func NewCreator(name, slug string) (*Creator, error) {
// Check if creator already exists
// Generate Permalink
return nil, nil
}

// func (c *Creator) LoadProviders() *Creator
// func (c *Creator) AddTag(tag string) *Creator
29 changes: 29 additions & 0 deletions pkg/providers/provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package providers

// TODO: Patreon, Social (generic social media accounts)

import (
"github.com/pkg/errors"
)

type Providers []*Provider

// Provider specifies the minimum methods a provider needs
// to implement.
type Provider interface {
GetName() string
}

func (pr *Providers) Add(provider *Provider) {
*pr = append(*pr, provider)
}

func (pr *Providers) GetProvider(key string) (*Provider, error) {
for _, provider := range *pr {
if (*provider).GetName() == key {
return provider, nil
}
}

return nil, errors.Errorf("provider '%v' could not be found", key)
}
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions pkg/videos/videos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package videos

import (
"net/url"
)

type Video struct {
ID string
Title string
Source string
URL url.URL
}