Skip to content

Commit

Permalink
Move shared packages and protos from sapagent to platform
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698290654
  • Loading branch information
karkunpavan authored and copybara-github committed Nov 22, 2024
1 parent 94f392c commit af5714d
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 35 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"go.uber.org/zap/zapcore"
"github.com/GoogleCloudPlatform/sapagent/shared/gce/metadataserver"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagent/internal/daemon"
"github.com/GoogleCloudPlatform/workloadagent/internal/onetime/logusage"
"github.com/GoogleCloudPlatform/workloadagent/internal/onetime"
"github.com/GoogleCloudPlatform/workloadagent/internal/onetime/version"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/gce/metadataserver"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"

cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/commondiscovery/commondiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"time"

"github.com/shirou/gopsutil/v3/process"
"github.com/GoogleCloudPlatform/sapagent/shared/commandlineexecutor"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/commandlineexecutor"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/daemon/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"go.uber.org/zap/zapcore"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"

dpb "google.golang.org/protobuf/types/known/durationpb"
cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
Expand Down
4 changes: 2 additions & 2 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"time"

"github.com/spf13/cobra"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/sapagent/shared/recovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/commondiscovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/daemon/configuration"
"github.com/GoogleCloudPlatform/workloadagent/internal/daemon/mysql"
"github.com/GoogleCloudPlatform/workloadagent/internal/daemon/oracle"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/recovery"

cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/daemon/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"time"

"go.uber.org/zap/zapcore"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/sapagent/shared/recovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/commondiscovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/mysqldiscovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/mysqlmetrics"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/recovery"
)

// Service implements the interfaces for MySQL workload agent service.
Expand Down
4 changes: 2 additions & 2 deletions internal/daemon/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import (
"slices"
"time"

"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/sapagent/shared/recovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/commondiscovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/oraclediscovery"
"github.com/GoogleCloudPlatform/workloadagent/internal/oraclemetrics"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
odpb "github.com/GoogleCloudPlatform/workloadagent/protos/oraclediscovery"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/recovery"
)

// Service implements the interfaces for Oracle workload agent service.
Expand Down
2 changes: 1 addition & 1 deletion internal/mysqldiscovery/mysqldiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package mysqldiscovery
import (
"context"

"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
)

// Discover runs the MySQL discovery routine.
Expand Down
2 changes: 1 addition & 1 deletion internal/mysqlmetrics/mysqlmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package mysqlmetrics
import (
"context"

"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
)

// CollectMetricsOnce collects metrics for MySQL databases running on the host.
Expand Down
10 changes: 5 additions & 5 deletions internal/onetime/logusage/logusage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagent/internal/daemon/configuration"
"github.com/GoogleCloudPlatform/workloadagent/internal/onetime"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"

cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
)
Expand Down Expand Up @@ -101,8 +101,8 @@ func NewCommand(lp log.Parameters, cloudProps *cpb.CloudProperties) *cobra.Comma
logUsageCmd.Flags().IntVar(&l.action, "a", 0, "usage action code")
logUsageCmd.Flags().IntVar(&l.usageError, "error", 0, "usage error code")
logUsageCmd.Flags().IntVar(&l.usageError, "e", 0, "usage error code")
logUsageCmd.Flags().StringVar(&l.image, "image", "", "the image url of the compute instance(optional), default value is retreived from metadata)")
logUsageCmd.Flags().StringVar(&l.image, "i", "", "the image url of the compute instance(optional), default value is retreived from metadata)")
logUsageCmd.Flags().StringVar(&l.image, "image", "", "the image url of the compute instance(optional), default value is retrieved from metadata)")
logUsageCmd.Flags().StringVar(&l.image, "i", "", "the image url of the compute instance(optional), default value is retrieved from metadata)")

