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

pkg structure refactoring, bump mods #260

Merged
merged 1 commit into from
Jun 11, 2024
Merged
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
26 changes: 13 additions & 13 deletions cmd/cdev/includes.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package main

import (
_ "github.com/shalb/cluster.dev/pkg/backend/azurerm"
_ "github.com/shalb/cluster.dev/pkg/backend/gcs"
_ "github.com/shalb/cluster.dev/pkg/backend/local"
_ "github.com/shalb/cluster.dev/pkg/backend/s3"
_ "github.com/shalb/cluster.dev/internal/backend/azurerm"
_ "github.com/shalb/cluster.dev/internal/backend/gcs"
_ "github.com/shalb/cluster.dev/internal/backend/local"
_ "github.com/shalb/cluster.dev/internal/backend/s3"
_ "github.com/shalb/cluster.dev/internal/project"
_ "github.com/shalb/cluster.dev/internal/secrets/aws_secretmanager"
_ "github.com/shalb/cluster.dev/internal/secrets/sops"
_ "github.com/shalb/cluster.dev/internal/units/shell/common"
_ "github.com/shalb/cluster.dev/internal/units/shell/k8s_manifest"
_ "github.com/shalb/cluster.dev/internal/units/shell/terraform/helm"
_ "github.com/shalb/cluster.dev/internal/units/shell/terraform/kubernetes"
_ "github.com/shalb/cluster.dev/internal/units/shell/terraform/module"
_ "github.com/shalb/cluster.dev/internal/units/shell/terraform/printer"
_ "github.com/shalb/cluster.dev/pkg/logging"
_ "github.com/shalb/cluster.dev/pkg/project"
_ "github.com/shalb/cluster.dev/pkg/secrets/aws_secretmanager"
_ "github.com/shalb/cluster.dev/pkg/secrets/sops"
_ "github.com/shalb/cluster.dev/pkg/units/shell/common"
_ "github.com/shalb/cluster.dev/pkg/units/shell/k8s_manifest"
_ "github.com/shalb/cluster.dev/pkg/units/shell/terraform/helm"
_ "github.com/shalb/cluster.dev/pkg/units/shell/terraform/kubernetes"
_ "github.com/shalb/cluster.dev/pkg/units/shell/terraform/module"
_ "github.com/shalb/cluster.dev/pkg/units/shell/terraform/printer"
)
2 changes: 1 addition & 1 deletion cmd/cdev/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/shalb/cluster.dev/pkg/cmd/cdev"
"github.com/shalb/cluster.dev/internal/cmd/cdev"
)

