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 license headers #79

Merged
merged 3 commits into from
Dec 17, 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
17 changes: 16 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package cmd

import (
Expand All @@ -7,6 +22,7 @@ import (
"io"
"net/http"
"os"

"pb/pkg/common"
internalHTTP "pb/pkg/http"

Expand Down Expand Up @@ -157,5 +173,4 @@ func init() {
GenerateSchemaCmd.Flags().StringP("file", "f", "", "Path to the JSON file to generate schema")
CreateSchemaCmd.Flags().StringP("stream", "s", "", "Name of the stream to associate with the schema")
CreateSchemaCmd.Flags().StringP("file", "f", "", "Path to the JSON file to create schema")

}
15 changes: 15 additions & 0 deletions cmd/installer.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package cmd

import (
Expand Down
16 changes: 16 additions & 0 deletions cmd/uninstaller.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package cmd

import (
"fmt"

"pb/pkg/common"
"pb/pkg/installer"

Expand Down
22 changes: 17 additions & 5 deletions pkg/analytics/analytics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package analytics

import (
Expand Down Expand Up @@ -92,7 +107,7 @@ func CheckAndCreateULID(_ *cobra.Command, _ []string) error {
// Check if config path exists
if _, err := os.Stat(configPath); os.IsNotExist(err) {
// Create the directory if needed
if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(configPath), 0o755); err != nil {
fmt.Printf("could not create config directory: %v\n", err)
return err
}
Expand Down Expand Up @@ -123,7 +138,7 @@ func CheckAndCreateULID(_ *cobra.Command, _ []string) error {
}

// Write updated config with ULID back to the file
if err := os.WriteFile(configPath, newData, 0644); err != nil {
if err := os.WriteFile(configPath, newData, 0o644); err != nil {
fmt.Printf("could not write to config file: %v\n", err)
return err
}
Expand Down Expand Up @@ -152,7 +167,6 @@ func PostRunAnalytics(cmd *cobra.Command, name string, args []string) {
if err != nil {
fmt.Println("Error sending analytics event:", err)
}

}

// sendEvent is a placeholder function to simulate sending an event after command execution.
Expand Down Expand Up @@ -223,7 +237,6 @@ func sendEvent(commandName string, arguments []string, errors *string, execution
return fmt.Errorf("received non-2xx response: %v", resp.Status)
}

//fmt.Println("Event sent successfully:", string(eventJSON))
return nil
}

Expand Down Expand Up @@ -383,5 +396,4 @@ func GetProfile() (config.Profile, error) {
}

return conf.Profiles[conf.DefaultProfile], nil

}
15 changes: 15 additions & 0 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package common

// ANSI escape codes for colors
Expand Down
32 changes: 22 additions & 10 deletions pkg/helm/helm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package helm

import (
Expand Down Expand Up @@ -40,15 +55,14 @@ func ListReleases(namespace string) ([]*release.Release, error) {
}

client := action.NewList(actionConfig)
//client.Deployed = true
// client.Deployed = true

return client.Run()
}

// Apply applies a Helm chart using the provided Helm struct configuration.
// It returns an error if any operation fails, otherwise, it returns nil.
func Apply(h Helm, verbose bool) error {

// Create a logger that does nothing by default
silentLogger := func(_ string, _ ...interface{}) {}

Expand Down Expand Up @@ -82,7 +96,7 @@ func Apply(h Helm, verbose bool) error {
// Add repository
repoAdd(h)

//RepoUpdate()
// RepoUpdate()

// Locate chart path
cp, err := client.ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", h.RepoName, h.ChartName), settings)
Expand All @@ -104,7 +118,7 @@ func Apply(h Helm, verbose bool) error {
client.Wait = true
client.Timeout = 300 * time.Second
client.WaitForJobs = true
//client.IncludeCRDs = true
// client.IncludeCRDs = true

// Merge values
values := values.Options{
Expand Down Expand Up @@ -132,7 +146,7 @@ func repoAdd(h Helm) error {
// Get the repository file path
repoFile := settings.RepositoryConfig

//Ensure the file directory exists as it is required for file locking
// Ensure the file directory exists as it is required for file locking
err := os.MkdirAll(filepath.Dir(repoFile), os.ModePerm)
if err != nil && !os.IsExist(err) {
return err
Expand Down Expand Up @@ -200,7 +214,7 @@ func repoAdd(h Helm) error {
f.Update(&c)

// Write the updated repository file
if err := f.WriteFile(repoFile, 0644); err != nil {
if err := f.WriteFile(repoFile, 0o644); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -294,7 +308,6 @@ func DeleteRelease(chartName, namespace string) error {
}

func Upgrade(h Helm) error {

settings := cli.New()

// Initialize action configuration
Expand All @@ -311,7 +324,7 @@ func Upgrade(h Helm) error {
// Add repository
repoAdd(h)

//RepoUpdate()
// RepoUpdate()

// Locate chart path
cp, err := client.ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", h.RepoName, h.ChartName), settings)
Expand All @@ -332,7 +345,7 @@ func Upgrade(h Helm) error {
client.Wait = true
client.Timeout = 300 * time.Second
client.WaitForJobs = true
//client.IncludeCRDs = true
// client.IncludeCRDs = true

// Merge values
values := values.Options{
Expand All @@ -352,7 +365,6 @@ func Upgrade(h Helm) error {
}

func Uninstall(h Helm, verbose bool) (*release.UninstallReleaseResponse, error) {

// Create a logger that does nothing by default
silentLogger := func(_ string, _ ...interface{}) {}

Expand Down
15 changes: 15 additions & 0 deletions pkg/installer/installer.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package installer

import (
Expand Down
15 changes: 15 additions & 0 deletions pkg/installer/model.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package installer

// deploymentType represents the type of deployment for the application.
Expand Down
15 changes: 15 additions & 0 deletions pkg/installer/plans.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package installer

import (
Expand Down
18 changes: 17 additions & 1 deletion pkg/installer/spinner.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package installer

import (
"fmt"
"pb/pkg/common"
"time"

"pb/pkg/common"

"github.com/briandowns/spinner"
)

Expand Down
23 changes: 19 additions & 4 deletions pkg/installer/uninstaller.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024 Parseable, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package installer

import (
Expand All @@ -6,11 +21,12 @@ import (
"fmt"
"os"
"path/filepath"
"pb/pkg/common"
"pb/pkg/helm"
"strings"
"time"

"pb/pkg/common"
"pb/pkg/helm"

"gopkg.in/yaml.v2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -41,7 +57,7 @@ func Uninstaller(verbose bool) error {
return fmt.Errorf("failed to get user confirmation: %v", err)
}
if !confirm {
return fmt.Errorf("Uninstall cancelled.")
return fmt.Errorf("Uninstall canceled.")
}

// Helm application configuration
Expand Down Expand Up @@ -91,7 +107,6 @@ func Uninstaller(verbose bool) error {
fmt.Printf(common.Green+"Successfully uninstalled Parseable from namespace '%s'.\n"+common.Reset, namespace)

return nil

}

// promptUserConfirmation prompts the user for a yes/no confirmation
Expand Down
Loading
Loading