return logUsageCmd
}
Expand All @@ -118,8 +118,8 @@ func (l *LogUsage) logUsageHandler(cmd *cobra.Command, cloudProps *cpb.CloudProp
log.Print("A usage status value is required.")
return fmt.Errorf("a usage status value is required")
case l.status == string(usagemetrics.StatusUpdated) && l.agentVersion == "":
log.Print("For status UPDATED, Agent Version is requried.")
return fmt.Errorf("for status UPDATED, Agent Version is requried")
log.Print("For status UPDATED, Agent Version is required.")
return fmt.Errorf("for status UPDATED, Agent Version is required")
case l.status == string(usagemetrics.StatusError) && l.usageError <= 0:
log.Print("For status ERROR, an error code is required.")
return fmt.Errorf("for status ERROR, an error code is required")
Expand Down
2 changes: 1 addition & 1 deletion internal/onetime/onetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"go.uber.org/zap/zapcore"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagent/internal/daemon/configuration"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion internal/onetime/onetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

"go.uber.org/zap/zapcore"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
)

func TestSetupOneTimeLogging(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/oraclediscovery/oraclediscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import (

timestamppb "google.golang.org/protobuf/types/known/timestamppb"
"github.com/shirou/gopsutil/v3/process"
"github.com/GoogleCloudPlatform/sapagent/shared/commandlineexecutor"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
odpb "github.com/GoogleCloudPlatform/workloadagent/protos/oraclediscovery"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/commandlineexecutor"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/oraclediscovery/oraclediscovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
tpb "google.golang.org/protobuf/types/known/timestamppb"
"github.com/google/go-cmp/cmp"
"google.golang.org/protobuf/testing/protocmp"
"github.com/GoogleCloudPlatform/sapagent/shared/commandlineexecutor"
cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
odpb "github.com/GoogleCloudPlatform/workloadagent/protos/oraclediscovery"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/commandlineexecutor"
)

//go:embed testdata/*
Expand Down
10 changes: 5 additions & 5 deletions internal/oraclemetrics/oraclemetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (

"golang.org/x/exp/maps"
"github.com/gammazero/workerpool"
"github.com/GoogleCloudPlatform/sapagent/shared/cloudmonitoring"
"github.com/GoogleCloudPlatform/sapagent/shared/gce"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/sapagent/shared/recovery"
"github.com/GoogleCloudPlatform/sapagent/shared/timeseries"
"github.com/GoogleCloudPlatform/workloadagent/internal/secret"
"github.com/GoogleCloudPlatform/workloadagent/internal/usagemetrics"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/cloudmonitoring"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/gce"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/recovery"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/timeseries"

mpb "google.golang.org/genproto/googleapis/api/metric"
mrpb "google.golang.org/genproto/googleapis/monitoring/v3"
Expand Down
8 changes: 4 additions & 4 deletions internal/oraclemetrics/oraclemetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
"github.com/GoogleCloudPlatform/sapagent/shared/cloudmonitoring"
gcefake "github.com/GoogleCloudPlatform/sapagent/shared/gce/fake"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/sapagent/shared/timeseries"
"github.com/GoogleCloudPlatform/workloadagent/internal/secret"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/cloudmonitoring"
gcefake "github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/gce/fake"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/timeseries"

mpb "google.golang.org/genproto/googleapis/api/metric"
mrespb "google.golang.org/genproto/googleapis/api/monitoredres"
Expand Down
2 changes: 2 additions & 0 deletions internal/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// TODO: Move this to the common shared directory.

// Package secret provides a custom string type that hides sensitive data from output.
package secret

Expand Down
4 changes: 2 additions & 2 deletions internal/usagemetrics/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"time"

"github.com/jonboulle/clockwork"
"github.com/GoogleCloudPlatform/sapagent/shared/log"
"github.com/GoogleCloudPlatform/sapagent/shared/usagemetrics"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/log"
"github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/usagemetrics"

cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/usagemetrics/usagemetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
// Package usagemetrics provides logging utility for the operational status of Google Cloud Agent for SAP.
package usagemetrics

import "github.com/GoogleCloudPlatform/sapagent/shared/usagemetrics"
import "github.com/GoogleCloudPlatform/workloadagentplatform/integration/common/shared/usagemetrics"

// The following status values are supported.
const (
Expand Down

0 comments on commit af5714d

Please sign in to comment.