func main() {
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.2
github.com/getsops/sops/v3 v3.8.1
github.com/google/go-github v17.0.0+incompatible
github.com/gookit/color v1.5.4
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.48
github.com/hashicorp/hcl/v2 v2.19.1
Expand All @@ -29,7 +30,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/tj/go-spin v1.1.0
github.com/zclconf/go-cty v1.14.1
golang.org/x/crypto v0.21.0
golang.org/x/crypto v0.24.0
golang.org/x/oauth2 v0.13.0
google.golang.org/api v0.148.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -40,7 +41,6 @@ require (
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-github/v60 v60.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
)
Expand Down Expand Up @@ -191,20 +191,20 @@ require (
go.opentelemetry.io/otel/trace v1.23.1 // indirect
go.starlark.net v0.0.0-20231016134836-22325403fcb3 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v5 v5.7.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"fmt"
"strings"

"github.com/apex/log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/apex/log"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/hcltools"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/pkg/utils"
"github.com/zclconf/go-cty/cty"
"gopkg.in/yaml.v3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package azurerm

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"gopkg.in/yaml.v3"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gcs

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"gopkg.in/yaml.v3"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/gcs/gcs.go → internal/backend/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"cloud.google.com/go/storage"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/shalb/cluster.dev/pkg/hcltools"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"github.com/zclconf/go-cty/cty"
"golang.org/x/oauth2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path/filepath"

"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"gopkg.in/yaml.v3"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/project"
"github.com/zclconf/go-cty/cty"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package s3

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"gopkg.in/yaml.v3"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/backend/s3/s3.go → internal/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/aws/aws-sdk-go-v2/service/s3/types"
awsbase "github.com/hashicorp/aws-sdk-go-base/v2"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"github.com/zclconf/go-cty/cty"
"gopkg.in/yaml.v3"
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/apply.go → internal/cmd/cdev/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cdev

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/pkg/utils"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cdev/build.go → internal/cmd/cdev/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cdev

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/project"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/destroy.go → internal/cmd/cdev/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cdev

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cdev/main.go → internal/cmd/cdev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/pkg/profiler"
"github.com/shalb/cluster.dev/pkg/utils"
"github.com/spf13/cobra"
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/output.go → internal/cmd/cdev/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cdev

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/plan.go → internal/cmd/cdev/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/cdev/project.go → internal/cmd/cdev/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strings"

"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/pkg/project/ui"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/internal/project/ui"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/secrets.go → internal/cmd/cdev/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cdev

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/pkg/project/ui"
"github.com/shalb/cluster.dev/internal/project"
"github.com/shalb/cluster.dev/internal/project/ui"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/state.go → internal/cmd/cdev/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cdev

import (
"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/types.go → internal/cmd/cdev/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cdev
import (
"runtime"

"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/project"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/internal/project"
)

type CmdErrExtended struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/project/commands.go → internal/project/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/apex/log"
"github.com/paulrademacher/climenu"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/pkg/colors"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/utils"
)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/project/graph.go → internal/project/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/internal/config"
)

type ExecutionStatus uint16
Expand Down
32 changes: 31 additions & 1 deletion pkg/project/helpers.go → internal/project/helpers.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package project

import (
"context"
"fmt"
"os"
"path/filepath"
"reflect"
"regexp"
"strings"

"github.com/Masterminds/semver"
"github.com/apex/log"
"github.com/google/go-github/github"

"github.com/olekukonko/tablewriter"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/pkg/colors"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/pkg/utils"
)

Expand Down Expand Up @@ -129,6 +132,33 @@ func (s *ProjectPlanningStatus) AddOrUpdate(u Unit, op UnitOperation, diff strin
}
}

func DiscoverCdevLastRelease() error {
var (
client = github.NewClient(nil)
ctx = context.Background()
org string = "shalb"
project string = "cluster.dev"
)

latestRelease, _, err := client.Repositories.GetLatestRelease(ctx, org, project)
if err != nil {
return err
}
curVersion, err := semver.NewVersion(config.Version)
if err != nil {
return fmt.Errorf("check failed: %v, current version: %v", err, config.Global.Version)
}
reqVerConstraints, err := semver.NewConstraint(*latestRelease.TagName)
if err != nil {
return fmt.Errorf("check failed: %v, latest stable release: %v", err, *latestRelease.TagName)
}
ok, _ := reqVerConstraints.Validate(curVersion)
if !ok {
return fmt.Errorf("the new cdev version is available. Current version: '%v', latest stable release: '%v'. Visit https://docs.cluster.dev/installation-upgrade/ to upgrade", curVersion, *latestRelease.TagName)
}
return nil
}

func (s *ProjectPlanningStatus) AddIfNotExists(u Unit, op UnitOperation, diff string, tainted bool) {
existingUnit := s.FindUnitByKey(u)
if existingUnit == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/project/project.go → internal/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/apex/log"
"github.com/gookit/color"
"github.com/olekukonko/tablewriter"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/pkg/utils"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -77,7 +77,7 @@ func NewEmptyProject() *Project {
CodeCacheDir: config.Global.CacheDir,
}
log.Info("Checking for newer releases...")
err := utils.DiscoverCdevLastRelease()
err := DiscoverCdevLastRelease()
if err != nil {
log.Warnf("Version check: %v.", err)
project.NewVersionMessage = fmt.Sprintf("Version check: %v", err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"

"github.com/apex/log"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/pkg/utils"
"gopkg.in/yaml.v3"
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/project/secret.go → internal/project/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/apex/log"
"github.com/olekukonko/tablewriter"
"github.com/shalb/cluster.dev/pkg/config"
"github.com/shalb/cluster.dev/internal/config"
"github.com/shalb/cluster.dev/pkg/utils"
)

Expand Down
Loading
Loading